packagemanager.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
  41. virtual OrderResult OrderInstall();
  42. bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
  43. bool CreateOrderList();
  44. // Analysis helpers
  45. bool DepAlwaysTrue(DepIterator D);
  46. // Install helpers
  47. bool ConfigureAll();
  48. bool SmartConfigure(PkgIterator Pkg);
  49. bool SmartUnPack(PkgIterator Pkg);
  50. bool SmartRemove(PkgIterator Pkg);
  51. bool EarlyRemove(PkgIterator Pkg);
  52. // The Actual installation implementation
  53. virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
  54. virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
  55. virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
  56. virtual bool Go(int statusFd=-1) {return true;};
  57. virtual void Reset() {};
  58. // the result of the operation
  59. OrderResult Res;
  60. public:
  61. // Main action members
  62. bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  63. pkgRecords *Recs);
  64. // Do the installation
  65. OrderResult DoInstall(int statusFd=-1);
  66. // stuff that needs to be done before the fork() of a library that
  67. // uses apt
  68. OrderResult DoInstallPreFork() {
  69. Res = OrderInstall();
  70. return Res;
  71. };
  72. // stuff that needs to be done after the fork
  73. OrderResult DoInstallPostFork(int statusFd=-1);
  74. bool FixMissing();
  75. pkgPackageManager(pkgDepCache *Cache);
  76. virtual ~pkgPackageManager();
  77. };
  78. #endif