]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgsystem.h
Do not set the binary dir in run-tests, it breaks stuff
[apt.git] / apt-pkg / pkgsystem.h
CommitLineData
b2e465d6
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
b2e465d6
AL
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
1e3f4083 9 it's specialized offspring completely define the environment and how
b2e465d6
AL
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
1e3f4083 25 function of the system. Index files are handled through a separate
b2e465d6
AL
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
472ff00e 39#include <apt-pkg/pkgcache.h>
453b82a3 40#include <apt-pkg/cacheiterators.h>
b2e465d6 41
90f057fd 42#include <vector>
472ff00e 43
b9dadc24
DK
44#ifndef APT_8_CLEANER_HEADERS
45#include <apt-pkg/depcache.h>
46#endif
47
472ff00e 48class pkgDepCache;
b2e465d6
AL
49class pkgPackageManager;
50class pkgVersioningSystem;
51class Configuration;
52class pkgIndexFile;
53
307d9eb2 54class pkgSystemPrivate;
b2e465d6 55class pkgSystem
5465192b 56{
b2e465d6
AL
57 public:
58
59 // Global list of supported systems
60 static pkgSystem **GlobalList;
61 static unsigned long GlobalListLen;
62 static pkgSystem *GetSystem(const char *Label);
63
6c55f07a
DK
64 const char * const Label;
65 pkgVersioningSystem * const VS;
b2e465d6
AL
66
67 /* Prevent other programs from touching shared data not covered by
68 other locks (cache or state locks) */
69 virtual bool Lock() = 0;
70 virtual bool UnLock(bool NoErrors = false) = 0;
71
72 /* Various helper classes to interface with specific bits of this
73 environment */
74 virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0;
75
76 /* Load environment specific configuration and perform any other setup
77 necessary */
db5c1b54 78 virtual bool Initialize(Configuration &/*Cnf*/) {return true;};
b2e465d6
AL
79
80 /* Type is some kind of Globally Unique way of differentiating
81 archive file types.. */
82 virtual bool ArchiveSupported(const char *Type) = 0;
83
84 // Return a list of system index files..
5465192b
DK
85 virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;
86
af87ab54
AL
87 virtual bool FindIndex(pkgCache::PkgFileIterator File,
88 pkgIndexFile *&Found) const = 0;
a49e7948 89
b2e465d6
AL
90 /* Evauluate how 'right' we are for this system based on the filesystem
91 etc.. */
a49e7948
MV
92 virtual signed Score(Configuration const &/*Cnf*/) {
93 return 0;
94 };
6c55f07a 95
8d6d3f00
DK
96 //FIXME: these methods should be virtual
97 /** does this system has support for MultiArch?
98 *
99 * Systems supporting only single arch (not systems which are single arch)
100 * are considered legacy systems and support for it will likely degrade over
101 * time.
102 *
103 * The default implementation returns always \b true.
104 *
105 * @return \b true if the system supports MultiArch, \b false if not.
106 */
107 bool MultiArchSupported() const;
825db890
DK
108 /** architectures supported by this system
109 *
110 * A MultiArch capable system might be configured to use
111 * this capability.
112 *
113 * @return a list of all architectures (native + foreign) configured
114 * for on this system (aka: which can be installed without force)
115 */
116 std::vector<std::string> ArchitecturesSupported() const;
8d6d3f00 117
307d9eb2
DK
118 APT_HIDDEN void SetVersionMapping(map_id_t const in, map_id_t const out);
119 APT_HIDDEN map_id_t GetVersionMapping(map_id_t const in) const;
120
6c55f07a 121 pkgSystem(char const * const Label, pkgVersioningSystem * const VS);
c8a4ce6c
DK
122 virtual ~pkgSystem();
123 private:
307d9eb2 124 pkgSystemPrivate * const d;
b2e465d6
AL
125};
126
127// The environment we are operating in.
128extern pkgSystem *_system;
129
130#endif