]>
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 AL |
13 | #include <apt-pkg/packagemanager.h> |
14 | #include <vector> | |
09fa2df2 | 15 | #include <map> |
b2e465d6 | 16 | #include <stdio.h> |
03e39e59 | 17 | |
a4f6bdc8 DK |
18 | #ifndef APT_8_CLEANER_HEADERS |
19 | using std::vector; | |
20 | using std::map; | |
21 | #endif | |
22 | ||
697a1d8a | 23 | class pkgDPkgPMPrivate; |
233b185f | 24 | |
03e39e59 AL |
25 | class pkgDPkgPM : public pkgPackageManager |
26 | { | |
6191b008 | 27 | private: |
697a1d8a | 28 | pkgDPkgPMPrivate *d; |
9169c871 | 29 | |
eb6f9bac DK |
30 | /** \brief record the disappear action and handle accordingly |
31 | ||
32 | dpkg let packages disappear then they have no files any longer and | |
33 | nothing depends on them. We need to collect this as dpkg as well as | |
34 | APT doesn't know beforehand that the package will disappear, so the | |
35 | only possible option is to tell the user afterwards about it. | |
36 | To enhance the experience we also try to forward the auto-install | |
37 | flag so the disappear-causer(s) are not autoremoved next time - | |
38 | for the transfer to happen the disappeared version needs to depend | |
39 | on the package the flag should be forwarded to and this package | |
40 | needs to declare a Replaces on the disappeared package. | |
41 | \param pkgname Name of the package that disappeared | |
42 | */ | |
8f3ba4e8 | 43 | void handleDisappearAction(std::string const &pkgname); |
eb6f9bac | 44 | |
ff56e980 | 45 | protected: |
5e457a93 | 46 | int pkgFailures; |
ff56e980 | 47 | |
09fa2df2 | 48 | // progress reporting |
2a7e07c7 MV |
49 | struct DpkgState |
50 | { | |
51 | const char *state; // the dpkg state (e.g. "unpack") | |
52 | const char *str; // the human readable translation of the state | |
53 | }; | |
09fa2df2 MV |
54 | |
55 | // the dpkg states that the pkg will run through, the string is | |
56 | // the package, the vector contains the dpkg states that the package | |
57 | // will go through | |
8f3ba4e8 | 58 | std::map<std::string,std::vector<struct DpkgState> > PackageOps; |
09fa2df2 MV |
59 | // the dpkg states that are already done; the string is the package |
60 | // the int is the state that is already done (e.g. a package that is | |
61 | // going to be install is already in state "half-installed") | |
8f3ba4e8 | 62 | std::map<std::string,unsigned int> PackageOpsDone; |
73e0ee1e | 63 | |
09fa2df2 | 64 | // progress reporting |
4b7c5a3f MV |
65 | unsigned int PackagesDone; |
66 | unsigned int PackagesTotal; | |
09fa2df2 | 67 | |
03e39e59 AL |
68 | struct Item |
69 | { | |
5e312de7 | 70 | enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op; |
8f3ba4e8 | 71 | std::string File; |
03e39e59 | 72 | PkgIterator Pkg; |
8f3ba4e8 | 73 | Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op), |
03e39e59 AL |
74 | File(File), Pkg(Pkg) {}; |
75 | Item() {}; | |
76 | ||
77 | }; | |
8f3ba4e8 | 78 | std::vector<Item> List; |
6dd55be7 AL |
79 | |
80 | // Helpers | |
db0c350f | 81 | bool RunScriptsWithPkgs(const char *Cnf); |
b2e465d6 | 82 | bool SendV2Pkgs(FILE *F); |
8f3ba4e8 | 83 | void WriteHistoryTag(std::string const &tag, std::string value); |
afb1e2e3 | 84 | |
5e457a93 MV |
85 | // apport integration |
86 | void WriteApportReport(const char *pkgpath, const char *errormsg); | |
87 | ||
2e1715ea MV |
88 | // dpkg log |
89 | bool OpenLog(); | |
90 | bool CloseLog(); | |
91 | ||
ceabc520 MV |
92 | // input processing |
93 | void DoStdin(int master); | |
1ba38171 | 94 | void DoTerminalPty(int master); |
09fa2df2 MV |
95 | void DoDpkgStatusFd(int statusfd, int OutStatusFd); |
96 | void ProcessDpkgStatusLine(int OutStatusFd, char *line); | |
6191b008 | 97 | |
03e39e59 | 98 | // The Actuall installation implementation |
8f3ba4e8 | 99 | virtual bool Install(PkgIterator Pkg,std::string File); |
03e39e59 | 100 | virtual bool Configure(PkgIterator Pkg); |
fc4b5c9f | 101 | virtual bool Remove(PkgIterator Pkg,bool Purge = false); |
2a7e07c7 | 102 | virtual bool Go(int StatusFd=-1); |
281daf46 | 103 | virtual void Reset(); |
03e39e59 AL |
104 | |
105 | public: | |
106 | ||
b2e465d6 | 107 | pkgDPkgPM(pkgDepCache *Cache); |
03e39e59 AL |
108 | virtual ~pkgDPkgPM(); |
109 | }; | |
110 | ||
590f1923 CB |
111 | void SigINT(int sig); |
112 | ||
03e39e59 | 113 | #endif |