You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

121 lines
3.4 KiB

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