]>
Commit | Line | Data |
---|---|---|
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 <vector> | |
15 | #include <map> | |
16 | #include <stdio.h> | |
17 | ||
18 | using std::vector; | |
19 | using std::map; | |
20 | ||
21 | ||
22 | class pkgDPkgPM : public pkgPackageManager | |
23 | { | |
24 | private: | |
25 | ||
26 | bool stdin_is_dev_null; | |
27 | ||
28 | // the buffer we use for the dpkg status-fd reading | |
29 | char dpkgbuf[1024]; | |
30 | int dpkgbuf_pos; | |
31 | FILE *term_out; | |
32 | FILE *history_out; | |
33 | string dpkg_error; | |
34 | ||
35 | /** \brief record the disappear action and handle accordingly | |
36 | ||
37 | dpkg let packages disappear then they have no files any longer and | |
38 | nothing depends on them. We need to collect this as dpkg as well as | |
39 | APT doesn't know beforehand that the package will disappear, so the | |
40 | only possible option is to tell the user afterwards about it. | |
41 | To enhance the experience we also try to forward the auto-install | |
42 | flag so the disappear-causer(s) are not autoremoved next time - | |
43 | for the transfer to happen the disappeared version needs to depend | |
44 | on the package the flag should be forwarded to and this package | |
45 | needs to declare a Replaces on the disappeared package. | |
46 | \param pkgname Name of the package that disappeared | |
47 | */ | |
48 | void handleDisappearAction(string const &pkgname); | |
49 | ||
50 | protected: | |
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 | map<string,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 | map<string,unsigned int> PackageOpsDone; | |
67 | // progress reporting | |
68 | unsigned int PackagesDone; | |
69 | unsigned int PackagesTotal; | |
70 | ||
71 | struct Item | |
72 | { | |
73 | enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op; | |
74 | string File; | |
75 | PkgIterator Pkg; | |
76 | Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op), | |
77 | File(File), Pkg(Pkg) {}; | |
78 | Item() {}; | |
79 | ||
80 | }; | |
81 | vector<Item> List; | |
82 | ||
83 | // Helpers | |
84 | bool RunScriptsWithPkgs(const char *Cnf); | |
85 | bool SendV2Pkgs(FILE *F); | |
86 | void WriteHistoryTag(string const &tag, string value); | |
87 | ||
88 | // dpkg log | |
89 | bool OpenLog(); | |
90 | bool CloseLog(); | |
91 | ||
92 | // input processing | |
93 | void DoStdin(int master); | |
94 | void DoTerminalPty(int master); | |
95 | void DoDpkgStatusFd(int statusfd, int OutStatusFd); | |
96 | void ProcessDpkgStatusLine(int OutStatusFd, char *line); | |
97 | ||
98 | // The Actuall installation implementation | |
99 | virtual bool Install(PkgIterator Pkg,string File); | |
100 | virtual bool Configure(PkgIterator Pkg); | |
101 | virtual bool Remove(PkgIterator Pkg,bool Purge = false); | |
102 | virtual bool Go(int StatusFd=-1); | |
103 | virtual void Reset(); | |
104 | ||
105 | public: | |
106 | ||
107 | pkgDPkgPM(pkgDepCache *Cache); | |
108 | virtual ~pkgDPkgPM(); | |
109 | }; | |
110 | ||
111 | #endif |