]>
git.saurik.com Git - apt.git/blob - test/scratch.cc
1 #define APT_COMPATIBILITY 1
2 #include <apt-pkg/dpkgdb.h>
3 #include <apt-pkg/debfile.h>
4 #include <apt-pkg/error.h>
5 #include <apt-pkg/configuration.h>
6 #include <apt-pkg/progress.h>
7 #include <apt-pkg/extract.h>
8 #include <apt-pkg/init.h>
9 #include <apt-pkg/fileutl.h>
11 int main(int argc
,char *argv
[])
13 pkgInitialize(*_config
);
15 // cout << flNoLink(argv[1]) << endl;
18 /* DynamicMMap *FileMap = new DynamicMMap(MMap::Public);
19 pkgFLCache *FList = new pkgFLCache(*FileMap);
21 char *Name = "/tmp/test";
22 pkgFLCache::PkgIterator Pkg(*FList,0);
23 pkgFLCache::NodeIterator Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
24 cout << (pkgFLCache::Node *)Node << endl;
25 Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
26 cout << (pkgFLCache::Node *)Node << endl;
29 _config
->Set("Dir::State::status","/tmp/testing/status");
36 if (Db
.ReadyPkgCache(Prog
) == false)
37 cerr
<< "Error!" << endl
;
40 if (Db
.ReadyFileList(Prog
) == false)
41 cerr
<< "Error!" << endl
;
44 if (_error
->PendingError() == true)
50 /* Db.GetFLCache().BeginDiverLoad();
51 pkgFLCache::PkgIterator Pkg(Db.GetFLCache(),0);
52 if (Db.GetFLCache().AddDiversion(Pkg,"/usr/include/linux/kerneld.h","/usr/bin/nslookup") == false)
53 cerr << "Error!" << endl;
55 const char *Tmp = "/usr/include/linux/kerneld.h";
56 pkgFLCache::NodeIterator Nde = Db.GetFLCache().GetNode(Tmp,Tmp+strlen(Tmp),0,false,false);
57 map_ptrloc Loc = Nde->File;
59 for (; Nde.end() == false && Nde->File == Loc; Nde++)
60 cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl;
61 Db.GetFLCache().FinishDiverLoad();*/
63 /* unsigned int I = 0;
64 pkgFLCache &Fl = Db.GetFLCache();
65 while (I < Fl.HeaderP->HashSize)
68 pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++);
69 if (Node->Pointer == 0)
71 for (; Node.end() == false; Node++)
73 cout << Node.DirN() << '/' << Node.File();
74 if (Node->Flags == pkgFLCache::Node::Diversion)
76 if (Node->Flags == pkgFLCache::Node::ConfFile)
82 for (int I
= 1; I
< argc
; I
++)
84 FileFd
F(argv
[I
],FileFd::ReadOnly
);
87 if (Deb
.ExtractControl(Db
) == false)
88 cerr
<< "Error!" << endl
;
89 cout
<< argv
[I
] << endl
;
91 pkgCache::VerIterator Ver
= Deb
.MergeControl(Db
);
92 if (Ver
.end() == true)
93 cerr
<< "Failed" << endl
;
95 cout
<< Ver
.ParentPkg().Name() << ' ' << Ver
.VerStr() << endl
;
97 pkgExtract
Extract(Db
.GetFLCache(),Ver
);
98 Deb
.ExtractArchive(Extract
);
102 _error
->DumpErrors();