apt  0.9.15
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 #include <apt-pkg/init.h>
19 
20 #ifndef APT_8_CLEANER_HEADERS
21 using std::vector;
22 using std::map;
23 #endif
24 
25 class pkgDPkgPMPrivate;
26 
27 
29 {
30  private:
32 
46  void handleDisappearAction(std::string const &pkgname);
47 
48  protected:
49  int pkgFailures;
50 
51  // progress reporting
52  struct DpkgState
53  {
54  const char *state; // the dpkg state (e.g. "unpack")
55  const char *str; // the human readable translation of the state
56  };
57 
58  // the dpkg states that the pkg will run through, the string is
59  // the package, the vector contains the dpkg states that the package
60  // will go through
61  std::map<std::string,std::vector<struct DpkgState> > PackageOps;
62  // the dpkg states that are already done; the string is the package
63  // the int is the state that is already done (e.g. a package that is
64  // going to be install is already in state "half-installed")
65  std::map<std::string,unsigned int> PackageOpsDone;
66 
67  // progress reporting
68  unsigned int PackagesDone;
69  unsigned int PackagesTotal;
70 
71  struct Item
72  {
73  enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
74  std::string File;
75  PkgIterator Pkg;
76  Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
77  File(File), Pkg(Pkg) {};
78  Item() {};
79 
80  };
81  std::vector<Item> List;
82 
83  // Helpers
84  bool RunScriptsWithPkgs(const char *Cnf);
85  __deprecated bool SendV2Pkgs(FILE *F);
86  bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
87  void WriteHistoryTag(std::string const &tag, std::string value);
88  std::string ExpandShortPackageName(pkgDepCache &Cache,
89  const std::string &short_pkgname);
90 
91  // Terminal progress
92  void SendTerminalProgress(float percentage);
93 
94  // apport integration
95  void WriteApportReport(const char *pkgpath, const char *errormsg);
96 
97  // dpkg log
98  bool OpenLog();
99  bool CloseLog();
100 
101  // helper
102  void BuildPackagesProgressMap();
103  void StartPtyMagic();
104  void StopPtyMagic();
105 
106  // input processing
107  void DoStdin(int master);
108  void DoTerminalPty(int master);
109  void DoDpkgStatusFd(int statusfd);
110  void ProcessDpkgStatusLine(char *line);
111 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
112  void DoDpkgStatusFd(int statusfd, int unused) {
113  DoDpkgStatusFd(statusfd);
114  }
115  void ProcessDpkgStatusLine(int unused, char *line) {
116  ProcessDpkgStatusLine(line);
117  }
118 #endif
119 
120 
121  // The Actuall installation implementation
122  virtual bool Install(PkgIterator Pkg,std::string File);
123  virtual bool Configure(PkgIterator Pkg);
124  virtual bool Remove(PkgIterator Pkg,bool Purge = false);
125 
126 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
127  virtual bool Go(APT::Progress::PackageManager *progress);
128 #else
129  virtual bool Go(int StatusFd=-1);
130  bool GoNoABIBreak(APT::Progress::PackageManager *progress);
131 #endif
132 
133  virtual void Reset();
134 
135  public:
136 
137  pkgDPkgPM(pkgDepCache *Cache);
138  virtual ~pkgDPkgPM();
139 };
140 
141 void SigINT(int sig);
142 
143 #endif
Definition: cacheiterators.h:136
information for a single version of a package
Definition: pkgcache.h:501
Definition: dpkgpm.h:71
Definition: packagemanager.h:47
Definition: dpkgpm.cc:54
Definition: install-progress.h:15
Definition: dpkgpm.h:52
Definition: dpkgpm.h:28
Definition: depcache.h:56