packagemanager.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  81. virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
  82. #else
  83. virtual bool Go(int /*statusFd*/=-1) {return true;};
  84. #endif
  85. virtual void Reset() {};
  86. // the result of the operation
  87. OrderResult Res;
  88. public:
  89. // Main action members
  90. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  91. pkgRecords *Recs);
  92. // Do the installation
  93. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  94. OrderResult DoInstall(APT::Progress::PackageManager *progress);
  95. // compat
  96. APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
  97. #else
  98. OrderResult DoInstall(int statusFd=-1);
  99. #endif
  100. // stuff that needs to be done before the fork() of a library that
  101. // uses apt
  102. OrderResult DoInstallPreFork() {
  103. Res = OrderInstall();
  104. return Res;
  105. };
  106. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  107. // stuff that needs to be done after the fork
  108. OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
  109. // compat
  110. APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
  111. #else
  112. OrderResult DoInstallPostFork(int statusFd=-1);
  113. #endif
  114. // ?
  115. bool FixMissing();
  116. /** \brief returns all packages dpkg let disappear */
  117. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  118. pkgPackageManager(pkgDepCache *Cache);
  119. virtual ~pkgPackageManager();
  120. private:
  121. enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
  122. APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
  123. pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
  124. bool * const Bad, bool * const Changed) APT_MUSTCHECK;
  125. };
  126. #endif