]>
Commit | Line | Data |
---|---|---|
03e39e59 AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
233b185f | 3 | // $Id: dpkgpm.h,v 1.8 2001/05/07 05:05:13 jgg Exp $ |
03e39e59 AL |
4 | /* ###################################################################### |
5 | ||
6 | DPKG Package Manager - Provide an interface to dpkg | |
7 | ||
8 | ##################################################################### */ | |
9 | /*}}}*/ | |
03e39e59 AL |
10 | #ifndef PKGLIB_DPKGPM_H |
11 | #define PKGLIB_DPKGPM_H | |
12 | ||
03e39e59 | 13 | #include <apt-pkg/packagemanager.h> |
453b82a3 DK |
14 | #include <apt-pkg/pkgcache.h> |
15 | #include <apt-pkg/macros.h> | |
16 | ||
03e39e59 | 17 | #include <vector> |
09fa2df2 | 18 | #include <map> |
b2e465d6 | 19 | #include <stdio.h> |
453b82a3 DK |
20 | #include <string> |
21 | ||
22 | #ifndef APT_10_CLEANER_HEADERS | |
bd5f39b3 | 23 | #include <apt-pkg/init.h> |
453b82a3 DK |
24 | #endif |
25 | ||
26 | class pkgDepCache; | |
27 | namespace APT { namespace Progress { class PackageManager; } } | |
03e39e59 | 28 | |
a4f6bdc8 DK |
29 | #ifndef APT_8_CLEANER_HEADERS |
30 | using std::vector; | |
31 | using std::map; | |
32 | #endif | |
33 | ||
697a1d8a | 34 | class pkgDPkgPMPrivate; |
233b185f | 35 | |
31f97d7b | 36 | |
03e39e59 AL |
37 | class pkgDPkgPM : public pkgPackageManager |
38 | { | |
6191b008 | 39 | private: |
6c55f07a | 40 | pkgDPkgPMPrivate * const d; |
9169c871 | 41 | |
eb6f9bac DK |
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 | */ | |
3809194b | 55 | APT_HIDDEN void handleDisappearAction(std::string const &pkgname); |
eb6f9bac | 56 | |
ff56e980 | 57 | protected: |
5e457a93 | 58 | int pkgFailures; |
ff56e980 | 59 | |
09fa2df2 | 60 | // progress reporting |
2a7e07c7 MV |
61 | struct DpkgState |
62 | { | |
63 | const char *state; // the dpkg state (e.g. "unpack") | |
64 | const char *str; // the human readable translation of the state | |
65 | }; | |
09fa2df2 MV |
66 | |
67 | // the dpkg states that the pkg will run through, the string is | |
68 | // the package, the vector contains the dpkg states that the package | |
69 | // will go through | |
8f3ba4e8 | 70 | std::map<std::string,std::vector<struct DpkgState> > PackageOps; |
09fa2df2 MV |
71 | // the dpkg states that are already done; the string is the package |
72 | // the int is the state that is already done (e.g. a package that is | |
73 | // going to be install is already in state "half-installed") | |
8f3ba4e8 | 74 | std::map<std::string,unsigned int> PackageOpsDone; |
73e0ee1e | 75 | |
09fa2df2 | 76 | // progress reporting |
4b7c5a3f MV |
77 | unsigned int PackagesDone; |
78 | unsigned int PackagesTotal; | |
4326680d DK |
79 | |
80 | public: | |
03e39e59 AL |
81 | struct Item |
82 | { | |
e7d4e0cf DK |
83 | enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending, |
84 | RemovePending, PurgePending } Op; | |
8f3ba4e8 | 85 | std::string File; |
03e39e59 | 86 | PkgIterator Pkg; |
8f3ba4e8 | 87 | Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op), |
03e39e59 AL |
88 | File(File), Pkg(Pkg) {}; |
89 | Item() {}; | |
03e39e59 | 90 | }; |
4326680d | 91 | protected: |
8f3ba4e8 | 92 | std::vector<Item> List; |
6dd55be7 AL |
93 | |
94 | // Helpers | |
db0c350f | 95 | bool RunScriptsWithPkgs(const char *Cnf); |
5dd00edb | 96 | APT_DEPRECATED_MSG("Use SendPkgInfo with the version as parameter instead") bool SendV2Pkgs(FILE *F); |
7a948ec7 | 97 | bool SendPkgsInfo(FILE * const F, unsigned int const &Version); |
8f3ba4e8 | 98 | void WriteHistoryTag(std::string const &tag, std::string value); |
dd640f3c MV |
99 | std::string ExpandShortPackageName(pkgDepCache &Cache, |
100 | const std::string &short_pkgname); | |
afb1e2e3 | 101 | |
af6b4169 | 102 | // Terminal progress |
7546c8da MV |
103 | void SendTerminalProgress(float percentage); |
104 | ||
5e457a93 MV |
105 | // apport integration |
106 | void WriteApportReport(const char *pkgpath, const char *errormsg); | |
107 | ||
2e1715ea MV |
108 | // dpkg log |
109 | bool OpenLog(); | |
110 | bool CloseLog(); | |
6fad3c24 MV |
111 | |
112 | // helper | |
113 | void BuildPackagesProgressMap(); | |
c3045b79 | 114 | void StartPtyMagic(); |
223ae57d | 115 | void SetupSlavePtyMagic(); |
c3045b79 | 116 | void StopPtyMagic(); |
2e1715ea | 117 | |
ceabc520 MV |
118 | // input processing |
119 | void DoStdin(int master); | |
1ba38171 | 120 | void DoTerminalPty(int master); |
e6ad8031 MV |
121 | void DoDpkgStatusFd(int statusfd); |
122 | void ProcessDpkgStatusLine(char *line); | |
6191b008 | 123 | |
8d89cda7 | 124 | // The Actual installation implementation |
3b302846 DK |
125 | virtual bool Install(PkgIterator Pkg,std::string File) APT_OVERRIDE; |
126 | virtual bool Configure(PkgIterator Pkg) APT_OVERRIDE; | |
127 | virtual bool Remove(PkgIterator Pkg,bool Purge = false) APT_OVERRIDE; | |
e6ad8031 | 128 | |
3b302846 | 129 | virtual bool Go(APT::Progress::PackageManager *progress) APT_OVERRIDE; |
4326680d | 130 | APT_DEPRECATED_MSG("Use overload with explicit progress manager") virtual bool Go(int StatusFd=-1) APT_OVERRIDE; |
bd5f39b3 | 131 | |
3b302846 | 132 | virtual void Reset() APT_OVERRIDE; |
03e39e59 AL |
133 | |
134 | public: | |
135 | ||
b2e465d6 | 136 | pkgDPkgPM(pkgDepCache *Cache); |
03e39e59 | 137 | virtual ~pkgDPkgPM(); |
4326680d DK |
138 | |
139 | APT_HIDDEN static bool ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache); | |
03e39e59 AL |
140 | }; |
141 | ||
590f1923 CB |
142 | void SigINT(int sig); |
143 | ||
03e39e59 | 144 | #endif |