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