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