private-cachefile.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef APT_PRIVATE_CACHEFILE_H
  2. #define APT_PRIVATE_CACHEFILE_H
  3. #include <apt-pkg/cachefile.h>
  4. #include <apt-pkg/progress.h>
  5. #include <apt-pkg/configuration.h>
  6. #include <apt-pkg/pkgcache.h>
  7. #include <apt-pkg/macros.h>
  8. #include <apt-pkg/sourcelist.h>
  9. #include <apti18n.h>
  10. // FIXME: we need to find a way to export this
  11. class APT_PUBLIC SourceList : public pkgSourceList
  12. {
  13. public:
  14. // Add custom metaIndex (e.g. local files)
  15. void AddMetaIndex(metaIndex *mi) {
  16. SrcList.push_back(mi);
  17. }
  18. };
  19. // class CacheFile - Cover class for some dependency cache functions /*{{{*/
  20. // ---------------------------------------------------------------------
  21. /* */
  22. class APT_PUBLIC CacheFile : public pkgCacheFile
  23. {
  24. static pkgCache *SortCache;
  25. APT_HIDDEN static int NameComp(const void *a,const void *b) APT_PURE;
  26. public:
  27. pkgCache::Package **List;
  28. void Sort();
  29. bool CheckDeps(bool AllowBroken = false);
  30. bool BuildCaches(bool WithLock = true)
  31. {
  32. OpTextProgress Prog(*_config);
  33. if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false)
  34. return false;
  35. return true;
  36. }
  37. // FIXME: this can go once the "libapt-pkg" pkgSourceList has a way
  38. // to add custom metaIndexes (or custom local files or so)
  39. bool BuildSourceList(OpProgress */*Progress*/ = NULL) {
  40. if (SrcList != NULL)
  41. return true;
  42. SrcList = new SourceList();
  43. if (SrcList->ReadMainList() == false)
  44. return _error->Error(_("The list of sources could not be read."));
  45. return true;
  46. }
  47. bool Open(bool WithLock = true)
  48. {
  49. OpTextProgress Prog(*_config);
  50. if (pkgCacheFile::Open(&Prog,WithLock) == false)
  51. return false;
  52. Sort();
  53. return true;
  54. };
  55. bool OpenForInstall()
  56. {
  57. if (_config->FindB("APT::Get::Print-URIs") == true)
  58. return Open(false);
  59. else
  60. return Open(true);
  61. }
  62. CacheFile() : List(0) {};
  63. ~CacheFile() {
  64. delete[] List;
  65. }
  66. };
  67. /*}}}*/
  68. #endif