packagemanager.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: packagemanager.h,v 1.14 2001/05/07 04:24:08 jgg Exp $
  4. /* ######################################################################
  5. Package Manager - Abstacts the package manager
  6. Three steps are
  7. - Aquiration of archives (stores the list of final file names)
  8. - Sorting of operations
  9. - Invokation of package manager
  10. This is the final stage when the package cache entities get converted
  11. into file names and the state stored in a DepCache is transformed
  12. into a series of operations.
  13. In the final scheme of things this may serve as a director class to
  14. access the actual install methods based on the file type being
  15. installed.
  16. ##################################################################### */
  17. /*}}}*/
  18. #ifndef PKGLIB_PACKAGEMANAGER_H
  19. #define PKGLIB_PACKAGEMANAGER_H
  20. #include <apt-pkg/pkgcache.h>
  21. #include <apt-pkg/init.h>
  22. #include <apt-pkg/macros.h>
  23. #include <string>
  24. #include <set>
  25. #ifndef APT_10_CLEANER_HEADERS
  26. #include <apt-pkg/install-progress.h>
  27. #include <iostream>
  28. #endif
  29. #ifndef APT_8_CLEANER_HEADERS
  30. #include <apt-pkg/depcache.h>
  31. using std::string;
  32. #endif
  33. class pkgAcquire;
  34. class pkgDepCache;
  35. class pkgSourceList;
  36. class pkgOrderList;
  37. class pkgRecords;
  38. namespace APT {
  39. namespace Progress {
  40. class PackageManager;
  41. }
  42. }
  43. class pkgPackageManager : protected pkgCache::Namespace
  44. {
  45. public:
  46. enum OrderResult {Completed,Failed,Incomplete};
  47. static bool SigINTStop;
  48. protected:
  49. std::string *FileNames;
  50. pkgDepCache &Cache;
  51. pkgOrderList *List;
  52. bool Debug;
  53. bool NoImmConfigure;
  54. bool ImmConfigureAll;
  55. /** \brief saves packages dpkg let disappear
  56. This way APT can retreat from trying to configure these
  57. packages later on and a frontend can choose to display a
  58. notice to inform the user about these disappears.
  59. */
  60. std::set<std::string> disappearedPkgs;
  61. void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
  62. virtual OrderResult OrderInstall();
  63. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *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. #if APT_PKG_ABI >= 413
  81. virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
  82. #endif
  83. virtual bool Go(int /*statusFd*/=-1) {return true;};
  84. virtual void Reset() {};
  85. // the result of the operation
  86. OrderResult Res;
  87. public:
  88. // Main action members
  89. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  90. pkgRecords *Recs);
  91. // Do the installation
  92. #if APT_PKG_ABI >= 413
  93. OrderResult DoInstall(APT::Progress::PackageManager *progress);
  94. // compat
  95. APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
  96. #else
  97. OrderResult DoInstall(int statusFd=-1);
  98. #endif
  99. // stuff that needs to be done before the fork() of a library that
  100. // uses apt
  101. OrderResult DoInstallPreFork() {
  102. Res = OrderInstall();
  103. return Res;
  104. };
  105. #if APT_PKG_ABI >= 413
  106. // stuff that needs to be done after the fork
  107. OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
  108. // compat
  109. APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
  110. #else
  111. OrderResult DoInstallPostFork(int statusFd=-1);
  112. #endif
  113. // ?
  114. bool FixMissing();
  115. /** \brief returns all packages dpkg let disappear */
  116. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  117. pkgPackageManager(pkgDepCache *Cache);
  118. virtual ~pkgPackageManager();
  119. private:
  120. enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
  121. APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
  122. pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
  123. bool * const Bad, bool * const Changed) APT_MUSTCHECK;
  124. };
  125. #endif