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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
// Include Files /*{{{*/
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/metaindex.h>
#include <apt-pkg/debmetaindex.h>
#include <string>
#include <vector>
/*}}}*/
class metaIndexPrivate /*{{{*/
{
public:
std::string Origin;
std::string Label;
std::string Version;
signed short DefaultPin;
std::string ReleaseNotes;
};
/*}}}*/
std::string metaIndex::Describe() const
{
return "Release";
}
pkgCache::RlsFileIterator metaIndex::FindInCache(pkgCache &Cache, bool const) const
{
return pkgCache::RlsFileIterator(Cache);
}
bool metaIndex::Merge(pkgCacheGenerator &Gen,OpProgress *) const
{
return Gen.SelectReleaseFile("", "");
}
metaIndex::metaIndex(std::string const &URI, std::string const &Dist,
char const * const Type)
: d(new metaIndexPrivate()), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET),
Date(0), ValidUntil(0), SupportsAcquireByHash(false), LoadedSuccessfully(TRI_UNSET)
{
/* nothing */
}
metaIndex::~metaIndex()
{
if (Indexes != 0)
{
for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
I != (*Indexes).end(); ++I)
delete *I;
delete Indexes;
}
for (auto const &E: Entries)
delete E.second;
delete d;
}
// one line Getters for public fields /*{{{*/
APT_PURE std::string metaIndex::GetURI() const { return URI; }
APT_PURE std::string metaIndex::GetDist() const { return Dist; }
APT_PURE const char* metaIndex::GetType() const { return Type; }
APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; }
APT_PURE std::string metaIndex::GetSignedBy() const { return SignedBy; }
APT_PURE std::string metaIndex::GetOrigin() const { return d->Origin; }
APT_PURE std::string metaIndex::GetLabel() const { return d->Label; }
APT_PURE std::string metaIndex::GetVersion() const { return d->Version; }
APT_PURE std::string metaIndex::GetCodename() const { return Codename; }
APT_PURE std::string metaIndex::GetSuite() const { return Suite; }
APT_PURE std::string metaIndex::GetReleaseNotes() const { return d->ReleaseNotes; }
APT_PURE signed short metaIndex::GetDefaultPin() const { return d->DefaultPin; }
APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; }
APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; }
APT_PURE time_t metaIndex::GetDate() const { return this->Date; }
APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; }
APT_PURE std::string metaIndex::GetExpectedDist() const { return Dist; }
/*}}}*/
bool metaIndex::CheckDist(string const &MaybeDist) const /*{{{*/
{
if (MaybeDist.empty() || this->Codename == MaybeDist || this->Suite == MaybeDist)
return true;
std::string Transformed = MaybeDist;
if (Transformed == "../project/experimental")
Transformed = "experimental";
auto const pos = Transformed.rfind('/');
if (pos != string::npos)
Transformed = Transformed.substr(0, pos);
if (Transformed == ".")
Transformed.clear();
return Transformed.empty() || this->Codename == Transformed || this->Suite == Transformed;
}
/*}}}*/
APT_PURE metaIndex::checkSum *metaIndex::Lookup(string const &MetaKey) const /*{{{*/
{
std::map<std::string, metaIndex::checkSum* >::const_iterator sum = Entries.find(MetaKey);
if (sum == Entries.end())
return NULL;
return sum->second;
}
/*}}}*/
APT_PURE bool metaIndex::Exists(string const &MetaKey) const /*{{{*/
{
return Entries.find(MetaKey) != Entries.end();
}
/*}}}*/
std::vector<std::string> metaIndex::MetaKeys() const /*{{{*/
{
std::vector<std::string> keys;
std::map<string,checkSum *>::const_iterator I = Entries.begin();
while(I != Entries.end()) {
keys.push_back((*I).first);
++I;
}
return keys;
}
/*}}}*/
void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/
{
std::swap(SignedBy, OldMetaIndex->SignedBy);
std::swap(Suite, OldMetaIndex->Suite);
std::swap(Codename, OldMetaIndex->Codename);
std::swap(Date, OldMetaIndex->Date);
std::swap(ValidUntil, OldMetaIndex->ValidUntil);
std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash);
std::swap(Entries, OldMetaIndex->Entries);
std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully);
OldMetaIndex->SetOrigin(d->Origin);
OldMetaIndex->SetLabel(d->Label);
OldMetaIndex->SetVersion(d->Version);
OldMetaIndex->SetDefaultPin(d->DefaultPin);
}
/*}}}*/
bool metaIndex::IsArchitectureSupported(std::string const &arch) const /*{{{*/
{
debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this);
if (deb != NULL)
return deb->IsArchitectureSupported(arch);
return true;
}
/*}}}*/
bool metaIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) const/*{{{*/
{
debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this);
if (deb != NULL)
return deb->IsArchitectureAllSupportedFor(target);
return true;
}
/*}}}*/
bool metaIndex::HasSupportForComponent(std::string const &component) const/*{{{*/
{
debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this);
if (deb != NULL)
return deb->HasSupportForComponent(component);
return true;
}
/*}}}*/
void metaIndex::SetOrigin(std::string const &origin) { d->Origin = origin; }
void metaIndex::SetLabel(std::string const &label) { d->Label = label; }
void metaIndex::SetVersion(std::string const &version) { d->Version = version; }
void metaIndex::SetDefaultPin(signed short const defaultpin) { d->DefaultPin = defaultpin; }
void metaIndex::SetReleaseNotes(std::string const ¬es) { d->ReleaseNotes = notes; }
|