apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pkgsystem.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  System - Abstraction for running on different systems.
6 
7  Instances of this class can be thought of as factories or meta-classes
8  for a variety of more specialized classes. Together this class and
9  it's specialized offspring completely define the environment and how
10  to access resources for a specific system. There are several sub
11  areas that are all orthogonal - each system has a unique combination of
12  these sub areas:
13  - Versioning. Different systems have different ideas on versions.
14  Within a system all sub classes must follow the same versioning
15  rules.
16  - Local tool locking to prevent multiple tools from accessing the
17  same database.
18  - Candidate Version selection policy - this is probably almost always
19  managed using a standard APT class
20  - Actual Package installation
21  * Indication of what kind of binary formats are supported
22  - Selection of local 'status' indexes that make up the pkgCache.
23 
24  It is important to note that the handling of index files is not a
25  function of the system. Index files are handled through a separate
26  abstraction - the only requirement is that the index files have the
27  same idea of versioning as the target system.
28 
29  Upon startup each supported system instantiates an instance of the
30  pkgSystem class (using a global constructor) which will make itself
31  available to the main APT init routine. That routine will select the
32  proper system and make it the global default.
33 
34  ##################################################################### */
35  /*}}}*/
36 #ifndef PKGLIB_PKGSYSTEM_H
37 #define PKGLIB_PKGSYSTEM_H
38 
39 #include <apt-pkg/pkgcache.h>
40 
41 #include <vector>
42 
43 
44 class pkgDepCache;
45 class pkgPackageManager;
47 class Configuration;
48 class pkgIndexFile;
49 class OpProgress;
50 
51 class pkgSystemPrivate;
53 {
54  public:
55 
56  // Global list of supported systems
58  static unsigned long GlobalListLen;
59  static pkgSystem *GetSystem(const char *Label);
60 
61  const char * const Label;
63 
64  /* Prevent other programs from touching shared data not covered by
65  other locks (cache or state locks) */
66  virtual bool Lock(OpProgress *const Progress = nullptr) = 0;
67  virtual bool UnLock(bool NoErrors = false) = 0;
68 
69  /* Various helper classes to interface with specific bits of this
70  environment */
71  virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0;
72 
73  /* Load environment specific configuration and perform any other setup
74  necessary */
75  virtual bool Initialize(Configuration &/*Cnf*/) {return true;};
76 
77  /* Type is some kind of Globally Unique way of differentiating
78  archive file types.. */
79  virtual bool ArchiveSupported(const char *Type) = 0;
80 
81  // Return a list of system index files..
82  virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;
83 
85  pkgIndexFile *&Found) const = 0;
86 
87  /* Evaluate how 'right' we are for this system based on the filesystem
88  etc.. */
89  virtual signed Score(Configuration const &/*Cnf*/) {
90  return 0;
91  };
92 
93  //FIXME: these methods should be virtual
94  /** does this system has support for MultiArch?
95  *
96  * Systems supporting only single arch (not systems which are single arch)
97  * are considered legacy systems and support for it will likely degrade over
98  * time.
99  *
100  * The default implementation returns always \b true.
101  *
102  * @return \b true if the system supports MultiArch, \b false if not.
103  */
104  virtual bool MultiArchSupported() const = 0;
105  /** architectures supported by this system
106  *
107  * A MultiArch capable system might be configured to use
108  * this capability.
109  *
110  * @return a list of all architectures (native + foreign) configured
111  * for on this system (aka: which can be installed without force)
112  */
113  virtual std::vector<std::string> ArchitecturesSupported() const = 0;
114 
115  APT_HIDDEN void SetVersionMapping(map_id_t const in, map_id_t const out);
116  APT_HIDDEN map_id_t GetVersionMapping(map_id_t const in) const;
117 
118  pkgSystem(char const * const Label, pkgVersioningSystem * const VS);
119  virtual ~~pkgSystem();
120 
121 
122  /* companions to Lock()/UnLock
123  *
124  * These functions can be called prior to calling dpkg to release an inner
125  * lock without releasing the overall outer lock, so that dpkg can run
126  * correctly but no other APT instance can acquire the system lock.
127  */
128  virtual bool LockInner(OpProgress *const Progress = 0, int timeOutSec = 0) = 0;
129  virtual bool UnLockInner(bool NoErrors = false) = 0;
130  /// checks if the system is currently locked
131  virtual bool IsLocked() = 0;
132  private:
134 };
135 
136 // The environment we are operating in.
138 
139 #endif
virtual pkgPackageManager * CreatePM(pkgDepCache *Cache) const =0
virtual bool AddStatusFiles(std::vector< pkgIndexFile * > &List)=0
virtual bool IsLocked()=0
checks if the system is currently locked
static pkgSystem ** GlobalList
Definition: pkgsystem.h:57
virtual bool UnLock(bool NoErrors=false)=0
virtual bool FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const =0
virtual bool Lock(OpProgress *const Progress=nullptr)=0
virtual std::vector< std::string > ArchitecturesSupported() const =0
virtual bool MultiArchSupported() const =0
pkgSystemPrivate *const d
Definition: pkgsystem.h:133
pkgVersioningSystem *const VS
Definition: pkgsystem.h:62
const char *const Label
Definition: pkgsystem.h:61
virtual bool ArchiveSupported(const char *Type)=0
virtual bool Initialize(Configuration &)
Definition: pkgsystem.h:75
static unsigned long GlobalListLen
Definition: pkgsystem.h:58
virtual bool LockInner(OpProgress *const Progress=0, int timeOutSec=0)=0
virtual signed Score(Configuration const &)
Definition: pkgsystem.h:89
virtual bool UnLockInner(bool NoErrors=false)=0
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
pkgCache - Structure definitions for the cache file
uint32_t map_id_t
Definition: pkgcache.h:93
APT_PUBLIC pkgSystem * _system
Definition: pkgsystem.cc:24