]> git.saurik.com Git - apt.git/blame - apt-pkg/packagemanager.h
Merge commit 'e2073b0276226b625897ef475f225bf8f508719e' as 'triehash'
[apt.git] / apt-pkg / packagemanager.h
CommitLineData
6c139d6e
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
6c139d6e
AL
3/* ######################################################################
4
5 Package Manager - Abstacts the package manager
6
7 Three steps are
8 - Aquiration of archives (stores the list of final file names)
9 - Sorting of operations
6fc33863 10 - Invokation of package manager
6c139d6e
AL
11
12 This is the final stage when the package cache entities get converted
13 into file names and the state stored in a DepCache is transformed
14 into a series of operations.
15
16 In the final scheme of things this may serve as a director class to
17 access the actual install methods based on the file type being
18 installed.
19
20 ##################################################################### */
21 /*}}}*/
6c139d6e
AL
22#ifndef PKGLIB_PACKAGEMANAGER_H
23#define PKGLIB_PACKAGEMANAGER_H
24
472ff00e 25#include <apt-pkg/pkgcache.h>
bd5f39b3 26#include <apt-pkg/init.h>
f74d99c6 27#include <apt-pkg/edsp.h>
453b82a3 28#include <apt-pkg/macros.h>
6c139d6e
AL
29
30#include <string>
642ebc1a 31#include <set>
6c139d6e 32
453b82a3
DK
33#ifndef APT_10_CLEANER_HEADERS
34#include <apt-pkg/install-progress.h>
35#include <iostream>
36#endif
a4f6bdc8 37#ifndef APT_8_CLEANER_HEADERS
b9dadc24 38#include <apt-pkg/depcache.h>
a4f6bdc8
DK
39using std::string;
40#endif
41
03e39e59 42class pkgAcquire;
6c139d6e
AL
43class pkgDepCache;
44class pkgSourceList;
45class pkgOrderList;
03e39e59 46class pkgRecords;
f74d99c6
DK
47class OpProgress;
48class pkgPackageManager;
b58f28d4
MV
49namespace APT {
50 namespace Progress {
51 class PackageManager;
bf3ad91f
DK
52 }
53}
31f97d7b 54
b2e465d6 55class pkgPackageManager : protected pkgCache::Namespace
6c139d6e 56{
281daf46
AL
57 public:
58
59 enum OrderResult {Completed,Failed,Incomplete};
590f1923 60 static bool SigINTStop;
281daf46 61
6c139d6e 62 protected:
8f3ba4e8 63 std::string *FileNames;
6c139d6e
AL
64 pkgDepCache &Cache;
65 pkgOrderList *List;
30e1eab5 66 bool Debug;
b684d8c7 67 bool NoImmConfigure;
a6c8798a 68 bool ImmConfigureAll;
642ebc1a
DK
69
70 /** \brief saves packages dpkg let disappear
71
72 This way APT can retreat from trying to configure these
add81166 73 packages later on and a front-end can choose to display a
642ebc1a
DK
74 notice to inform the user about these disappears.
75 */
76 std::set<std::string> disappearedPkgs;
77
d183f850 78 void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
756458fb 79 virtual OrderResult OrderInstall();
6c139d6e 80 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
9106d7c9 81 bool CheckRBreaks(PkgIterator const &Pkg,DepIterator Dep,const char * const Ver);
7a1b1f8b 82 bool CreateOrderList();
6c139d6e
AL
83
84 // Analysis helpers
a02db58f 85 bool DepAlwaysTrue(DepIterator D) APT_PURE;
6c139d6e
AL
86
87 // Install helpers
88 bool ConfigureAll();
71e7a0f3 89 bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
d77b985a 90 //FIXME: merge on abi break
71e7a0f3
DK
91 bool SmartUnPack(PkgIterator Pkg) APT_MUSTCHECK;
92 bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth) APT_MUSTCHECK;
93 bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK;
0eb4af9d
DK
94 bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
95 APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK;
96
b2e465d6 97 // The Actual installation implementation
8f3ba4e8 98 virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
db5c1b54
AL
99 virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
100 virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
65512241 101 virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
4326680d 102 APT_DEPRECATED_MSG("Use overload with explicit progress manager") virtual bool Go(int /*statusFd*/=-1) {return true;};
bd5f39b3 103
281daf46 104 virtual void Reset() {};
3c9b111f
MV
105
106 // the result of the operation
107 OrderResult Res;
108
6c139d6e 109 public:
281daf46 110
b50b2c97 111 // Main action members
03e39e59
AL
112 bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
113 pkgRecords *Recs);
3c9b111f 114
ccf6bdb3 115 // Do the installation
e6ad8031 116 OrderResult DoInstall(APT::Progress::PackageManager *progress);
e6ad8031 117 // compat
5dd00edb 118 APT_DEPRECATED_MSG("Use APT::Progress::PackageManager subclass instead of fd") OrderResult DoInstall(int statusFd=-1);
3c9b111f 119
8e99b22c 120 friend bool EIPP::OrderInstall(char const * const planner, pkgPackageManager * const PM,
f74d99c6
DK
121 unsigned int const version, OpProgress * const Progress);
122 friend bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM,
123 OpProgress * const Progress);
124
3c9b111f
MV
125 // stuff that needs to be done before the fork() of a library that
126 // uses apt
127 OrderResult DoInstallPreFork() {
128 Res = OrderInstall();
129 return Res;
130 };
3c9b111f 131 // stuff that needs to be done after the fork
e6ad8031 132 OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
3b1b0f29 133 // compat
5dd00edb 134 APT_DEPRECATED_MSG("Use APT::Progress::PackageManager subclass instead of fd") OrderResult DoInstallPostFork(int statusFd=-1);
3b1b0f29
MV
135
136 // ?
6c139d6e 137 bool FixMissing();
642ebc1a
DK
138
139 /** \brief returns all packages dpkg let disappear */
140 inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
141
e8afd168 142 explicit pkgPackageManager(pkgDepCache *Cache);
6c139d6e 143 virtual ~pkgPackageManager();
0eb4af9d
DK
144
145 private:
6c55f07a 146 void * const d;
0eb4af9d
DK
147 enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
148 APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
149 pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
150 bool * const Bad, bool * const Changed) APT_MUSTCHECK;
6c139d6e
AL
151};
152
153#endif