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