]> git.saurik.com Git - apt.git/blob - test/scratch.cc
Be quiet in apt.post{inst,rm}.
[apt.git] / 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>
10
11 int main(int argc,char *argv[])
12 {
13 pkgInitialize(*_config);
14
15 // cout << flNoLink(argv[1]) << endl;
16
17 // #if 0
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)
45 {
46 _error->DumpErrors();
47 return 0;
48 }
49
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++)
83 {
84 FileFd F(argv[I],FileFd::ReadOnly);
85 debDebFile Deb(F);
86
87 if (Deb.ExtractControl(Db) == false)
88 cerr << "Error!" << endl;
89 cout << argv[I] << endl;
90
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;
96
97 pkgExtract Extract(Db.GetFLCache(),Ver);
98 Deb.ExtractArchive(Extract);
99 }
100 // #endif
101 //#endif
102 _error->DumpErrors();
103 }