Merge branch 'debian/sid' into feature/install-progress-refactor
[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>
03e39e59 18
a4f6bdc8
DK
19#ifndef APT_8_CLEANER_HEADERS
20using std::vector;
21using std::map;
22#endif
23
697a1d8a 24class pkgDPkgPMPrivate;
233b185f 25
31f97d7b 26
03e39e59
AL
27class pkgDPkgPM : public pkgPackageManager
28{
6191b008 29 private:
697a1d8a 30 pkgDPkgPMPrivate *d;
9169c871 31
eb6f9bac
DK
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 */
8f3ba4e8 45 void handleDisappearAction(std::string const &pkgname);
eb6f9bac 46
ff56e980 47 protected:
5e457a93 48 int pkgFailures;
ff56e980 49
09fa2df2 50 // progress reporting
2a7e07c7
MV
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 };
09fa2df2
MV
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
8f3ba4e8 60 std::map<std::string,std::vector<struct DpkgState> > PackageOps;
09fa2df2
MV
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")
8f3ba4e8 64 std::map<std::string,unsigned int> PackageOpsDone;
73e0ee1e 65
09fa2df2 66 // progress reporting
4b7c5a3f
MV
67 unsigned int PackagesDone;
68 unsigned int PackagesTotal;
09fa2df2 69
03e39e59
AL
70 struct Item
71 {
5e312de7 72 enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
8f3ba4e8 73 std::string File;
03e39e59 74 PkgIterator Pkg;
8f3ba4e8 75 Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
03e39e59
AL
76 File(File), Pkg(Pkg) {};
77 Item() {};
78
79 };
8f3ba4e8 80 std::vector<Item> List;
6dd55be7
AL
81
82 // Helpers
db0c350f 83 bool RunScriptsWithPkgs(const char *Cnf);
7a948ec7
DK
84 __deprecated bool SendV2Pkgs(FILE *F);
85 bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
8f3ba4e8 86 void WriteHistoryTag(std::string const &tag, std::string value);
afb1e2e3 87
af6b4169
MV
88 // Terminal progress
89 void SetupTerminalScrollArea(int nr_scrolled_rows);
7546c8da 90 void SendTerminalProgress(float percentage);
c420fe00 91 void CleanupTerminal();
7546c8da 92
5e457a93
MV
93 // apport integration
94 void WriteApportReport(const char *pkgpath, const char *errormsg);
95
2e1715ea
MV
96 // dpkg log
97 bool OpenLog();
98 bool CloseLog();
99
ceabc520
MV
100 // input processing
101 void DoStdin(int master);
1ba38171 102 void DoTerminalPty(int master);
e6ad8031
MV
103 void DoDpkgStatusFd(int statusfd);
104 void ProcessDpkgStatusLine(char *line);
6191b008 105
03e39e59 106 // The Actuall installation implementation
8f3ba4e8 107 virtual bool Install(PkgIterator Pkg,std::string File);
03e39e59 108 virtual bool Configure(PkgIterator Pkg);
fc4b5c9f 109 virtual bool Remove(PkgIterator Pkg,bool Purge = false);
e6ad8031
MV
110
111 virtual bool Go(APT::Progress::PackageManager *progress);
281daf46 112 virtual void Reset();
03e39e59
AL
113
114 public:
115
b2e465d6 116 pkgDPkgPM(pkgDepCache *Cache);
03e39e59
AL
117 virtual ~pkgDPkgPM();
118};
119
590f1923
CB
120void SigINT(int sig);
121
03e39e59 122#endif