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