dpkgpm.h 3.4 KB

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