dpkgpm.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: dpkgpm.h,v 1.8 2001/05/07 05:05:13 jgg Exp $
  4. /* ######################################################################
  5. DPKG Package Manager - Provide an interface to dpkg
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef PKGLIB_DPKGPM_H
  9. #define PKGLIB_DPKGPM_H
  10. #include <apt-pkg/packagemanager.h>
  11. #include <vector>
  12. #include <map>
  13. #include <stdio.h>
  14. using std::vector;
  15. using std::map;
  16. class pkgDPkgPMPrivate;
  17. class pkgDPkgPM : public pkgPackageManager
  18. {
  19. private:
  20. pkgDPkgPMPrivate *d;
  21. /** \brief record the disappear action and handle accordingly
  22. dpkg let packages disappear then they have no files any longer and
  23. nothing depends on them. We need to collect this as dpkg as well as
  24. APT doesn't know beforehand that the package will disappear, so the
  25. only possible option is to tell the user afterwards about it.
  26. To enhance the experience we also try to forward the auto-install
  27. flag so the disappear-causer(s) are not autoremoved next time -
  28. for the transfer to happen the disappeared version needs to depend
  29. on the package the flag should be forwarded to and this package
  30. needs to declare a Replaces on the disappeared package.
  31. \param pkgname Name of the package that disappeared
  32. */
  33. void handleDisappearAction(string const &pkgname);
  34. protected:
  35. int pkgFailures;
  36. // progress reporting
  37. struct DpkgState
  38. {
  39. const char *state; // the dpkg state (e.g. "unpack")
  40. const char *str; // the human readable translation of the state
  41. };
  42. // the dpkg states that the pkg will run through, the string is
  43. // the package, the vector contains the dpkg states that the package
  44. // will go through
  45. map<string,vector<struct DpkgState> > PackageOps;
  46. // the dpkg states that are already done; the string is the package
  47. // the int is the state that is already done (e.g. a package that is
  48. // going to be install is already in state "half-installed")
  49. map<string,unsigned int> PackageOpsDone;
  50. // progress reporting
  51. unsigned int PackagesDone;
  52. unsigned int PackagesTotal;
  53. struct Item
  54. {
  55. enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
  56. string File;
  57. PkgIterator Pkg;
  58. Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op),
  59. File(File), Pkg(Pkg) {};
  60. Item() {};
  61. };
  62. vector<Item> List;
  63. // Helpers
  64. bool RunScriptsWithPkgs(const char *Cnf);
  65. bool SendV2Pkgs(FILE *F);
  66. void WriteHistoryTag(string const &tag, string value);
  67. // apport integration
  68. void WriteApportReport(const char *pkgpath, const char *errormsg);
  69. // dpkg log
  70. bool OpenLog();
  71. bool CloseLog();
  72. // input processing
  73. void DoStdin(int master);
  74. void DoTerminalPty(int master);
  75. void DoDpkgStatusFd(int statusfd, int OutStatusFd);
  76. void ProcessDpkgStatusLine(int OutStatusFd, char *line);
  77. // The Actuall installation implementation
  78. virtual bool Install(PkgIterator Pkg,string File);
  79. virtual bool Configure(PkgIterator Pkg);
  80. virtual bool Remove(PkgIterator Pkg,bool Purge = false);
  81. virtual bool Go(int StatusFd=-1);
  82. virtual void Reset();
  83. public:
  84. pkgDPkgPM(pkgDepCache *Cache);
  85. virtual ~pkgDPkgPM();
  86. };
  87. #endif