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.
 
 
 
 
 
 

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