]>
git.saurik.com Git - apt.git/blob - apt-pkg/policy.h
1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Package Version Policy implementation
7 This implements the more advanced 'Version 4' APT policy engine. The
8 standard 'Version 0' engine is included inside the DepCache which is
9 it's historical location.
11 The V4 engine allows the user to completly control all aspects of
12 version selection. There are three primary means to choose a version
13 * Selection by version match
14 * Selection by Release file match
15 * Selection by origin server
17 Each package may be 'pinned' with a single criteria, which will ultimately
18 result in the selection of a single version, or no version, for each
21 Furthermore, the default selection can be influenced by specifying
22 the ordering of package files. The order is derived by reading the
23 package file preferences and assigning a priority to each package
26 A special flag may be set to indicate if no version should be returned
27 if no matching versions are found, otherwise the default matching
28 rules are used to locate a hit.
30 ##################################################################### */
32 #ifndef PKGLIB_POLICY_H
33 #define PKGLIB_POLICY_H
35 #include <apt-pkg/depcache.h>
36 #include <apt-pkg/pkgcache.h>
37 #include <apt-pkg/cacheiterators.h>
38 #include <apt-pkg/versionmatch.h>
43 #ifndef APT_8_CLEANER_HEADERS
47 class pkgPolicy
: public pkgDepCache::Policy
53 pkgVersionMatch::MatchType Type
;
55 signed short Priority
;
56 Pin() : Type(pkgVersionMatch::None
), Priority(0) {};
62 explicit PkgPin(std::string
const &Pkg
) : Pin(), Pkg(Pkg
) {};
67 signed short *PFPriority
;
68 std::vector
<Pin
> Defaults
;
69 std::vector
<PkgPin
> Unmatched
;
75 // Things for manipulating pins
76 void CreatePin(pkgVersionMatch::MatchType Type
,std::string Pkg
,
77 std::string Data
,signed short Priority
);
78 pkgCache::VerIterator
GetMatch(pkgCache::PkgIterator
const &Pkg
);
80 // Things for the cache interface.
81 virtual pkgCache::VerIterator
GetCandidateVer(pkgCache::PkgIterator
const &Pkg
) APT_OVERRIDE
;
82 virtual signed short GetPriority(pkgCache::PkgIterator
const &Pkg
) APT_OVERRIDE
;
83 virtual signed short GetPriority(pkgCache::VerIterator
const &Pkg
);
84 virtual signed short GetPriority(pkgCache::PkgFileIterator
const &File
) APT_OVERRIDE
;
88 explicit pkgPolicy(pkgCache
*Owner
);
91 APT_HIDDEN
pkgCache::VerIterator
GetCandidateVerNew(pkgCache::PkgIterator
const &Pkg
);
95 bool ReadPinFile(pkgPolicy
&Plcy
, std::string File
= "");
96 bool ReadPinDir(pkgPolicy
&Plcy
, std::string Dir
= "");