]>
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>
10 int main(int argc
,char *argv
[])
12 pkgInitialize(*_config
);
14 cout
<< flNoLink(argv
[1]) << endl
;
17 /* DynamicMMap *FileMap = new DynamicMMap(MMap::Public);
18 pkgFLCache *FList = new pkgFLCache(*FileMap);
20 char *Name = "/tmp/test";
21 pkgFLCache::PkgIterator Pkg(*FList,0);
22 pkgFLCache::NodeIterator Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
23 cout << (pkgFLCache::Node *)Node << endl;
24 Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
25 cout << (pkgFLCache::Node *)Node << endl;
28 _config
->Set("Dir::State::status","/tmp/testing/status");
35 if (Db
.ReadyPkgCache(Prog
) == false)
36 cerr
<< "Error!" << endl
;
39 if (Db
.ReadyFileList(Prog
) == false)
40 cerr
<< "Error!" << endl
;
43 if (_error
->PendingError() == true)
49 /* Db.GetFLCache().BeginDiverLoad();
50 pkgFLCache::PkgIterator Pkg(Db.GetFLCache(),0);
51 if (Db.GetFLCache().AddDiversion(Pkg,"/usr/include/linux/kerneld.h","/usr/bin/nslookup") == false)
52 cerr << "Error!" << endl;
54 const char *Tmp = "/usr/include/linux/kerneld.h";
55 pkgFLCache::NodeIterator Nde = Db.GetFLCache().GetNode(Tmp,Tmp+strlen(Tmp),0,false,false);
56 map_ptrloc Loc = Nde->File;
58 for (; Nde.end() == false && Nde->File == Loc; Nde++)
59 cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl;
60 Db.GetFLCache().FinishDiverLoad();*/
62 /* unsigned int I = 0;
63 pkgFLCache &Fl = Db.GetFLCache();
64 while (I < Fl.HeaderP->HashSize)
67 pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++);
68 if (Node->Pointer == 0)
70 for (; Node.end() == false; Node++)
72 cout << Node.DirN() << '/' << Node.File();
73 if (Node->Flags == pkgFLCache::Node::Diversion)
75 if (Node->Flags == pkgFLCache::Node::ConfFile)
81 for (int I
= 1; I
< argc
; I
++)
83 FileFd
F(argv
[I
],FileFd::ReadOnly
);
86 if (Deb
.ExtractControl(Db
) == false)
87 cerr
<< "Error!" << endl
;
88 cout
<< argv
[I
] << endl
;
90 pkgCache::VerIterator Ver
= Deb
.MergeControl(Db
);
91 if (Ver
.end() == true)
92 cerr
<< "Failed" << endl
;
94 cout
<< Ver
.ParentPkg().Name() << ' ' << Ver
.VerStr() << endl
;
96 pkgExtract
Extract(Db
.GetFLCache(),Ver
);
97 Deb
.ExtractArchive(Extract
);
101 _error
->DumpErrors();