]> git.saurik.com Git - apt.git/blob - apt-pkg/deb/dpkgpm.h
cleanup datatypes mix used in binary cache
[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 <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
26 class pkgDepCache;
27 namespace APT { namespace Progress { class PackageManager; } }
28
29 #ifndef APT_8_CLEANER_HEADERS
30 using std::vector;
31 using std::map;
32 #endif
33
34 class pkgDPkgPMPrivate;
35
36
37 class pkgDPkgPM : public pkgPackageManager
38 {
39 private:
40 pkgDPkgPMPrivate *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 void handleDisappearAction(std::string const &pkgname);
56
57 protected:
58 int pkgFailures;
59
60 // progress reporting
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 };
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
70 std::map<std::string,std::vector<struct DpkgState> > PackageOps;
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")
74 std::map<std::string,unsigned int> PackageOpsDone;
75
76 // progress reporting
77 unsigned int PackagesDone;
78 unsigned int PackagesTotal;
79
80 struct Item
81 {
82 enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
83 std::string File;
84 PkgIterator Pkg;
85 Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
86 File(File), Pkg(Pkg) {};
87 Item() {};
88
89 };
90 std::vector<Item> List;
91
92 // Helpers
93 bool RunScriptsWithPkgs(const char *Cnf);
94 APT_DEPRECATED bool SendV2Pkgs(FILE *F);
95 bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
96 void WriteHistoryTag(std::string const &tag, std::string value);
97 std::string ExpandShortPackageName(pkgDepCache &Cache,
98 const std::string &short_pkgname);
99
100 // Terminal progress
101 void SendTerminalProgress(float percentage);
102
103 // apport integration
104 void WriteApportReport(const char *pkgpath, const char *errormsg);
105
106 // dpkg log
107 bool OpenLog();
108 bool CloseLog();
109
110 // helper
111 void BuildPackagesProgressMap();
112 void StartPtyMagic();
113 void StopPtyMagic();
114
115 // input processing
116 void DoStdin(int master);
117 void DoTerminalPty(int master);
118 void DoDpkgStatusFd(int statusfd);
119 void ProcessDpkgStatusLine(char *line);
120 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
121 void DoDpkgStatusFd(int statusfd, int /*unused*/) {
122 DoDpkgStatusFd(statusfd);
123 }
124 void ProcessDpkgStatusLine(int /*unused*/, char *line) {
125 ProcessDpkgStatusLine(line);
126 }
127 #endif
128
129
130 // The Actuall installation implementation
131 virtual bool Install(PkgIterator Pkg,std::string File);
132 virtual bool Configure(PkgIterator Pkg);
133 virtual bool Remove(PkgIterator Pkg,bool Purge = false);
134
135 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
136 virtual bool Go(APT::Progress::PackageManager *progress);
137 #else
138 virtual bool Go(int StatusFd=-1);
139 bool GoNoABIBreak(APT::Progress::PackageManager *progress);
140 #endif
141
142 virtual void Reset();
143
144 public:
145
146 pkgDPkgPM(pkgDepCache *Cache);
147 virtual ~pkgDPkgPM();
148 };
149
150 void SigINT(int sig);
151
152 #endif