]> git.saurik.com Git - apt.git/blame - test/scratch.cc
* apt-pkg/pkgcachegen.cc:
[apt.git] / test / scratch.cc
CommitLineData
421c8d10
AL
1#include <apt-pkg/dpkgdb.h>
2#include <apt-pkg/debfile.h>
2fd65468 3#include <apt-pkg/error.h>
421c8d10
AL
4#include <apt-pkg/configuration.h>
5#include <apt-pkg/progress.h>
6#include <apt-pkg/extract.h>
2fd65468 7#include <apt-pkg/init.h>
421c8d10 8#include <apt-pkg/fileutl.h>
b98f2859 9
5a8748f1
AL
10using namespace std;
11
93bf083d 12int main(int argc,char *argv[])
024835dc 13{
5a8748f1
AL
14 pkgInitConfig(*_config);
15 pkgInitSystem(*_config,_system);
421c8d10 16
eac03193 17// cout << flNoLink(argv[1]) << endl;
421c8d10 18
eac03193 19// #if 0
421c8d10
AL
20/* DynamicMMap *FileMap = new DynamicMMap(MMap::Public);
21 pkgFLCache *FList = new pkgFLCache(*FileMap);
22
23 char *Name = "/tmp/test";
24 pkgFLCache::PkgIterator Pkg(*FList,0);
25 pkgFLCache::NodeIterator Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
26 cout << (pkgFLCache::Node *)Node << endl;
27 Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
28 cout << (pkgFLCache::Node *)Node << endl;
29*/
30// #if 0
31 _config->Set("Dir::State::status","/tmp/testing/status");
32
33 debDpkgDB Db;
34
35 {
36 OpTextProgress Prog;
37
38 if (Db.ReadyPkgCache(Prog) == false)
39 cerr << "Error!" << endl;
40 Prog.Done();
41
42 if (Db.ReadyFileList(Prog) == false)
43 cerr << "Error!" << endl;
44 }
45
46 if (_error->PendingError() == true)
2fd65468
AL
47 {
48 _error->DumpErrors();
49 return 0;
50 }
51
421c8d10
AL
52/* Db.GetFLCache().BeginDiverLoad();
53 pkgFLCache::PkgIterator Pkg(Db.GetFLCache(),0);
54 if (Db.GetFLCache().AddDiversion(Pkg,"/usr/include/linux/kerneld.h","/usr/bin/nslookup") == false)
55 cerr << "Error!" << endl;
56
57 const char *Tmp = "/usr/include/linux/kerneld.h";
58 pkgFLCache::NodeIterator Nde = Db.GetFLCache().GetNode(Tmp,Tmp+strlen(Tmp),0,false,false);
59 map_ptrloc Loc = Nde->File;
60
61 for (; Nde.end() == false && Nde->File == Loc; Nde++)
62 cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl;
63 Db.GetFLCache().FinishDiverLoad();*/
64
65/* unsigned int I = 0;
66 pkgFLCache &Fl = Db.GetFLCache();
67 while (I < Fl.HeaderP->HashSize)
68 {
69 cout << I << endl;
70 pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++);
71 if (Node->Pointer == 0)
72 continue;
73 for (; Node.end() == false; Node++)
74 {
75 cout << Node.DirN() << '/' << Node.File();
76 if (Node->Flags == pkgFLCache::Node::Diversion)
77 cout << " (div)";
78 if (Node->Flags == pkgFLCache::Node::ConfFile)
79 cout << " (conf)";
80 cout << endl;
81 }
82 }*/
83
84 for (int I = 1; I < argc; I++)
2fd65468 85 {
421c8d10
AL
86 FileFd F(argv[I],FileFd::ReadOnly);
87 debDebFile Deb(F);
2fd65468 88
421c8d10
AL
89 if (Deb.ExtractControl(Db) == false)
90 cerr << "Error!" << endl;
91 cout << argv[I] << endl;
2fd65468 92
421c8d10
AL
93 pkgCache::VerIterator Ver = Deb.MergeControl(Db);
94 if (Ver.end() == true)
95 cerr << "Failed" << endl;
96 else
97 cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl;
2fd65468 98
421c8d10
AL
99 pkgExtract Extract(Db.GetFLCache(),Ver);
100 Deb.ExtractArchive(Extract);
2fd65468 101 }
421c8d10 102// #endif
eac03193 103//#endif
421c8d10 104 _error->DumpErrors();
024835dc 105}