]>
git.saurik.com Git - apt.git/blob - test/interactive-helper/testextract.cc
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 #include <apt-pkg/fileutl.h>
10 #include <apt-pkg/pkgsystem.h>
17 bool Go(int argc
,char *argv
[])
24 if (Db
.ReadyPkgCache(Prog
) == false)
28 if (Db
.ReadyFileList(Prog
) == false)
32 for (int I
= 1; I
< argc
; I
++)
35 for (unsigned J
= 0; argv
[I
][J
] != 0; J
++)
37 if (argv
[I
][J
] != ',')
39 Fake
= argv
[I
] + J
+ 1;
43 FileFd
F(argv
[I
],FileFd::ReadOnly
);
46 if (_error
->PendingError() == true)
49 if (Deb
.ExtractControl(Db
) == false)
51 cout
<< argv
[I
] << endl
;
53 pkgCache::VerIterator Ver
= Deb
.MergeControl(Db
);
54 if (Ver
.end() == true)
57 cout
<< Ver
.ParentPkg().Name() << ' ' << Ver
.VerStr() << endl
;
59 pkgExtract
Extract(Db
.GetFLCache(),Ver
);
64 memset(&Itm
,0,sizeof(Itm
));
65 FILE *F
= fopen(Fake
,"r");
69 fgets(Line
,sizeof(Line
),F
);
70 Itm
.Name
= _strstrip(Line
);
71 Itm
.Type
= pkgDirStream::Item::File
;
72 if (Line
[strlen(Line
)-1] == '/')
73 Itm
.Type
= pkgDirStream::Item::Directory
;
76 if (Extract
.DoItem(Itm
,Fd
) == false) {
84 if (Deb
.ExtractArchive(Extract
) == false)
90 int main(int argc
,char *argv
[])
92 pkgInitConfig(*_config
);
93 pkgInitSystem(*_config
,_system
);
94 _config
->Set("Dir::State::status","/tmp/testing/status");
98 if (_error
->PendingError() == true)
100 _error
->DumpErrors();