apt  0.9.12.1
dpkgpm.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: dpkgpm.h,v 1.8 2001/05/07 05:05:13 jgg Exp $
4 /* ######################################################################
5 
6  DPKG Package Manager - Provide an interface to dpkg
7 
8  ##################################################################### */
9  /*}}}*/
10 #ifndef PKGLIB_DPKGPM_H
11 #define PKGLIB_DPKGPM_H
12 
13 #include <apt-pkg/packagemanager.h>
14 #include <vector>
15 #include <map>
16 #include <stdio.h>
17 #include <apt-pkg/macros.h>
18 
19 #ifndef APT_8_CLEANER_HEADERS
20 using std::vector;
21 using std::map;
22 #endif
23 
24 class pkgDPkgPMPrivate;
25 
27 {
28  private:
30 
44  void handleDisappearAction(std::string const &pkgname);
45 
46  protected:
47  int pkgFailures;
48 
49  // progress reporting
50  struct DpkgState
51  {
52  const char *state; // the dpkg state (e.g. "unpack")
53  const char *str; // the human readable translation of the state
54  };
55 
56  // the dpkg states that the pkg will run through, the string is
57  // the package, the vector contains the dpkg states that the package
58  // will go through
59  std::map<std::string,std::vector<struct DpkgState> > PackageOps;
60  // the dpkg states that are already done; the string is the package
61  // the int is the state that is already done (e.g. a package that is
62  // going to be install is already in state "half-installed")
63  std::map<std::string,unsigned int> PackageOpsDone;
64 
65  // progress reporting
66  unsigned int PackagesDone;
67  unsigned int PackagesTotal;
68 
69  struct Item
70  {
71  enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
72  std::string File;
73  PkgIterator Pkg;
74  Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
75  File(File), Pkg(Pkg) {};
76  Item() {};
77 
78  };
79  std::vector<Item> List;
80 
81  // Helpers
82  bool RunScriptsWithPkgs(const char *Cnf);
83  __deprecated bool SendV2Pkgs(FILE *F);
84  bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
85  void WriteHistoryTag(std::string const &tag, std::string value);
86 
87  // Terminal progress
88  void SetupTerminalScrollArea(int nr_scrolled_rows);
89  void SendTerminalProgress(float percentage);
90 
91  // apport integration
92  void WriteApportReport(const char *pkgpath, const char *errormsg);
93 
94  // dpkg log
95  bool OpenLog();
96  bool CloseLog();
97 
98  // input processing
99  void DoStdin(int master);
100  void DoTerminalPty(int master);
101  void DoDpkgStatusFd(int statusfd, int OutStatusFd);
102  void ProcessDpkgStatusLine(int OutStatusFd, char *line);
103 
104  // The Actuall installation implementation
105  virtual bool Install(PkgIterator Pkg,std::string File);
106  virtual bool Configure(PkgIterator Pkg);
107  virtual bool Remove(PkgIterator Pkg,bool Purge = false);
108  virtual bool Go(int StatusFd=-1);
109  virtual void Reset();
110 
111  public:
112 
113  pkgDPkgPM(pkgDepCache *Cache);
114  virtual ~pkgDPkgPM();
115 };
116 
117 void SigINT(int sig);
118 
119 #endif