packagemanager.h 3.8 KB

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