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