apt
@VERSION@
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: policy.h,v 1.4 2001/05/07 04:24:08 jgg Exp $ 00004 /* ###################################################################### 00005 00006 Package Version Policy implementation 00007 00008 This implements the more advanced 'Version 4' APT policy engine. The 00009 standard 'Version 0' engine is included inside the DepCache which is 00010 it's historical location. 00011 00012 The V4 engine allows the user to completly control all aspects of 00013 version selection. There are three primary means to choose a version 00014 * Selection by version match 00015 * Selection by Release file match 00016 * Selection by origin server 00017 00018 Each package may be 'pinned' with a single criteria, which will ultimately 00019 result in the selection of a single version, or no version, for each 00020 package. 00021 00022 Furthermore, the default selection can be influenced by specifying 00023 the ordering of package files. The order is derived by reading the 00024 package file preferences and assigning a priority to each package 00025 file. 00026 00027 A special flag may be set to indicate if no version should be returned 00028 if no matching versions are found, otherwise the default matching 00029 rules are used to locate a hit. 00030 00031 ##################################################################### */ 00032 /*}}}*/ 00033 #ifndef PKGLIB_POLICY_H 00034 #define PKGLIB_POLICY_H 00035 00036 00037 #include <apt-pkg/depcache.h> 00038 #include <apt-pkg/versionmatch.h> 00039 #include <vector> 00040 00041 #ifndef APT_8_CLEANER_HEADERS 00042 using std::vector; 00043 #endif 00044 00045 class pkgPolicy : public pkgDepCache::Policy 00046 { 00047 protected: 00048 00049 struct Pin 00050 { 00051 pkgVersionMatch::MatchType Type; 00052 std::string Data; 00053 signed short Priority; 00054 Pin() : Type(pkgVersionMatch::None), Priority(0) {}; 00055 }; 00056 00057 struct PkgPin : Pin 00058 { 00059 std::string Pkg; 00060 PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {}; 00061 }; 00062 00063 Pin *Pins; 00064 signed short *PFPriority; 00065 std::vector<Pin> Defaults; 00066 std::vector<PkgPin> Unmatched; 00067 pkgCache *Cache; 00068 bool StatusOverride; 00069 00070 public: 00071 00072 // Things for manipulating pins 00073 void CreatePin(pkgVersionMatch::MatchType Type,std::string Pkg, 00074 std::string Data,signed short Priority); 00075 pkgCache::VerIterator GetMatch(pkgCache::PkgIterator const &Pkg); 00076 00077 // Things for the cache interface. 00078 virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator const &Pkg); 00079 virtual signed short GetPriority(pkgCache::PkgIterator const &Pkg); 00080 virtual signed short GetPriority(pkgCache::PkgFileIterator const &File); 00081 00082 bool InitDefaults(); 00083 00084 pkgPolicy(pkgCache *Owner); 00085 virtual ~pkgPolicy() {delete [] PFPriority; delete [] Pins;}; 00086 }; 00087 00088 bool ReadPinFile(pkgPolicy &Plcy, std::string File = ""); 00089 bool ReadPinDir(pkgPolicy &Plcy, std::string Dir = ""); 00090 00091 #endif