packagemanager.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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/macros.h>
  21. #include <apt-pkg/pkgcache.h>
  22. #include <apt-pkg/install-progress.h>
  23. #include <string>
  24. #include <iostream>
  25. #include <set>
  26. #ifndef APT_8_CLEANER_HEADERS
  27. #include <apt-pkg/depcache.h>
  28. using std::string;
  29. #endif
  30. class pkgAcquire;
  31. class pkgDepCache;
  32. class pkgSourceList;
  33. class pkgOrderList;
  34. class pkgRecords;
  35. class pkgPackageManager : protected pkgCache::Namespace
  36. {
  37. public:
  38. enum OrderResult {Completed,Failed,Incomplete};
  39. static bool SigINTStop;
  40. protected:
  41. std::string *FileNames;
  42. pkgDepCache &Cache;
  43. pkgOrderList *List;
  44. bool Debug;
  45. bool NoImmConfigure;
  46. bool ImmConfigureAll;
  47. /** \brief saves packages dpkg let disappear
  48. This way APT can retreat from trying to configure these
  49. packages later on and a frontend can choose to display a
  50. notice to inform the user about these disappears.
  51. */
  52. std::set<std::string> disappearedPkgs;
  53. void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
  54. virtual OrderResult OrderInstall();
  55. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
  56. bool CreateOrderList();
  57. // Analysis helpers
  58. bool DepAlwaysTrue(DepIterator D);
  59. // Install helpers
  60. bool ConfigureAll();
  61. bool SmartConfigure(PkgIterator Pkg, int const Depth);
  62. //FIXME: merge on abi break
  63. bool SmartUnPack(PkgIterator Pkg);
  64. bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth);
  65. bool SmartRemove(PkgIterator Pkg);
  66. bool EarlyRemove(PkgIterator Pkg);
  67. // The Actual installation implementation
  68. virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
  69. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  70. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  71. virtual bool Go(APT::Progress::PackageManager *progress) {return true;};
  72. virtual void Reset() {};
  73. // the result of the operation
  74. OrderResult Res;
  75. public:
  76. // Main action members
  77. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  78. pkgRecords *Recs);
  79. // Do the installation
  80. OrderResult DoInstall(APT::Progress::PackageManager *progress);
  81. // compat
  82. __deprecated OrderResult DoInstall(int statusFd=-1);
  83. // stuff that needs to be done before the fork() of a library that
  84. // uses apt
  85. OrderResult DoInstallPreFork() {
  86. Res = OrderInstall();
  87. return Res;
  88. };
  89. // stuff that needs to be done after the fork
  90. OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
  91. // compat
  92. __deprecated OrderResult DoInstallPostFork(int statusFd=-1);
  93. // ?
  94. bool FixMissing();
  95. /** \brief returns all packages dpkg let disappear */
  96. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  97. pkgPackageManager(pkgDepCache *Cache);
  98. virtual ~pkgPackageManager();
  99. };
  100. #endif