packagemanager.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #ifdef __GNUG__
  21. #pragma interface "apt-pkg/packagemanager.h"
  22. #endif
  23. #include <string>
  24. #include <apt-pkg/pkgcache.h>
  25. #include <apt-pkg/depcache.h>
  26. using std::string;
  27. class pkgAcquire;
  28. class pkgDepCache;
  29. class pkgSourceList;
  30. class pkgOrderList;
  31. class pkgRecords;
  32. class pkgPackageManager : protected pkgCache::Namespace
  33. {
  34. public:
  35. enum OrderResult {Completed,Failed,Incomplete};
  36. protected:
  37. string *FileNames;
  38. pkgDepCache &Cache;
  39. pkgOrderList *List;
  40. bool Debug;
  41. bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
  42. virtual OrderResult OrderInstall();
  43. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
  44. bool CreateOrderList();
  45. // Analysis helpers
  46. bool DepAlwaysTrue(DepIterator D);
  47. // Install helpers
  48. bool ConfigureAll();
  49. bool SmartConfigure(PkgIterator Pkg);
  50. bool SmartUnPack(PkgIterator Pkg);
  51. bool SmartRemove(PkgIterator Pkg);
  52. bool EarlyRemove(PkgIterator Pkg);
  53. // The Actual installation implementation
  54. virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
  55. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  56. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  57. virtual bool Go(int statusFd=-1) {return true;};
  58. virtual void Reset() {};
  59. // the result of the operation
  60. OrderResult Res;
  61. public:
  62. // Main action members
  63. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  64. pkgRecords *Recs);
  65. // Do the installation
  66. OrderResult DoInstall() {
  67. if(DoInstallPreFork() == Failed)
  68. return Failed;
  69. return DoInstallPostFork();
  70. }
  71. // stuff that needs to be done before the fork() of a library that
  72. // uses apt
  73. OrderResult DoInstallPreFork() {
  74. Res = OrderInstall();
  75. return Res;
  76. };
  77. // stuff that needs to be done after the fork
  78. OrderResult DoInstallPostFork(int statusFd=-1) {
  79. bool goResult = Go(statusFd);
  80. if(goResult == false)
  81. return Failed;
  82. // if all was fine update the state file
  83. if(Res == Completed)
  84. Cache.writeStateFile(NULL);
  85. return Res;
  86. };
  87. bool FixMissing();
  88. pkgPackageManager(pkgDepCache *Cache);
  89. virtual ~pkgPackageManager();
  90. };
  91. #endif