apt: apt-pkg/deb/dpkgpm.h Source File

apt 2.7.10 commandline package manager

dpkgpm.h
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
22class pkgDepCache;
23namespace APT { namespace Progress { class PackageManager; } }
24
25
26class pkgDPkgPMPrivate;
27
28
29 class APT_PUBLIC pkgDPkgPM : public pkgPackageManager
30{
31 private:
32 pkgDPkgPMPrivate * const d;
33
47 APT_HIDDEN void handleDisappearAction(std::string const &pkgname);
48 APT_HIDDEN void handleCrossUpgradeAction(std::string const &pkgname);
49
50 protected:
51 int pkgFailures;
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;
79 PkgIterator Pkg;
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
133void SigINT(int sig);
134
135#endif
pkgDPkgPMPrivate
Definition dpkgpm.cc:103
pkgDPkgPM
Definition dpkgpm.h:30
pkgDepCache
Definition depcache.h:62
pkgPackageManager
Definition packagemanager.h:48
pkgcache.h
pkgCache - Structure definitions for the cache file
pkgCache::Version
information for a single version of a package
Definition pkgcache.h:625
pkgDPkgPM::DpkgState
Definition dpkgpm.h:55
pkgDPkgPM::Item
Definition dpkgpm.h:75