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