X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/93bf083d699c60f1ac40297bfa6783fb0cb800d8..213b88053da331adf07b89ce35c8eb9cff914be4:/test/scratch.cc diff --git a/test/scratch.cc b/test/scratch.cc index 7cd43c554..d638c7097 100644 --- a/test/scratch.cc +++ b/test/scratch.cc @@ -1,38 +1,105 @@ -#include -#include +#include +#include #include -#include -#include +#include +#include +#include +#include +#include + +using namespace std; int main(int argc,char *argv[]) { - signal(SIGPIPE,SIG_IGN); + pkgInitConfig(*_config); + pkgInitSystem(*_config,_system); -/* URI Foo(argv[1]); - cout << Foo.Access << '\'' << endl; - cout << Foo.Host << '\'' << endl; - cout << Foo.Path << '\'' << endl; - cout << Foo.User << '\'' << endl; - cout << Foo.Password << '\'' << endl; - cout << Foo.Port << endl; +// cout << flNoLink(argv[1]) << endl; - return 0;*/ +// #if 0 +/* DynamicMMap *FileMap = new DynamicMMap(MMap::Public); + pkgFLCache *FList = new pkgFLCache(*FileMap); - pkgInitialize(*_config); + char *Name = "/tmp/test"; + pkgFLCache::PkgIterator Pkg(*FList,0); + pkgFLCache::NodeIterator Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false); + cout << (pkgFLCache::Node *)Node << endl; + Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false); + cout << (pkgFLCache::Node *)Node << endl; +*/ +// #if 0 + _config->Set("Dir::State::status","/tmp/testing/status"); + + debDpkgDB Db; - pkgSourceList List; - pkgAcquire Fetcher; - List.ReadMainList(); + { + OpTextProgress Prog; + + if (Db.ReadyPkgCache(Prog) == false) + cerr << "Error!" << endl; + Prog.Done(); + + if (Db.ReadyFileList(Prog) == false) + cerr << "Error!" << endl; + } - pkgSourceList::const_iterator I; - for (I = List.begin(); I != List.end(); I++) + if (_error->PendingError() == true) { - new pkgAcqIndex(&Fetcher,I); - if (_error->PendingError() == true) - break; + _error->DumpErrors(); + return 0; } - - Fetcher.Run(); +/* Db.GetFLCache().BeginDiverLoad(); + pkgFLCache::PkgIterator Pkg(Db.GetFLCache(),0); + if (Db.GetFLCache().AddDiversion(Pkg,"/usr/include/linux/kerneld.h","/usr/bin/nslookup") == false) + cerr << "Error!" << endl; + + const char *Tmp = "/usr/include/linux/kerneld.h"; + pkgFLCache::NodeIterator Nde = Db.GetFLCache().GetNode(Tmp,Tmp+strlen(Tmp),0,false,false); + map_ptrloc Loc = Nde->File; + + for (; Nde.end() == false && Nde->File == Loc; Nde++) + cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl; + Db.GetFLCache().FinishDiverLoad();*/ + +/* unsigned int I = 0; + pkgFLCache &Fl = Db.GetFLCache(); + while (I < Fl.HeaderP->HashSize) + { + cout << I << endl; + pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++); + if (Node->Pointer == 0) + continue; + for (; Node.end() == false; Node++) + { + cout << Node.DirN() << '/' << Node.File(); + if (Node->Flags == pkgFLCache::Node::Diversion) + cout << " (div)"; + if (Node->Flags == pkgFLCache::Node::ConfFile) + cout << " (conf)"; + cout << endl; + } + }*/ + + for (int I = 1; I < argc; I++) + { + FileFd F(argv[I],FileFd::ReadOnly); + debDebFile Deb(F); + + if (Deb.ExtractControl(Db) == false) + cerr << "Error!" << endl; + cout << argv[I] << endl; + + pkgCache::VerIterator Ver = Deb.MergeControl(Db); + if (Ver.end() == true) + cerr << "Failed" << endl; + else + cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl; + + pkgExtract Extract(Db.GetFLCache(),Ver); + Deb.ExtractArchive(Extract); + } +// #endif +//#endif _error->DumpErrors(); }