apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dpkgpm.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  DPKG Package Manager - Provide an interface to dpkg
6 
7  ##################################################################### */
8  /*}}}*/
9 #ifndef PKGLIB_DPKGPM_H
10 #define PKGLIB_DPKGPM_H
11 
12 #include <apt-pkg/macros.h>
13 #include <apt-pkg/packagemanager.h>
14 #include <apt-pkg/pkgcache.h>
15 
16 #include <map>
17 #include <string>
18 #include <vector>
19 #include <stdio.h>
20 
21 
22 class pkgDepCache;
23 namespace APT { namespace Progress { class PackageManager; } }
24 
25 
26 class pkgDPkgPMPrivate;
27 
28 
30 {
31  private:
33 
34  /** \brief record the disappear action and handle accordingly
35 
36  dpkg let packages disappear then they have no files any longer and
37  nothing depends on them. We need to collect this as dpkg as well as
38  APT doesn't know beforehand that the package will disappear, so the
39  only possible option is to tell the user afterwards about it.
40  To enhance the experience we also try to forward the auto-install
41  flag so the disappear-causer(s) are not autoremoved next time -
42  for the transfer to happen the disappeared version needs to depend
43  on the package the flag should be forwarded to and this package
44  needs to declare a Replaces on the disappeared package.
45  \param pkgname Name of the package that disappeared
46  */
47  APT_HIDDEN void handleDisappearAction(std::string const &pkgname);
48  APT_HIDDEN void handleCrossUpgradeAction(std::string const &pkgname);
49 
50  protected:
52 
53  // progress reporting
54  struct DpkgState
55  {
56  const char *state; // the dpkg state (e.g. "unpack")
57  const char *str; // the human readable translation of the state
58  };
59 
60  // the dpkg states that the pkg will run through, the string is
61  // the package, the vector contains the dpkg states that the package
62  // will go through
63  std::map<std::string,std::vector<struct DpkgState> > PackageOps;
64  // the dpkg states that are already done; the string is the package
65  // the int is the state that is already done (e.g. a package that is
66  // going to be install is already in state "half-installed")
67  std::map<std::string,unsigned int> PackageOpsDone;
68 
69  // progress reporting
70  unsigned int PackagesDone;
71  unsigned int PackagesTotal;
72 
73  public:
74  struct Item
75  {
76  enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending,
77  RemovePending, PurgePending } Op;
78  std::string File;
80  Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
81  File(File), Pkg(Pkg) {};
82  Item() {};
83  };
84  protected:
85  std::vector<Item> List;
86 
87  // Helpers
88  bool RunScriptsWithPkgs(const char *Cnf);
89  bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
90  void WriteHistoryTag(std::string const &tag, std::string value);
91  std::string ExpandShortPackageName(pkgDepCache &Cache,
92  const std::string &short_pkgname);
93 
94  // Terminal progress
95  void SendTerminalProgress(float percentage);
96 
97  // apport integration
98  void WriteApportReport(const char *pkgpath, const char *errormsg);
99 
100  // dpkg log
101  bool OpenLog();
102  bool CloseLog();
103 
104  // helper
105  void BuildPackagesProgressMap();
106  void StartPtyMagic();
107  void SetupSlavePtyMagic();
108  void StopPtyMagic();
109 
110  // input processing
111  void DoStdin(int master);
112  void DoTerminalPty(int master);
113  void DoDpkgStatusFd(int statusfd);
114  void ProcessDpkgStatusLine(char *line);
115 
116  // The Actual installation implementation
117  virtual bool Install(PkgIterator Pkg,std::string File) APT_OVERRIDE;
118  virtual bool Configure(PkgIterator Pkg) APT_OVERRIDE;
119  virtual bool Remove(PkgIterator Pkg,bool Purge = false) APT_OVERRIDE;
120 
121  virtual bool Go(APT::Progress::PackageManager *progress) APT_OVERRIDE;
122 
123  virtual void Reset() APT_OVERRIDE;
124 
125  public:
126 
127  explicit pkgDPkgPM(pkgDepCache *Cache);
128  virtual ~pkgDPkgPM();
129 
130  APT_HIDDEN static bool ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache);
131 };
132 
133 void SigINT(int sig);
134 
135 #endif
static bool Go(CommandLine &CmdL)
pkgCache::PkgIterator PkgIterator
Definition: pkgcache.h:829
std::vector< Item > List
Definition: dpkgpm.h:85
unsigned int PackagesDone
Definition: dpkgpm.h:70
std::map< std::string, unsigned int > PackageOpsDone
Definition: dpkgpm.h:67
void SendTerminalProgress(float percentage)
int pkgFailures
Definition: dpkgpm.h:51
std::map< std::string, std::vector< struct DpkgState > > PackageOps
Definition: dpkgpm.h:63
unsigned int PackagesTotal
Definition: dpkgpm.h:71
std::string ExpandShortPackageName(pkgDepCache &Cache, const std::string &short_pkgname)
pkgDPkgPMPrivate *const d
Definition: dpkgpm.h:32
virtual bool Configure(PkgIterator)
virtual bool Remove(PkgIterator, bool=false)
virtual bool Install(PkgIterator, std::string)
FILE
void SigINT(int sig)
Definition: dpkgpm.cc:2227
#define APT_OVERRIDE
Definition: macros.h:111
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
pkgCache - Structure definitions for the cache file
information for a single version of a package
Definition: pkgcache.h:625
const char * state
Definition: dpkgpm.h:56
const char * str
Definition: dpkgpm.h:57
Item(Ops Op, PkgIterator Pkg, std::string File="")
Definition: dpkgpm.h:80
PkgIterator Pkg
Definition: dpkgpm.h:79
std::string File
Definition: dpkgpm.h:78