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