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