This repository was archived by the owner on Dec 12, 2022. It is now read-only.
mirrored from https://salsa.debian.org/apt-team/apt.git
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathprivate-cacheset.h
133 lines (109 loc) · 5.11 KB
/
private-cacheset.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef APT_PRIVATE_CACHESET_H
#define APT_PRIVATE_CACHESET_H
#include <apt-pkg/cacheset.h>
#include <apt-pkg/macros.h>
#include <apt-private/private-output.h>
#include <list>
#include <set>
#include <string>
#include <vector>
class OpProgress;
class VerIteratorWithCaching
{
const pkgCache::VerIterator iter;
const pkgCache::DescFile * descFile;
public:
// cppcheck-suppress noExplicitConstructor
VerIteratorWithCaching(const pkgCache::VerIterator& iter) :
iter(iter),
descFile(iter->DescriptionList != 0
? (const pkgCache::DescFile *) iter.TranslatedDescription().FileList()
: nullptr)
{}
const pkgCache::DescFile * CachedDescFile() const { return descFile; }
operator pkgCache::VerIterator() const { return iter; }
map_id_t ID() const { return iter->ID; }
};
struct VersionSortDescriptionLocality /*{{{*/
{
bool operator () (const VerIteratorWithCaching &v_lhs,
const VerIteratorWithCaching &v_rhs) const
{
pkgCache::DescFile const *A = v_lhs.CachedDescFile();
pkgCache::DescFile const *B = v_rhs.CachedDescFile();
if (A == nullptr)
{
if (B == nullptr)
return v_lhs.ID() < v_rhs.ID();
return true;
}
else if (B == nullptr)
return false;
if (A->File == B->File)
{
if (A->Offset == B->Offset)
return v_lhs.ID() < v_rhs.ID();
return A->Offset < B->Offset;
}
return A->File < B->File;
}
};
/*}}}*/
// sorted by locality which makes iterating much faster
typedef APT::VersionContainer<
std::set<VerIteratorWithCaching,
VersionSortDescriptionLocality> > LocalitySortedVersionSet;
class Matcher {
public:
virtual bool operator () (const pkgCache::PkgIterator &/*P*/) {
return true;}
virtual ~Matcher() = default;
};
// FIXME: add default argument for OpProgress (or overloaded function)
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
APT::VersionContainerInterface * const vci,
Matcher &matcher,
OpProgress * const progress);
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
APT::VersionContainerInterface * const vci,
OpProgress * const progress);
// CacheSetHelper saving virtual packages /*{{{*/
class CacheSetHelperVirtuals: public APT::CacheSetHelper {
public:
APT::PackageSet virtualPkgs;
pkgCache::VerIterator canNotGetVersion(enum CacheSetHelper::VerSelector select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) override;
void canNotFindVersion(enum CacheSetHelper::VerSelector select, APT::VersionContainerInterface *vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) override;
pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) override;
CacheSetHelperVirtuals(bool const ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE);
};
/*}}}*/
// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
class CacheSetHelperAPTGet : public APT::CacheSetHelper {
/** \brief stream message should be printed to */
std::ostream &out;
/** \brief were things like Task or RegEx used to select packages? */
bool explicitlyNamed;
APT::PackageSet virtualPkgs;
public:
std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
std::set<std::string> notFound;
explicit CacheSetHelperAPTGet(std::ostream &out);
void showPackageSelection(pkgCache::PkgIterator const &Pkg, enum PkgSelector select, std::string const &pattern) override;
void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern);
void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern);
void showRegExSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern);
void showVersionSelection(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver, enum VerSelector select, std::string const &pattern) override;
bool showVirtualPackageErrors(pkgCacheFile &Cache);
pkgCache::VerIterator canNotGetVersion(enum VerSelector select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) override;
void canNotFindVersion(enum VerSelector select, APT::VersionContainerInterface *vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) override;
pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
pkgCache::VerIterator canNotFindVersionNumber(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, std::string const &verstr);
pkgCache::VerIterator canNotFindVersionRelease(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, std::string const &verstr);
pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) override;
APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg,
CacheSetHelper::VerSelector const select);
inline bool allPkgNamedExplicitly() const { return explicitlyNamed; }
};
/*}}}*/
#endif