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