]> git.saurik.com Git - apt.git/blob - apt-pkg/packagemanager.h
Coverage: Do not print messages from gcov
[apt.git] / apt-pkg / packagemanager.h
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/edsp.h>
28 #include <apt-pkg/macros.h>
29
30 #include <string>
31 #include <set>
32
33 #ifndef APT_10_CLEANER_HEADERS
34 #include <apt-pkg/install-progress.h>
35 #include <iostream>
36 #endif
37 #ifndef APT_8_CLEANER_HEADERS
38 #include <apt-pkg/depcache.h>
39 using std::string;
40 #endif
41
42 class pkgAcquire;
43 class pkgDepCache;
44 class pkgSourceList;
45 class pkgOrderList;
46 class pkgRecords;
47 class OpProgress;
48 class pkgPackageManager;
49 namespace APT {
50 namespace Progress {
51 class PackageManager;
52 }
53 }
54
55 class pkgPackageManager : protected pkgCache::Namespace
56 {
57 public:
58
59 enum OrderResult {Completed,Failed,Incomplete};
60 static bool SigINTStop;
61
62 protected:
63 std::string *FileNames;
64 pkgDepCache &Cache;
65 pkgOrderList *List;
66 bool Debug;
67 bool NoImmConfigure;
68 bool ImmConfigureAll;
69
70 /** \brief saves packages dpkg let disappear
71
72 This way APT can retreat from trying to configure these
73 packages later on and a front-end can choose to display a
74 notice to inform the user about these disappears.
75 */
76 std::set<std::string> disappearedPkgs;
77
78 void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
79 virtual OrderResult OrderInstall();
80 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
81 bool CheckRBreaks(PkgIterator const &Pkg,DepIterator Dep,const char * const Ver);
82 bool CreateOrderList();
83
84 // Analysis helpers
85 bool DepAlwaysTrue(DepIterator D) APT_PURE;
86
87 // Install helpers
88 bool ConfigureAll();
89 bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
90 //FIXME: merge on abi break
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;
94 bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
95 APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK;
96
97 // The Actual installation implementation
98 virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
99 virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
100 virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
101 virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
102 APT_DEPRECATED_MSG("Use overload with explicit progress manager") virtual bool Go(int /*statusFd*/=-1) {return true;};
103
104 virtual void Reset() {};
105
106 // the result of the operation
107 OrderResult Res;
108
109 public:
110
111 // Main action members
112 bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
113 pkgRecords *Recs);
114
115 // Do the installation
116 OrderResult DoInstall(APT::Progress::PackageManager *progress);
117 // compat
118 APT_DEPRECATED_MSG("Use APT::Progress::PackageManager subclass instead of fd") OrderResult DoInstall(int statusFd=-1);
119
120 friend bool EIPP::OrderInstall(char const * const planner, pkgPackageManager * const PM,
121 unsigned int const version, OpProgress * const Progress);
122 friend bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM,
123 OpProgress * const Progress);
124
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 };
131 // stuff that needs to be done after the fork
132 OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
133 // compat
134 APT_DEPRECATED_MSG("Use APT::Progress::PackageManager subclass instead of fd") OrderResult DoInstallPostFork(int statusFd=-1);
135
136 // ?
137 bool FixMissing();
138
139 /** \brief returns all packages dpkg let disappear */
140 inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
141
142 explicit pkgPackageManager(pkgDepCache *Cache);
143 virtual ~pkgPackageManager();
144
145 private:
146 void * const d;
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;
151 };
152
153 #endif