You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

147 lines
4.4 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Package Manager - Abstacts the package manager
  5. Three steps are
  6. - Aquiration of archives (stores the list of final file names)
  7. - Sorting of operations
  8. - Invokation of package manager
  9. This is the final stage when the package cache entities get converted
  10. into file names and the state stored in a DepCache is transformed
  11. into a series of operations.
  12. In the final scheme of things this may serve as a director class to
  13. access the actual install methods based on the file type being
  14. installed.
  15. ##################################################################### */
  16. /*}}}*/
  17. #ifndef PKGLIB_PACKAGEMANAGER_H
  18. #define PKGLIB_PACKAGEMANAGER_H
  19. #include <apt-pkg/pkgcache.h>
  20. #include <apt-pkg/init.h>
  21. #include <apt-pkg/macros.h>
  22. #include <string>
  23. #include <set>
  24. #ifndef APT_10_CLEANER_HEADERS
  25. #include <apt-pkg/install-progress.h>
  26. #include <iostream>
  27. #endif
  28. #ifndef APT_8_CLEANER_HEADERS
  29. #include <apt-pkg/depcache.h>
  30. using std::string;
  31. #endif
  32. class pkgAcquire;
  33. class pkgDepCache;
  34. class pkgSourceList;
  35. class pkgOrderList;
  36. class pkgRecords;
  37. namespace APT {
  38. namespace Progress {
  39. class PackageManager;
  40. }
  41. }
  42. class pkgPackageManager : protected pkgCache::Namespace
  43. {
  44. public:
  45. enum OrderResult {Completed,Failed,Incomplete};
  46. static bool SigINTStop;
  47. protected:
  48. std::string *FileNames;
  49. pkgDepCache &Cache;
  50. pkgOrderList *List;
  51. bool Debug;
  52. bool NoImmConfigure;
  53. bool ImmConfigureAll;
  54. /** \brief saves packages dpkg let disappear
  55. This way APT can retreat from trying to configure these
  56. packages later on and a front-end can choose to display a
  57. notice to inform the user about these disappears.
  58. */
  59. std::set<std::string> disappearedPkgs;
  60. void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
  61. virtual OrderResult OrderInstall();
  62. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
  63. bool CheckRBreaks(PkgIterator const &Pkg,DepIterator Dep,const char * const Ver);
  64. bool CreateOrderList();
  65. // Analysis helpers
  66. bool DepAlwaysTrue(DepIterator D) APT_PURE;
  67. // Install helpers
  68. bool ConfigureAll();
  69. bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
  70. //FIXME: merge on abi break
  71. bool SmartUnPack(PkgIterator Pkg) APT_MUSTCHECK;
  72. bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth) APT_MUSTCHECK;
  73. bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK;
  74. bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
  75. APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK;
  76. // The Actual installation implementation
  77. virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
  78. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  79. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  80. virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
  81. virtual bool Go(int /*statusFd*/=-1) {return true;};
  82. virtual void Reset() {};
  83. // the result of the operation
  84. OrderResult Res;
  85. public:
  86. // Main action members
  87. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  88. pkgRecords *Recs);
  89. // Do the installation
  90. OrderResult DoInstall(APT::Progress::PackageManager *progress);
  91. // compat
  92. APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
  93. // stuff that needs to be done before the fork() of a library that
  94. // uses apt
  95. OrderResult DoInstallPreFork() {
  96. Res = OrderInstall();
  97. return Res;
  98. };
  99. // stuff that needs to be done after the fork
  100. OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
  101. // compat
  102. APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
  103. // ?
  104. bool FixMissing();
  105. /** \brief returns all packages dpkg let disappear */
  106. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  107. explicit pkgPackageManager(pkgDepCache *Cache);
  108. virtual ~pkgPackageManager();
  109. private:
  110. void * const d;
  111. enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
  112. APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
  113. pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
  114. bool * const Bad, bool * const Changed) APT_MUSTCHECK;
  115. };
  116. #endif