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