packagemanager.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. class pkgPackageManager : protected pkgCache::Namespace
  39. {
  40. public:
  41. enum OrderResult {Completed,Failed,Incomplete};
  42. static bool SigINTStop;
  43. protected:
  44. std::string *FileNames;
  45. pkgDepCache &Cache;
  46. pkgOrderList *List;
  47. bool Debug;
  48. bool NoImmConfigure;
  49. bool ImmConfigureAll;
  50. /** \brief saves packages dpkg let disappear
  51. This way APT can retreat from trying to configure these
  52. packages later on and a frontend can choose to display a
  53. notice to inform the user about these disappears.
  54. */
  55. std::set<std::string> disappearedPkgs;
  56. void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
  57. virtual OrderResult OrderInstall();
  58. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
  59. bool CreateOrderList();
  60. // Analysis helpers
  61. bool DepAlwaysTrue(DepIterator D) APT_PURE;
  62. // Install helpers
  63. bool ConfigureAll();
  64. bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
  65. //FIXME: merge on abi break
  66. bool SmartUnPack(PkgIterator Pkg) APT_MUSTCHECK;
  67. bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth) APT_MUSTCHECK;
  68. bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK;
  69. bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
  70. APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK;
  71. // The Actual installation implementation
  72. virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
  73. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  74. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  75. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  76. virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
  77. #else
  78. virtual bool Go(int /*statusFd*/=-1) {return true;};
  79. #endif
  80. virtual void Reset() {};
  81. // the result of the operation
  82. OrderResult Res;
  83. public:
  84. // Main action members
  85. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  86. pkgRecords *Recs);
  87. // Do the installation
  88. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  89. OrderResult DoInstall(APT::Progress::PackageManager *progress);
  90. // compat
  91. APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
  92. #else
  93. OrderResult DoInstall(int statusFd=-1);
  94. #endif
  95. // stuff that needs to be done before the fork() of a library that
  96. // uses apt
  97. OrderResult DoInstallPreFork() {
  98. Res = OrderInstall();
  99. return Res;
  100. };
  101. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  102. // stuff that needs to be done after the fork
  103. OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
  104. // compat
  105. APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
  106. #else
  107. OrderResult DoInstallPostFork(int statusFd=-1);
  108. #endif
  109. // ?
  110. bool FixMissing();
  111. /** \brief returns all packages dpkg let disappear */
  112. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  113. pkgPackageManager(pkgDepCache *Cache);
  114. virtual ~pkgPackageManager();
  115. private:
  116. enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
  117. APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
  118. pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
  119. bool * const Bad, bool * const Changed) APT_MUSTCHECK;
  120. };
  121. #endif