packagemanager.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. bool SmartUnPack(PkgIterator Pkg);
  57. bool SmartRemove(PkgIterator Pkg);
  58. bool EarlyRemove(PkgIterator Pkg);
  59. // The Actual installation implementation
  60. virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
  61. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  62. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  63. virtual bool Go(int statusFd=-1) {return true;};
  64. virtual void Reset() {};
  65. // the result of the operation
  66. OrderResult Res;
  67. public:
  68. // Main action members
  69. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  70. pkgRecords *Recs);
  71. // Do the installation
  72. OrderResult DoInstall(int statusFd=-1);
  73. // stuff that needs to be done before the fork() of a library that
  74. // uses apt
  75. OrderResult DoInstallPreFork() {
  76. Res = OrderInstall();
  77. return Res;
  78. };
  79. // stuff that needs to be done after the fork
  80. OrderResult DoInstallPostFork(int statusFd=-1);
  81. bool FixMissing();
  82. /** \brief returns all packages dpkg let disappear */
  83. inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
  84. pkgPackageManager(pkgDepCache *Cache);
  85. virtual ~pkgPackageManager();
  86. };
  87. #endif