]> git.saurik.com Git - apt.git/blob - apt-pkg/packagemanager.h
fix 'Source' to 'Package' rename in apt-ftparchive
[apt.git] / apt-pkg / packagemanager.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: packagemanager.h,v 1.14 2001/05/07 04:24:08 jgg Exp $
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
11 - Invokation of package manager
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 /*}}}*/
23 #ifndef PKGLIB_PACKAGEMANAGER_H
24 #define PKGLIB_PACKAGEMANAGER_H
25
26 #include <apt-pkg/pkgcache.h>
27 #include <apt-pkg/init.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 namespace APT {
48 namespace Progress {
49 class PackageManager;
50 }
51 }
52
53
54 class pkgPackageManager : protected pkgCache::Namespace
55 {
56 public:
57
58 enum OrderResult {Completed,Failed,Incomplete};
59 static bool SigINTStop;
60
61 protected:
62 std::string *FileNames;
63 pkgDepCache &Cache;
64 pkgOrderList *List;
65 bool Debug;
66 bool NoImmConfigure;
67 bool ImmConfigureAll;
68
69 /** \brief saves packages dpkg let disappear
70
71 This way APT can retreat from trying to configure these
72 packages later on and a frontend can choose to display a
73 notice to inform the user about these disappears.
74 */
75 std::set<std::string> disappearedPkgs;
76
77 void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
78 virtual OrderResult OrderInstall();
79 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
80 bool CreateOrderList();
81
82 // Analysis helpers
83 bool DepAlwaysTrue(DepIterator D) APT_PURE;
84
85 // Install helpers
86 bool ConfigureAll();
87 bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
88 //FIXME: merge on abi break
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;
92 bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
93 APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK;
94
95 // The Actual installation implementation
96 virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
97 virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
98 virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
99 #if APT_PKG_ABI >= 413
100 virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
101 #endif
102 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 #if APT_PKG_ABI >= 413
117 OrderResult DoInstall(APT::Progress::PackageManager *progress);
118 // compat
119 APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
120 #else
121 OrderResult DoInstall(int statusFd=-1);
122 #endif
123
124 // stuff that needs to be done before the fork() of a library that
125 // uses apt
126 OrderResult DoInstallPreFork() {
127 Res = OrderInstall();
128 return Res;
129 };
130 #if APT_PKG_ABI >= 413
131 // stuff that needs to be done after the fork
132 OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
133 // compat
134 APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
135 #else
136 OrderResult DoInstallPostFork(int statusFd=-1);
137 #endif
138
139 // ?
140 bool FixMissing();
141
142 /** \brief returns all packages dpkg let disappear */
143 inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
144
145 pkgPackageManager(pkgDepCache *Cache);
146 virtual ~pkgPackageManager();
147
148 private:
149 enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
150 APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
151 pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
152 bool * const Bad, bool * const Changed) APT_MUSTCHECK;
153 };
154
155 #endif