dpkgpm.h 3.4 KB

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