packagemanager.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. using std::string;
  25. class pkgAcquire;
  26. class pkgDepCache;
  27. class pkgSourceList;
  28. class pkgOrderList;
  29. class pkgRecords;
  30. class pkgPackageManager : protected pkgCache::Namespace
  31. {
  32. public:
  33. enum OrderResult {Completed,Failed,Incomplete};
  34. protected:
  35. string *FileNames;
  36. pkgDepCache &Cache;
  37. pkgOrderList *List;
  38. bool Debug;
  39. bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
  40. // binary-compat change, fix on next abi break
  41. void ImmediateAdd(PkgIterator P, bool UseInstallVer) {
  42. ImmediateAdd(P, UseInstallVer, 0);
  43. }
  44. void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth);
  45. virtual OrderResult OrderInstall();
  46. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
  47. bool CreateOrderList();
  48. // Analysis helpers
  49. bool DepAlwaysTrue(DepIterator D);
  50. // Install helpers
  51. bool ConfigureAll();
  52. bool SmartConfigure(PkgIterator Pkg);
  53. bool SmartUnPack(PkgIterator Pkg);
  54. bool SmartRemove(PkgIterator Pkg);
  55. bool EarlyRemove(PkgIterator Pkg);
  56. // The Actual installation implementation
  57. virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
  58. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  59. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  60. virtual bool Go(int statusFd=-1) {return true;};
  61. virtual void Reset() {};
  62. // the result of the operation
  63. OrderResult Res;
  64. public:
  65. // Main action members
  66. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  67. pkgRecords *Recs);
  68. // Do the installation
  69. OrderResult DoInstall(int statusFd=-1);
  70. // stuff that needs to be done before the fork() of a library that
  71. // uses apt
  72. OrderResult DoInstallPreFork() {
  73. Res = OrderInstall();
  74. return Res;
  75. };
  76. // stuff that needs to be done after the fork
  77. OrderResult DoInstallPostFork(int statusFd=-1);
  78. bool FixMissing();
  79. pkgPackageManager(pkgDepCache *Cache);
  80. virtual ~pkgPackageManager();
  81. };
  82. #endif