apt: apt-pkg/packagemanager.h Source File

apt 2.7.5 commandline package manager

packagemanager.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Package Manager - Abstracts the package manager
6
7 Three steps are
8 - Aquiration of archives (stores the list of final file names)
9 - Sorting of operations
10 - Invocation 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/edsp.h>
26#include <apt-pkg/init.h>
27#include <apt-pkg/macros.h>
28#include <apt-pkg/pkgcache.h>
29
30#include <set>
31#include <string>
32
33
34class pkgAcquire;
35class pkgDepCache;
36class pkgSourceList;
37class pkgOrderList;
38class pkgRecords;
39class OpProgress;
40class pkgPackageManager;
41namespace APT {
42 namespace Progress {
43 class PackageManager;
44 }
45}
46
47 class APT_PUBLIC pkgPackageManager : protected pkgCache::Namespace
48{
49 public:
50
51 enum OrderResult {Completed,Failed,Incomplete};
52 static bool SigINTStop;
53
54 protected:
55 std::string *FileNames;
56 pkgDepCache &Cache;
57 pkgOrderList *List;
58 bool Debug;
59 bool NoImmConfigure;
60 bool ImmConfigureAll;
61
68 std::set<std::string> disappearedPkgs;
69
70 void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
71 virtual OrderResult OrderInstall();
72 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
73 bool CheckRBreaks(PkgIterator const &Pkg,DepIterator Dep,const char * const Ver);
74 bool CreateOrderList();
75
76 // Analysis helpers
77 bool DepAlwaysTrue(DepIterator D) APT_PURE;
78
79 // Install helpers
80 bool ConfigureAll();
81 bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
82 bool SmartUnPack(PkgIterator Pkg, bool const Immediate = true, int const Depth = 0) APT_MUSTCHECK;
83 bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK;
84 bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
85
86 // The Actual installation implementation
87 virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
88 virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
89 virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
90 virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
91
92 virtual void Reset() {};
93
94 // the result of the operation
95 OrderResult Res;
96
97 public:
98
99 // Main action members
100 bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
101 pkgRecords *Recs);
102
103 // Do the installation
104 OrderResult DoInstall(APT::Progress::PackageManager *progress);
105
106 friend bool EIPP::OrderInstall(char const * const planner, pkgPackageManager * const PM,
107 unsigned int const version, OpProgress * const Progress);
108 friend bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM,
109 OpProgress * const Progress);
110
111 // stuff that needs to be done before the fork() of a library that
112 // uses apt
113 OrderResult DoInstallPreFork() {
114 Res = OrderInstall();
115 return Res;
116 };
117 // stuff that needs to be done after the fork
118 OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
119 // compat
120
121 // ?
122 bool FixMissing();
123
125 inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
126
127 explicit pkgPackageManager(pkgDepCache *Cache);
128 virtual ~pkgPackageManager();
129
130 private:
131 void * const d;
132 enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
133 APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
134 pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
135 bool * const Bad, bool * const Changed) APT_MUSTCHECK;
136};
137
138#endif
APT::Progress::PackageManager
Definition install-progress.h:18
OpProgress
Definition progress.h:30
pkgAcquire
Represents the process by which a pkgAcquire object should retrieve a file or a collection of files.
Definition acquire-item.h:59
pkgCache::Namespace
Definition pkgcache.h:826
pkgDepCache
Definition depcache.h:62
pkgOrderList
Definition orderlist.h:25
pkgPackageManager
Definition packagemanager.h:48
pkgPackageManager::disappearedPkgs
std::set< std::string > disappearedPkgs
saves packages dpkg let disappear
Definition packagemanager.h:68
pkgPackageManager::GetDisappearedPackages
std::set< std::string > GetDisappearedPackages()
returns all packages dpkg let disappear
Definition packagemanager.h:125
pkgRecords
Definition pkgrecords.h:27
pkgSourceList
Definition sourcelist.h:43
edsp.h
pkgcache.h
pkgCache - Structure definitions for the cache file
pkgCache::Dep
Definition pkgcache.h:164