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