You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

121 lines
3.7 KiB

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