]> git.saurik.com Git - apt.git/blame - apt-private/private-cacheset.h
select kernels to protect from autoremove based on Debian version
[apt.git] / apt-private / private-cacheset.h
CommitLineData
b9179170
MV
1#ifndef APT_PRIVATE_CACHESET_H
2#define APT_PRIVATE_CACHESET_H
3
b9179170 4#include <apt-pkg/cacheset.h>
453b82a3 5#include <apt-pkg/macros.h>
b9179170 6
a0c19a21
DK
7#include <apt-private/private-output.h>
8
b9179170 9#include <vector>
453b82a3 10#include <list>
453b82a3
DK
11#include <set>
12#include <string>
b9179170 13
b9179170
MV
14#include <apti18n.h>
15
453b82a3
DK
16class OpProgress;
17
6cfadda1 18struct APT_PUBLIC VersionSortDescriptionLocality /*{{{*/
b9179170 19{
6cfadda1
DK
20 bool operator () (const pkgCache::VerIterator &v_lhs,
21 const pkgCache::VerIterator &v_rhs)
22 {
23 pkgCache::DescFile const *A = nullptr;
24 pkgCache::DescFile const *B = nullptr;
25 if (v_lhs->DescriptionList != 0)
26 A = v_lhs.TranslatedDescription().FileList();
27 if (v_rhs->DescriptionList != 0)
28 B = v_rhs.TranslatedDescription().FileList();
3d8232bf 29
6cfadda1
DK
30 if (A == nullptr && B == nullptr)
31 return false;
b9179170 32
6cfadda1
DK
33 if (A == nullptr)
34 return true;
b9179170 35
6cfadda1
DK
36 if (B == nullptr)
37 return false;
b9179170 38
6cfadda1
DK
39 if (A->File == B->File)
40 return A->Offset < B->Offset;
b9179170 41
6cfadda1
DK
42 return A->File < B->File;
43 }
b9179170 44};
6cfadda1 45 /*}}}*/
b9179170
MV
46// sorted by locality which makes iterating much faster
47typedef APT::VersionContainer<
48 std::set<pkgCache::VerIterator,
49 VersionSortDescriptionLocality> > LocalitySortedVersionSet;
50
51class Matcher {
52public:
65512241
DK
53 virtual bool operator () (const pkgCache::PkgIterator &/*P*/) {
54 return true;}
b9179170
MV
55};
56
57// FIXME: add default argument for OpProgress (or overloaded function)
25594bb5
DK
58bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
59 APT::VersionContainerInterface * const vci,
b9179170 60 Matcher &matcher,
25594bb5
DK
61 OpProgress * const progress);
62bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
63 APT::VersionContainerInterface * const vci,
64 OpProgress * const progress);
b9179170
MV
65
66
67// CacheSetHelper saving virtual packages /*{{{*/
6cfadda1 68class APT_PUBLIC CacheSetHelperVirtuals: public APT::CacheSetHelper {
b9179170
MV
69public:
70 APT::PackageSet virtualPkgs;
71
6cfadda1
DK
72 virtual pkgCache::VerIterator canNotGetVersion(enum CacheSetHelper::VerSelector const select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
73 virtual void canNotFindVersion(enum CacheSetHelper::VerSelector const select, APT::VersionContainerInterface * vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
3addaba1 74 virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) APT_OVERRIDE;
b9179170 75
6cfadda1 76 CacheSetHelperVirtuals(bool const ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE);
b9179170
MV
77};
78 /*}}}*/
79
80// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
6cfadda1 81class APT_PUBLIC CacheSetHelperAPTGet : public APT::CacheSetHelper {
b9179170
MV
82 /** \brief stream message should be printed to */
83 std::ostream &out;
84 /** \brief were things like Task or RegEx used to select packages? */
85 bool explicitlyNamed;
86
87 APT::PackageSet virtualPkgs;
88
89public:
90 std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
91
6cfadda1 92 CacheSetHelperAPTGet(std::ostream &out);
b9179170 93
6cfadda1
DK
94 virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
95 virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
96 virtual void showRegExSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
65512241 97 virtual void showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, pkgCache::VerIterator const Ver,
6cfadda1
DK
98 std::string const &ver, bool const /*verIsRel*/) APT_OVERRIDE;
99 bool showVirtualPackageErrors(pkgCacheFile &Cache);
b9179170 100
6cfadda1
DK
101 virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
102 virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
3addaba1 103 virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) APT_OVERRIDE;
b9179170
MV
104
105 APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg,
6cfadda1 106 CacheSetHelper::VerSelector const select);
b9179170
MV
107
108 inline bool allPkgNamedExplicitly() const { return explicitlyNamed; }
b9179170
MV
109};
110 /*}}}*/
111
112#endif