packagemanager.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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) APT_MUSTCHECK;
  70. // The Actual installation implementation
  71. virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
  72. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  73. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  74. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  75. virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
  76. #else
  77. virtual bool Go(int /*statusFd*/=-1) {return true;};
  78. #endif
  79. virtual void Reset() {};
  80. // the result of the operation
  81. OrderResult Res;
  82. public:
  83. // Main action members
  84. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  85. pkgRecords *Recs);
  86. // Do the installation
  87. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  88. OrderResult DoInstall(APT::Progress::PackageManager *progress);
  89. // compat
  90. APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
  91. #else
  92. OrderResult DoInstall(int statusFd=-1);
  93. #endif
  94. // stuff that needs to be done before the fork() of a library that
  95. // uses apt
  96. OrderResult DoInstallPreFork() {
  97. Res = OrderInstall();
  98. return Res;
  99. };
  100. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  101. // stuff that needs to be done after the fork
  102. OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
  103. // compat
  104. APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
  105. #else
  106. OrderResult DoInstallPostFork(int statusFd=-1);
  107. #endif
  108. // ?
  109. bool FixMissing();
  110. /** \brief returns all packages dpkg let disappear */
  111. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  112. pkgPackageManager(pkgDepCache *Cache);
  113. virtual ~pkgPackageManager();
  114. };
  115. #endif