]>
git.saurik.com Git - apt.git/blob - test/scratch.cc
1 #include <apt-pkg/dpkgdb.h>
2 #include <apt-pkg/debfile.h>
3 #include <apt-pkg/error.h>
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/progress.h>
6 #include <apt-pkg/extract.h>
7 #include <apt-pkg/init.h>
8 #include <apt-pkg/fileutl.h>
12 int main(int argc
,char *argv
[])
14 pkgInitConfig(*_config
);
15 pkgInitSystem(*_config
,_system
);
17 // cout << flNoLink(argv[1]) << endl;
20 /* DynamicMMap *FileMap = new DynamicMMap(MMap::Public);
21 pkgFLCache *FList = new pkgFLCache(*FileMap);
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;
31 _config
->Set("Dir::State::status","/tmp/testing/status");
38 if (Db
.ReadyPkgCache(Prog
) == false)
39 cerr
<< "Error!" << endl
;
42 if (Db
.ReadyFileList(Prog
) == false)
43 cerr
<< "Error!" << endl
;
46 if (_error
->PendingError() == true)
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;
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;
61 for (; Nde.end() == false && Nde->File == Loc; Nde++)
62 cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl;
63 Db.GetFLCache().FinishDiverLoad();*/
65 /* unsigned int I = 0;
66 pkgFLCache &Fl = Db.GetFLCache();
67 while (I < Fl.HeaderP->HashSize)
70 pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++);
71 if (Node->Pointer == 0)
73 for (; Node.end() == false; Node++)
75 cout << Node.DirN() << '/' << Node.File();
76 if (Node->Flags == pkgFLCache::Node::Diversion)
78 if (Node->Flags == pkgFLCache::Node::ConfFile)
84 for (int I
= 1; I
< argc
; I
++)
86 FileFd
F(argv
[I
],FileFd::ReadOnly
);
89 if (Deb
.ExtractControl(Db
) == false)
90 cerr
<< "Error!" << endl
;
91 cout
<< argv
[I
] << endl
;
93 pkgCache::VerIterator Ver
= Deb
.MergeControl(Db
);
94 if (Ver
.end() == true)
95 cerr
<< "Failed" << endl
;
97 cout
<< Ver
.ParentPkg().Name() << ' ' << Ver
.VerStr() << endl
;
99 pkgExtract
Extract(Db
.GetFLCache(),Ver
);
100 Deb
.ExtractArchive(Extract
);
104 _error
->DumpErrors();