scratch.cc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/fileutl.h>
  9. int main(int argc,char *argv[])
  10. {
  11. pkgInitialize(*_config);
  12. cout << flNoLink(argv[1]) << endl;
  13. #if 0
  14. /* DynamicMMap *FileMap = new DynamicMMap(MMap::Public);
  15. pkgFLCache *FList = new pkgFLCache(*FileMap);
  16. char *Name = "/tmp/test";
  17. pkgFLCache::PkgIterator Pkg(*FList,0);
  18. pkgFLCache::NodeIterator Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
  19. cout << (pkgFLCache::Node *)Node << endl;
  20. Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
  21. cout << (pkgFLCache::Node *)Node << endl;
  22. */
  23. // #if 0
  24. _config->Set("Dir::State::status","/tmp/testing/status");
  25. debDpkgDB Db;
  26. {
  27. OpTextProgress Prog;
  28. if (Db.ReadyPkgCache(Prog) == false)
  29. cerr << "Error!" << endl;
  30. Prog.Done();
  31. if (Db.ReadyFileList(Prog) == false)
  32. cerr << "Error!" << endl;
  33. }
  34. if (_error->PendingError() == true)
  35. {
  36. _error->DumpErrors();
  37. return 0;
  38. }
  39. /* Db.GetFLCache().BeginDiverLoad();
  40. pkgFLCache::PkgIterator Pkg(Db.GetFLCache(),0);
  41. if (Db.GetFLCache().AddDiversion(Pkg,"/usr/include/linux/kerneld.h","/usr/bin/nslookup") == false)
  42. cerr << "Error!" << endl;
  43. const char *Tmp = "/usr/include/linux/kerneld.h";
  44. pkgFLCache::NodeIterator Nde = Db.GetFLCache().GetNode(Tmp,Tmp+strlen(Tmp),0,false,false);
  45. map_ptrloc Loc = Nde->File;
  46. for (; Nde.end() == false && Nde->File == Loc; Nde++)
  47. cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl;
  48. Db.GetFLCache().FinishDiverLoad();*/
  49. /* unsigned int I = 0;
  50. pkgFLCache &Fl = Db.GetFLCache();
  51. while (I < Fl.HeaderP->HashSize)
  52. {
  53. cout << I << endl;
  54. pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++);
  55. if (Node->Pointer == 0)
  56. continue;
  57. for (; Node.end() == false; Node++)
  58. {
  59. cout << Node.DirN() << '/' << Node.File();
  60. if (Node->Flags == pkgFLCache::Node::Diversion)
  61. cout << " (div)";
  62. if (Node->Flags == pkgFLCache::Node::ConfFile)
  63. cout << " (conf)";
  64. cout << endl;
  65. }
  66. }*/
  67. for (int I = 1; I < argc; I++)
  68. {
  69. FileFd F(argv[I],FileFd::ReadOnly);
  70. debDebFile Deb(F);
  71. if (Deb.ExtractControl(Db) == false)
  72. cerr << "Error!" << endl;
  73. cout << argv[I] << endl;
  74. pkgCache::VerIterator Ver = Deb.MergeControl(Db);
  75. if (Ver.end() == true)
  76. cerr << "Failed" << endl;
  77. else
  78. cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl;
  79. pkgExtract Extract(Db.GetFLCache(),Ver);
  80. Deb.ExtractArchive(Extract);
  81. }
  82. // #endif
  83. #endif
  84. _error->DumpErrors();
  85. }