dpkgpm.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 pkgDPkgPM : public pkgPackageManager
  17. {
  18. private:
  19. bool stdin_is_dev_null;
  20. // the buffer we use for the dpkg status-fd reading
  21. char dpkgbuf[1024];
  22. int dpkgbuf_pos;
  23. FILE *term_out;
  24. protected:
  25. int pkgFailures;
  26. // progress reporting
  27. struct DpkgState
  28. {
  29. const char *state; // the dpkg state (e.g. "unpack")
  30. const char *str; // the human readable translation of the state
  31. };
  32. // the dpkg states that the pkg will run through, the string is
  33. // the package, the vector contains the dpkg states that the package
  34. // will go through
  35. map<string,vector<struct DpkgState> > PackageOps;
  36. // the dpkg states that are already done; the string is the package
  37. // the int is the state that is already done (e.g. a package that is
  38. // going to be install is already in state "half-installed")
  39. map<string,unsigned int> PackageOpsDone;
  40. #if 1 // FIXME: BINARY COMPATIBILITY ONLY, remove on next ABI break
  41. map<string,string> PackageProcessingOps;
  42. #endif
  43. // progress reporting
  44. unsigned int PackagesDone;
  45. unsigned int PackagesTotal;
  46. struct Item
  47. {
  48. enum Ops {Install, Configure, Remove, Purge} Op;
  49. string File;
  50. PkgIterator Pkg;
  51. Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op),
  52. File(File), Pkg(Pkg) {};
  53. Item() {};
  54. };
  55. vector<Item> List;
  56. // Helpers
  57. bool RunScriptsWithPkgs(const char *Cnf);
  58. bool SendV2Pkgs(FILE *F);
  59. // apport integration
  60. void WriteApportReport(const char *pkgpath, const char *errormsg);
  61. // dpkg log
  62. bool OpenLog();
  63. bool CloseLog();
  64. // input processing
  65. void DoStdin(int master);
  66. void DoTerminalPty(int master);
  67. void DoDpkgStatusFd(int statusfd, int OutStatusFd);
  68. void ProcessDpkgStatusLine(int OutStatusFd, char *line);
  69. // The Actuall installation implementation
  70. virtual bool Install(PkgIterator Pkg,string File);
  71. virtual bool Configure(PkgIterator Pkg);
  72. virtual bool Remove(PkgIterator Pkg,bool Purge = false);
  73. virtual bool Go(int StatusFd=-1);
  74. virtual void Reset();
  75. public:
  76. pkgDPkgPM(pkgDepCache *Cache);
  77. virtual ~pkgDPkgPM();
  78. };
  79. #endif