]>
Commit | Line | Data |
---|---|---|
b2e465d6 AL |
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/strutl.h> | |
9 | ||
10 | #include <stdio.h> | |
11 | #include <stdlib.h> | |
12 | ||
5a8748f1 AL |
13 | using namespace std; |
14 | ||
b2e465d6 AL |
15 | bool Go(int argc,char *argv[]) |
16 | { | |
17 | // Init the database | |
18 | debDpkgDB Db; | |
19 | { | |
20 | OpTextProgress Prog; | |
21 | ||
22 | if (Db.ReadyPkgCache(Prog) == false) | |
23 | return false; | |
24 | Prog.Done(); | |
25 | ||
26 | if (Db.ReadyFileList(Prog) == false) | |
27 | return false; | |
28 | } | |
29 | ||
30 | for (int I = 1; I < argc; I++) | |
31 | { | |
32 | const char *Fake = 0; | |
33 | for (unsigned J = 0; argv[I][J] != 0; J++) | |
34 | { | |
35 | if (argv[I][J] != ',') | |
36 | continue; | |
37 | Fake = argv[I] + J + 1; | |
38 | argv[I][J] = 0; | |
39 | } | |
40 | ||
41 | FileFd F(argv[I],FileFd::ReadOnly); | |
42 | debDebFile Deb(F); | |
43 | ||
44 | if (_error->PendingError() == true) | |
45 | return false; | |
46 | ||
47 | if (Deb.ExtractControl(Db) == false) | |
48 | return false; | |
49 | cout << argv[I] << endl; | |
50 | ||
51 | pkgCache::VerIterator Ver = Deb.MergeControl(Db); | |
52 | if (Ver.end() == true) | |
53 | return false; | |
54 | ||
55 | cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl; | |
56 | ||
57 | pkgExtract Extract(Db.GetFLCache(),Ver); | |
58 | ||
59 | if (Fake != 0) | |
60 | { | |
61 | pkgExtract::Item Itm; | |
62 | memset(&Itm,0,sizeof(Itm)); | |
63 | FILE *F = fopen(Fake,"r"); | |
64 | while (feof(F) == 0) | |
65 | { | |
66 | char Line[300]; | |
67 | fgets(Line,sizeof(Line),F); | |
68 | Itm.Name = _strstrip(Line); | |
69 | Itm.Type = pkgDirStream::Item::File; | |
70 | if (Line[strlen(Line)-1] == '/') | |
71 | Itm.Type = pkgDirStream::Item::Directory; | |
72 | ||
73 | int Fd; | |
6070a346 DK |
74 | if (Extract.DoItem(Itm,Fd) == false) { |
75 | fclose(F); | |
b2e465d6 | 76 | return false; |
6070a346 DK |
77 | } |
78 | } | |
79 | fclose(F); | |
b2e465d6 AL |
80 | } |
81 | else | |
82 | if (Deb.ExtractArchive(Extract) == false) | |
83 | return false; | |
84 | } | |
85 | return true; | |
86 | } | |
87 | ||
88 | int main(int argc,char *argv[]) | |
89 | { | |
5a8748f1 AL |
90 | pkgInitConfig(*_config); |
91 | pkgInitSystem(*_config,_system); | |
b2e465d6 AL |
92 | _config->Set("Dir::State::status","/tmp/testing/status"); |
93 | ||
94 | Go(argc,argv); | |
95 | ||
96 | if (_error->PendingError() == true) | |
97 | { | |
98 | _error->DumpErrors(); | |
99 | return 0; | |
100 | } | |
101 | } |