]>
Commit | Line | Data |
---|---|---|
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> |
453b82a3 | 27 | #include <apt-pkg/macros.h> |
6c139d6e AL |
28 | |
29 | #include <string> | |
642ebc1a | 30 | #include <set> |
6c139d6e | 31 | |
453b82a3 DK |
32 | #ifndef APT_10_CLEANER_HEADERS |
33 | #include <apt-pkg/install-progress.h> | |
34 | #include <iostream> | |
35 | #endif | |
a4f6bdc8 | 36 | #ifndef APT_8_CLEANER_HEADERS |
b9dadc24 | 37 | #include <apt-pkg/depcache.h> |
a4f6bdc8 DK |
38 | using std::string; |
39 | #endif | |
40 | ||
03e39e59 | 41 | class pkgAcquire; |
6c139d6e AL |
42 | class pkgDepCache; |
43 | class pkgSourceList; | |
44 | class pkgOrderList; | |
03e39e59 | 45 | class pkgRecords; |
b58f28d4 MV |
46 | namespace APT { |
47 | namespace Progress { | |
48 | class PackageManager; | |
bf3ad91f DK |
49 | } |
50 | } | |
31f97d7b | 51 | |
e6ad8031 | 52 | |
b2e465d6 | 53 | class pkgPackageManager : protected pkgCache::Namespace |
6c139d6e | 54 | { |
281daf46 AL |
55 | public: |
56 | ||
57 | enum OrderResult {Completed,Failed,Incomplete}; | |
590f1923 | 58 | static bool SigINTStop; |
281daf46 | 59 | |
6c139d6e | 60 | protected: |
8f3ba4e8 | 61 | std::string *FileNames; |
6c139d6e AL |
62 | pkgDepCache &Cache; |
63 | pkgOrderList *List; | |
30e1eab5 | 64 | bool Debug; |
b684d8c7 | 65 | bool NoImmConfigure; |
a6c8798a | 66 | bool ImmConfigureAll; |
642ebc1a DK |
67 | |
68 | /** \brief saves packages dpkg let disappear | |
69 | ||
70 | This way APT can retreat from trying to configure these | |
add81166 | 71 | packages later on and a front-end can choose to display a |
642ebc1a DK |
72 | notice to inform the user about these disappears. |
73 | */ | |
74 | std::set<std::string> disappearedPkgs; | |
75 | ||
d183f850 | 76 | void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0); |
756458fb | 77 | virtual OrderResult OrderInstall(); |
6c139d6e | 78 | bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver); |
9106d7c9 | 79 | bool CheckRBreaks(PkgIterator const &Pkg,DepIterator Dep,const char * const Ver); |
7a1b1f8b | 80 | bool CreateOrderList(); |
6c139d6e AL |
81 | |
82 | // Analysis helpers | |
a02db58f | 83 | bool DepAlwaysTrue(DepIterator D) APT_PURE; |
6c139d6e AL |
84 | |
85 | // Install helpers | |
86 | bool ConfigureAll(); | |
71e7a0f3 | 87 | bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK; |
d77b985a | 88 | //FIXME: merge on abi break |
71e7a0f3 DK |
89 | bool SmartUnPack(PkgIterator Pkg) APT_MUSTCHECK; |
90 | bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth) APT_MUSTCHECK; | |
91 | bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK; | |
0eb4af9d DK |
92 | bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK; |
93 | APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK; | |
94 | ||
b2e465d6 | 95 | // The Actual installation implementation |
8f3ba4e8 | 96 | virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;}; |
db5c1b54 AL |
97 | virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; |
98 | virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; | |
65512241 | 99 | virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;}; |
ccf6bdb3 | 100 | virtual bool Go(int /*statusFd*/=-1) {return true;}; |
bd5f39b3 | 101 | |
281daf46 | 102 | virtual void Reset() {}; |
3c9b111f MV |
103 | |
104 | // the result of the operation | |
105 | OrderResult Res; | |
106 | ||
6c139d6e | 107 | public: |
281daf46 | 108 | |
b50b2c97 | 109 | // Main action members |
03e39e59 AL |
110 | bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, |
111 | pkgRecords *Recs); | |
3c9b111f | 112 | |
ccf6bdb3 | 113 | // Do the installation |
e6ad8031 | 114 | OrderResult DoInstall(APT::Progress::PackageManager *progress); |
e6ad8031 | 115 | // compat |
453b82a3 | 116 | APT_DEPRECATED OrderResult DoInstall(int statusFd=-1); |
3c9b111f MV |
117 | |
118 | // stuff that needs to be done before the fork() of a library that | |
119 | // uses apt | |
120 | OrderResult DoInstallPreFork() { | |
121 | Res = OrderInstall(); | |
122 | return Res; | |
123 | }; | |
3c9b111f | 124 | // stuff that needs to be done after the fork |
e6ad8031 | 125 | OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress); |
3b1b0f29 | 126 | // compat |
453b82a3 | 127 | APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1); |
3b1b0f29 MV |
128 | |
129 | // ? | |
6c139d6e | 130 | bool FixMissing(); |
642ebc1a DK |
131 | |
132 | /** \brief returns all packages dpkg let disappear */ | |
133 | inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; }; | |
134 | ||
e8afd168 | 135 | explicit pkgPackageManager(pkgDepCache *Cache); |
6c139d6e | 136 | virtual ~pkgPackageManager(); |
0eb4af9d DK |
137 | |
138 | private: | |
6c55f07a | 139 | void * const d; |
0eb4af9d DK |
140 | enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE }; |
141 | APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg, | |
142 | pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop, | |
143 | bool * const Bad, bool * const Changed) APT_MUSTCHECK; | |
6c139d6e AL |
144 | }; |
145 | ||
146 | #endif |