]>
Commit | Line | Data |
---|---|---|
ea542140 | 1 | #include <config.h> |
7db98ffc | 2 | |
b07aeb1a | 3 | #include <apt-pkg/error.h> |
7db98ffc MZ |
4 | #include <apt-pkg/debmetaindex.h> |
5 | #include <apt-pkg/debindexfile.h> | |
6 | #include <apt-pkg/strutl.h> | |
472ff00e | 7 | #include <apt-pkg/fileutl.h> |
7db98ffc MZ |
8 | #include <apt-pkg/acquire-item.h> |
9 | #include <apt-pkg/configuration.h> | |
45df0ad2 | 10 | #include <apt-pkg/aptconfiguration.h> |
472ff00e | 11 | #include <apt-pkg/sourcelist.h> |
453b82a3 | 12 | #include <apt-pkg/hashes.h> |
453b82a3 | 13 | #include <apt-pkg/metaindex.h> |
b07aeb1a DK |
14 | #include <apt-pkg/pkgcachegen.h> |
15 | #include <apt-pkg/tagfile.h> | |
16 | #include <apt-pkg/gpgv.h> | |
17 | #include <apt-pkg/macros.h> | |
7db98ffc | 18 | |
453b82a3 DK |
19 | #include <map> |
20 | #include <string> | |
21 | #include <utility> | |
22 | #include <vector> | |
7cb28948 | 23 | #include <algorithm> |
d7a51997 | 24 | #include <sstream> |
5dd4c8b8 | 25 | |
b07aeb1a | 26 | #include <sys/stat.h> |
b07aeb1a DK |
27 | #include <string.h> |
28 | ||
268ffceb DK |
29 | #include <apti18n.h> |
30 | ||
463c8d80 DK |
31 | class APT_HIDDEN debReleaseIndexPrivate /*{{{*/ |
32 | { | |
33 | public: | |
34 | struct APT_HIDDEN debSectionEntry | |
35 | { | |
3090ae69 | 36 | std::string sourcesEntry; |
463c8d80 DK |
37 | std::string Name; |
38 | std::vector<std::string> Targets; | |
39 | std::vector<std::string> Architectures; | |
40 | std::vector<std::string> Languages; | |
1a3a14ac | 41 | bool UsePDiffs; |
24e8f24e | 42 | std::string UseByHash; |
463c8d80 DK |
43 | }; |
44 | ||
45 | std::vector<debSectionEntry> DebEntries; | |
46 | std::vector<debSectionEntry> DebSrcEntries; | |
268ffceb | 47 | |
0741daeb DK |
48 | metaIndex::TriState CheckValidUntil; |
49 | time_t ValidUntilMin; | |
50 | time_t ValidUntilMax; | |
51 | ||
1dd20368 DK |
52 | std::vector<std::string> Architectures; |
53 | ||
0741daeb | 54 | debReleaseIndexPrivate() : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0) {} |
463c8d80 DK |
55 | }; |
56 | /*}}}*/ | |
57 | // ReleaseIndex::MetaIndex* - display helpers /*{{{*/ | |
58 | std::string debReleaseIndex::MetaIndexInfo(const char *Type) const | |
7db98ffc | 59 | { |
463c8d80 | 60 | std::string Info = ::URI::ArchiveOnly(URI) + ' '; |
7db98ffc MZ |
61 | if (Dist[Dist.size() - 1] == '/') |
62 | { | |
63 | if (Dist != "/") | |
64 | Info += Dist; | |
65 | } | |
66 | else | |
67 | Info += Dist; | |
68 | Info += " "; | |
69 | Info += Type; | |
70 | return Info; | |
71 | } | |
b07aeb1a DK |
72 | std::string debReleaseIndex::Describe() const |
73 | { | |
74 | return MetaIndexInfo("Release"); | |
75 | } | |
7db98ffc | 76 | |
463c8d80 | 77 | std::string debReleaseIndex::MetaIndexFile(const char *Type) const |
7db98ffc MZ |
78 | { |
79 | return _config->FindDir("Dir::State::lists") + | |
80 | URItoFileName(MetaIndexURI(Type)); | |
81 | } | |
82 | ||
463c8d80 | 83 | std::string debReleaseIndex::MetaIndexURI(const char *Type) const |
7db98ffc | 84 | { |
463c8d80 | 85 | std::string Res; |
7db98ffc MZ |
86 | |
87 | if (Dist == "/") | |
88 | Res = URI; | |
89 | else if (Dist[Dist.size()-1] == '/') | |
90 | Res = URI + Dist; | |
91 | else | |
92 | Res = URI + "dists/" + Dist + "/"; | |
93 | ||
94 | Res += Type; | |
95 | return Res; | |
96 | } | |
463c8d80 | 97 | /*}}}*/ |
463c8d80 DK |
98 | // ReleaseIndex Con- and Destructors /*{{{*/ |
99 | debReleaseIndex::debReleaseIndex(std::string const &URI, std::string const &Dist) : | |
268ffceb | 100 | metaIndex(URI, Dist, "deb"), d(new debReleaseIndexPrivate()) |
4b42f43b | 101 | {} |
5ad0096a DK |
102 | debReleaseIndex::debReleaseIndex(std::string const &URI, std::string const &Dist, bool const pTrusted) : |
103 | metaIndex(URI, Dist, "deb"), d(new debReleaseIndexPrivate()) | |
104 | { | |
105 | Trusted = pTrusted ? TRI_YES : TRI_NO; | |
106 | } | |
5dd4c8b8 | 107 | debReleaseIndex::~debReleaseIndex() { |
463c8d80 DK |
108 | if (d != NULL) |
109 | delete d; | |
7a9f09bd | 110 | } |
463c8d80 DK |
111 | /*}}}*/ |
112 | // ReleaseIndex::GetIndexTargets /*{{{*/ | |
113 | static void GetIndexTargetsFor(char const * const Type, std::string const &URI, std::string const &Dist, | |
114 | std::vector<debReleaseIndexPrivate::debSectionEntry> const &entries, | |
115 | std::vector<IndexTarget> &IndexTargets) | |
1e0f0f28 | 116 | { |
1e0f0f28 DK |
117 | bool const flatArchive = (Dist[Dist.length() - 1] == '/'); |
118 | std::string baseURI = URI; | |
119 | if (flatArchive) | |
120 | { | |
121 | if (Dist != "/") | |
122 | baseURI += Dist; | |
123 | } | |
124 | else | |
125 | baseURI += "dists/" + Dist + "/"; | |
126 | std::string const Release = (Dist == "/") ? "" : Dist; | |
1da3b7b8 | 127 | std::string const Site = ::URI::ArchiveOnly(URI); |
463c8d80 | 128 | |
d7a51997 DK |
129 | std::string DefCompressionTypes; |
130 | { | |
131 | std::vector<std::string> types = APT::Configuration::getCompressionTypes(); | |
132 | if (types.empty() == false) | |
133 | { | |
134 | std::ostringstream os; | |
135 | std::copy(types.begin(), types.end()-1, std::ostream_iterator<std::string>(os, " ")); | |
136 | os << *types.rbegin(); | |
137 | DefCompressionTypes = os.str(); | |
138 | } | |
139 | } | |
c4d1ab98 | 140 | std::string const NativeArch = _config->Find("APT::Architecture"); |
653ef26c | 141 | bool const GzipIndex = _config->FindB("Acquire::GzipIndexes", false); |
463c8d80 | 142 | for (std::vector<debReleaseIndexPrivate::debSectionEntry>::const_iterator E = entries.begin(); E != entries.end(); ++E) |
1e0f0f28 | 143 | { |
463c8d80 | 144 | for (std::vector<std::string>::const_iterator T = E->Targets.begin(); T != E->Targets.end(); ++T) |
1e0f0f28 | 145 | { |
d7a51997 DK |
146 | #define APT_T_CONFIG_STR(X, Y) _config->Find(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::" + (X), (Y)) |
147 | #define APT_T_CONFIG_BOOL(X, Y) _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::" + (X), (Y)) | |
148 | std::string const tplMetaKey = APT_T_CONFIG_STR(flatArchive ? "flatMetaKey" : "MetaKey", ""); | |
149 | std::string const tplShortDesc = APT_T_CONFIG_STR("ShortDescription", ""); | |
150 | std::string const tplLongDesc = "$(SITE) " + APT_T_CONFIG_STR(flatArchive ? "flatDescription" : "Description", ""); | |
151 | bool const IsOptional = APT_T_CONFIG_BOOL("Optional", true); | |
152 | bool const KeepCompressed = APT_T_CONFIG_BOOL("KeepCompressed", GzipIndex); | |
9adb9778 | 153 | bool const DefaultEnabled = APT_T_CONFIG_BOOL("DefaultEnabled", true); |
d7a51997 | 154 | bool const UsePDiffs = APT_T_CONFIG_BOOL("PDiffs", E->UsePDiffs); |
24e8f24e | 155 | std::string const UseByHash = APT_T_CONFIG_STR("By-Hash", E->UseByHash); |
d7a51997 DK |
156 | std::string const CompressionTypes = APT_T_CONFIG_STR("CompressionTypes", DefCompressionTypes); |
157 | #undef APT_T_CONFIG_BOOL | |
158 | #undef APT_T_CONFIG_STR | |
463c8d80 | 159 | if (tplMetaKey.empty()) |
1e0f0f28 DK |
160 | continue; |
161 | ||
463c8d80 | 162 | for (std::vector<std::string>::const_iterator L = E->Languages.begin(); L != E->Languages.end(); ++L) |
1e0f0f28 | 163 | { |
463c8d80 DK |
164 | if (*L == "none" && tplMetaKey.find("$(LANGUAGE)") != std::string::npos) |
165 | continue; | |
166 | ||
167 | for (std::vector<std::string>::const_iterator A = E->Architectures.begin(); A != E->Architectures.end(); ++A) | |
1e0f0f28 | 168 | { |
d7a51997 | 169 | // available in templates |
d3a869e3 DK |
170 | std::map<std::string, std::string> Options; |
171 | Options.insert(std::make_pair("SITE", Site)); | |
172 | Options.insert(std::make_pair("RELEASE", Release)); | |
463c8d80 DK |
173 | if (tplMetaKey.find("$(COMPONENT)") != std::string::npos) |
174 | Options.insert(std::make_pair("COMPONENT", E->Name)); | |
175 | if (tplMetaKey.find("$(LANGUAGE)") != std::string::npos) | |
176 | Options.insert(std::make_pair("LANGUAGE", *L)); | |
177 | if (tplMetaKey.find("$(ARCHITECTURE)") != std::string::npos) | |
178 | Options.insert(std::make_pair("ARCHITECTURE", *A)); | |
c4d1ab98 DK |
179 | else if (tplMetaKey.find("$(NATIVE_ARCHITECTURE)") != std::string::npos) |
180 | Options.insert(std::make_pair("ARCHITECTURE", NativeArch)); | |
181 | if (tplMetaKey.find("$(NATIVE_ARCHITECTURE)") != std::string::npos) | |
182 | Options.insert(std::make_pair("NATIVE_ARCHITECTURE", NativeArch)); | |
d3a869e3 | 183 | |
463c8d80 DK |
184 | std::string MetaKey = tplMetaKey; |
185 | std::string ShortDesc = tplShortDesc; | |
186 | std::string LongDesc = tplLongDesc; | |
187 | for (std::map<std::string, std::string>::const_iterator O = Options.begin(); O != Options.end(); ++O) | |
188 | { | |
189 | MetaKey = SubstVar(MetaKey, std::string("$(") + O->first + ")", O->second); | |
190 | ShortDesc = SubstVar(ShortDesc, std::string("$(") + O->first + ")", O->second); | |
191 | LongDesc = SubstVar(LongDesc, std::string("$(") + O->first + ")", O->second); | |
192 | } | |
d7a51997 | 193 | |
3090ae69 DK |
194 | { |
195 | auto const dup = std::find_if(IndexTargets.begin(), IndexTargets.end(), [&](IndexTarget const &IT) { | |
196 | return MetaKey == IT.MetaKey && baseURI == IT.Option(IndexTarget::BASE_URI) && | |
197 | E->sourcesEntry == IT.Option(IndexTarget::SOURCESENTRY) && *T == IT.Option(IndexTarget::CREATED_BY); | |
198 | }); | |
199 | if (dup != IndexTargets.end()) | |
200 | { | |
201 | if (tplMetaKey.find("$(ARCHITECTURE)") == std::string::npos) | |
202 | break; | |
203 | continue; | |
204 | } | |
205 | } | |
206 | ||
207 | { | |
208 | auto const dup = std::find_if(IndexTargets.begin(), IndexTargets.end(), [&](IndexTarget const &IT) { | |
209 | return MetaKey == IT.MetaKey && baseURI == IT.Option(IndexTarget::BASE_URI) && | |
210 | E->sourcesEntry == IT.Option(IndexTarget::SOURCESENTRY) && *T != IT.Option(IndexTarget::CREATED_BY); | |
211 | }); | |
212 | if (dup != IndexTargets.end()) | |
213 | { | |
214 | std::string const dupT = dup->Option(IndexTarget::CREATED_BY); | |
215 | std::string const dupEntry = dup->Option(IndexTarget::SOURCESENTRY); | |
216 | //TRANSLATOR: an identifier like Packages; Releasefile key indicating | |
217 | // a file like main/binary-amd64/Packages; another identifier like Contents; | |
218 | // filename and linenumber of the sources.list entry currently parsed | |
219 | _error->Warning(_("Target %s wants to acquire the same file (%s) as %s from source %s"), | |
220 | T->c_str(), MetaKey.c_str(), dupT.c_str(), dupEntry.c_str()); | |
221 | if (tplMetaKey.find("$(ARCHITECTURE)") == std::string::npos) | |
222 | break; | |
223 | continue; | |
224 | } | |
225 | } | |
226 | ||
227 | { | |
228 | auto const dup = std::find_if(IndexTargets.begin(), IndexTargets.end(), [&](IndexTarget const &T) { | |
229 | return MetaKey == T.MetaKey && baseURI == T.Option(IndexTarget::BASE_URI) && | |
230 | E->sourcesEntry != T.Option(IndexTarget::SOURCESENTRY); | |
231 | }); | |
232 | if (dup != IndexTargets.end()) | |
233 | { | |
234 | std::string const dupEntry = dup->Option(IndexTarget::SOURCESENTRY); | |
235 | //TRANSLATOR: an identifier like Packages; Releasefile key indicating | |
236 | // a file like main/binary-amd64/Packages; filename and linenumber of | |
237 | // two sources.list entries | |
238 | _error->Warning(_("Target %s (%s) is configured multiple times in %s and %s"), | |
239 | T->c_str(), MetaKey.c_str(), dupEntry.c_str(), E->sourcesEntry.c_str()); | |
240 | if (tplMetaKey.find("$(ARCHITECTURE)") == std::string::npos) | |
241 | break; | |
242 | continue; | |
243 | } | |
244 | } | |
245 | ||
d7a51997 DK |
246 | // not available in templates, but in the indextarget |
247 | Options.insert(std::make_pair("BASE_URI", baseURI)); | |
248 | Options.insert(std::make_pair("REPO_URI", URI)); | |
249 | Options.insert(std::make_pair("TARGET_OF", Type)); | |
250 | Options.insert(std::make_pair("CREATED_BY", *T)); | |
9adb9778 | 251 | Options.insert(std::make_pair("PDIFFS", UsePDiffs ? "yes" : "no")); |
24e8f24e | 252 | Options.insert(std::make_pair("BY_HASH", UseByHash)); |
9adb9778 | 253 | Options.insert(std::make_pair("DEFAULTENABLED", DefaultEnabled ? "yes" : "no")); |
d7a51997 | 254 | Options.insert(std::make_pair("COMPRESSIONTYPES", CompressionTypes)); |
3090ae69 | 255 | Options.insert(std::make_pair("SOURCESENTRY", E->sourcesEntry)); |
d7a51997 | 256 | |
1dd20368 DK |
257 | bool IsOpt = IsOptional; |
258 | if (IsOpt == false) | |
259 | { | |
260 | auto const arch = Options.find("ARCHITECTURE"); | |
261 | if (arch != Options.end() && arch->second == "all") | |
262 | IsOpt = true; | |
263 | } | |
264 | ||
463c8d80 DK |
265 | IndexTarget Target( |
266 | MetaKey, | |
267 | ShortDesc, | |
268 | LongDesc, | |
269 | Options.find("BASE_URI")->second + MetaKey, | |
1dd20368 | 270 | IsOpt, |
653ef26c | 271 | KeepCompressed, |
463c8d80 DK |
272 | Options |
273 | ); | |
274 | IndexTargets.push_back(Target); | |
275 | ||
276 | if (tplMetaKey.find("$(ARCHITECTURE)") == std::string::npos) | |
1e0f0f28 | 277 | break; |
d3a869e3 | 278 | |
1e0f0f28 DK |
279 | } |
280 | ||
463c8d80 | 281 | if (tplMetaKey.find("$(LANGUAGE)") == std::string::npos) |
1e0f0f28 | 282 | break; |
463c8d80 | 283 | |
1e0f0f28 DK |
284 | } |
285 | ||
1e0f0f28 DK |
286 | } |
287 | } | |
59148d96 | 288 | } |
261727f0 | 289 | std::vector<IndexTarget> debReleaseIndex::GetIndexTargets() const |
59148d96 | 290 | { |
463c8d80 DK |
291 | std::vector<IndexTarget> IndexTargets; |
292 | GetIndexTargetsFor("deb-src", URI, Dist, d->DebSrcEntries, IndexTargets); | |
293 | GetIndexTargetsFor("deb", URI, Dist, d->DebEntries, IndexTargets); | |
294 | return IndexTargets; | |
7db98ffc | 295 | } |
463c8d80 | 296 | /*}}}*/ |
3090ae69 DK |
297 | void debReleaseIndex::AddComponent(std::string const &sourcesEntry, /*{{{*/ |
298 | bool const isSrc, std::string const &Name, | |
463c8d80 DK |
299 | std::vector<std::string> const &Targets, |
300 | std::vector<std::string> const &Architectures, | |
1a3a14ac | 301 | std::vector<std::string> Languages, |
24e8f24e | 302 | bool const usePDiffs, std::string const &useByHash) |
463c8d80 DK |
303 | { |
304 | if (Languages.empty() == true) | |
305 | Languages.push_back("none"); | |
306 | debReleaseIndexPrivate::debSectionEntry const entry = { | |
24e8f24e | 307 | sourcesEntry, Name, Targets, Architectures, Languages, usePDiffs, useByHash |
463c8d80 DK |
308 | }; |
309 | if (isSrc) | |
310 | d->DebSrcEntries.push_back(entry); | |
311 | else | |
312 | d->DebEntries.push_back(entry); | |
313 | } | |
314 | /*}}}*/ | |
59148d96 | 315 | |
5ad0096a DK |
316 | bool debReleaseIndex::Load(std::string const &Filename, std::string * const ErrorText)/*{{{*/ |
317 | { | |
318 | LoadedSuccessfully = TRI_NO; | |
319 | FileFd Fd; | |
320 | if (OpenMaybeClearSignedFile(Filename, Fd) == false) | |
321 | return false; | |
322 | ||
323 | pkgTagFile TagFile(&Fd, Fd.Size()); | |
95278287 | 324 | if (Fd.IsOpen() == false || Fd.Failed()) |
5ad0096a DK |
325 | { |
326 | if (ErrorText != NULL) | |
327 | strprintf(*ErrorText, _("Unable to parse Release file %s"),Filename.c_str()); | |
328 | return false; | |
329 | } | |
330 | ||
331 | pkgTagSection Section; | |
332 | const char *Start, *End; | |
333 | if (TagFile.Step(Section) == false) | |
334 | { | |
335 | if (ErrorText != NULL) | |
336 | strprintf(*ErrorText, _("No sections in Release file %s"), Filename.c_str()); | |
337 | return false; | |
338 | } | |
339 | // FIXME: find better tag name | |
340 | SupportsAcquireByHash = Section.FindB("Acquire-By-Hash", false); | |
341 | ||
342 | Suite = Section.FindS("Suite"); | |
343 | Codename = Section.FindS("Codename"); | |
1dd20368 DK |
344 | { |
345 | std::string const archs = Section.FindS("Architectures"); | |
346 | if (archs.empty() == false) | |
347 | d->Architectures = VectorizeString(archs, ' '); | |
348 | } | |
5ad0096a DK |
349 | |
350 | bool FoundHashSum = false; | |
bd4a8f51 DK |
351 | bool FoundStrongHashSum = false; |
352 | auto const SupportedHashes = HashString::SupportedHashes(); | |
353 | for (int i=0; SupportedHashes[i] != NULL; i++) | |
5ad0096a | 354 | { |
bd4a8f51 | 355 | if (!Section.Find(SupportedHashes[i], Start, End)) |
5ad0096a DK |
356 | continue; |
357 | ||
358 | std::string Name; | |
359 | std::string Hash; | |
360 | unsigned long long Size; | |
361 | while (Start < End) | |
362 | { | |
363 | if (!parseSumData(Start, End, Name, Hash, Size)) | |
364 | return false; | |
365 | ||
bd4a8f51 | 366 | HashString const hs(SupportedHashes[i], Hash); |
5ad0096a DK |
367 | if (Entries.find(Name) == Entries.end()) |
368 | { | |
369 | metaIndex::checkSum *Sum = new metaIndex::checkSum; | |
370 | Sum->MetaKeyFilename = Name; | |
371 | Sum->Size = Size; | |
372 | Sum->Hashes.FileSize(Size); | |
bd4a8f51 | 373 | APT_IGNORE_DEPRECATED(Sum->Hash = hs;) |
5ad0096a DK |
374 | Entries[Name] = Sum; |
375 | } | |
bd4a8f51 | 376 | Entries[Name]->Hashes.push_back(hs); |
5ad0096a | 377 | FoundHashSum = true; |
bd4a8f51 DK |
378 | if (FoundStrongHashSum == false && hs.usable() == true) |
379 | FoundStrongHashSum = true; | |
5ad0096a DK |
380 | } |
381 | } | |
382 | ||
383 | if(FoundHashSum == false) | |
384 | { | |
385 | if (ErrorText != NULL) | |
386 | strprintf(*ErrorText, _("No Hash entry in Release file %s"), Filename.c_str()); | |
387 | return false; | |
388 | } | |
bd4a8f51 DK |
389 | if(FoundStrongHashSum == false) |
390 | { | |
391 | if (ErrorText != NULL) | |
392 | strprintf(*ErrorText, _("No Hash entry in Release file %s, which is considered strong enough for security purposes"), Filename.c_str()); | |
393 | return false; | |
394 | } | |
5ad0096a DK |
395 | |
396 | std::string const StrDate = Section.FindS("Date"); | |
397 | if (RFC1123StrToTime(StrDate.c_str(), Date) == false) | |
398 | { | |
399 | if (ErrorText != NULL) | |
400 | strprintf(*ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str()); | |
401 | return false; | |
402 | } | |
403 | ||
0741daeb DK |
404 | bool CheckValidUntil = _config->FindB("Acquire::Check-Valid-Until", true); |
405 | if (d->CheckValidUntil == metaIndex::TRI_NO) | |
406 | CheckValidUntil = false; | |
407 | else if (d->CheckValidUntil == metaIndex::TRI_YES) | |
408 | CheckValidUntil = true; | |
5ad0096a | 409 | |
0741daeb | 410 | if (CheckValidUntil == true) |
5ad0096a | 411 | { |
0741daeb DK |
412 | std::string const Label = Section.FindS("Label"); |
413 | std::string const StrValidUntil = Section.FindS("Valid-Until"); | |
414 | ||
415 | // if we have a Valid-Until header in the Release file, use it as default | |
416 | if (StrValidUntil.empty() == false) | |
5ad0096a | 417 | { |
0741daeb DK |
418 | if(RFC1123StrToTime(StrValidUntil.c_str(), ValidUntil) == false) |
419 | { | |
420 | if (ErrorText != NULL) | |
421 | strprintf(*ErrorText, _("Invalid 'Valid-Until' entry in Release file %s"), Filename.c_str()); | |
422 | return false; | |
423 | } | |
424 | } | |
425 | // get the user settings for this archive and use what expires earlier | |
426 | time_t MaxAge = d->ValidUntilMax; | |
427 | if (MaxAge == 0) | |
428 | { | |
429 | MaxAge = _config->FindI("Acquire::Max-ValidTime", 0); | |
430 | if (Label.empty() == false) | |
431 | MaxAge = _config->FindI(("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); | |
432 | } | |
433 | time_t MinAge = d->ValidUntilMin; | |
434 | if (MinAge == 0) | |
435 | { | |
436 | MinAge = _config->FindI("Acquire::Min-ValidTime", 0); | |
437 | if (Label.empty() == false) | |
438 | MinAge = _config->FindI(("Acquire::Min-ValidTime::" + Label).c_str(), MinAge); | |
5ad0096a | 439 | } |
5ad0096a | 440 | |
0741daeb DK |
441 | if (MinAge != 0 && ValidUntil != 0) { |
442 | time_t const min_date = Date + MinAge; | |
443 | if (ValidUntil < min_date) | |
444 | ValidUntil = min_date; | |
445 | } | |
446 | if (MaxAge != 0) { | |
447 | time_t const max_date = Date + MaxAge; | |
448 | if (ValidUntil == 0 || ValidUntil > max_date) | |
449 | ValidUntil = max_date; | |
450 | } | |
5ad0096a | 451 | } |
59148d96 | 452 | |
0741daeb | 453 | LoadedSuccessfully = TRI_YES; |
5ad0096a DK |
454 | return true; |
455 | } | |
456 | /*}}}*/ | |
457 | metaIndex * debReleaseIndex::UnloadedClone() const /*{{{*/ | |
458 | { | |
459 | if (Trusted == TRI_NO) | |
460 | return new debReleaseIndex(URI, Dist, false); | |
461 | else if (Trusted == TRI_YES) | |
462 | return new debReleaseIndex(URI, Dist, true); | |
463 | else | |
464 | return new debReleaseIndex(URI, Dist); | |
465 | } | |
466 | /*}}}*/ | |
467 | bool debReleaseIndex::parseSumData(const char *&Start, const char *End, /*{{{*/ | |
468 | std::string &Name, std::string &Hash, unsigned long long &Size) | |
7db98ffc | 469 | { |
5ad0096a DK |
470 | Name = ""; |
471 | Hash = ""; | |
472 | Size = 0; | |
473 | /* Skip over the first blank */ | |
474 | while ((*Start == '\t' || *Start == ' ' || *Start == '\n' || *Start == '\r') | |
475 | && Start < End) | |
476 | Start++; | |
477 | if (Start >= End) | |
478 | return false; | |
07cb47e7 | 479 | |
5ad0096a DK |
480 | /* Move EntryEnd to the end of the first entry (the hash) */ |
481 | const char *EntryEnd = Start; | |
482 | while ((*EntryEnd != '\t' && *EntryEnd != ' ') | |
483 | && EntryEnd < End) | |
484 | EntryEnd++; | |
485 | if (EntryEnd == End) | |
486 | return false; | |
487 | ||
488 | Hash.append(Start, EntryEnd-Start); | |
489 | ||
490 | /* Skip over intermediate blanks */ | |
491 | Start = EntryEnd; | |
492 | while (*Start == '\t' || *Start == ' ') | |
493 | Start++; | |
494 | if (Start >= End) | |
495 | return false; | |
496 | ||
497 | EntryEnd = Start; | |
498 | /* Find the end of the second entry (the size) */ | |
499 | while ((*EntryEnd != '\t' && *EntryEnd != ' ' ) | |
500 | && EntryEnd < End) | |
501 | EntryEnd++; | |
502 | if (EntryEnd == End) | |
503 | return false; | |
504 | ||
505 | Size = strtoull (Start, NULL, 10); | |
506 | ||
507 | /* Skip over intermediate blanks */ | |
508 | Start = EntryEnd; | |
509 | while (*Start == '\t' || *Start == ' ') | |
510 | Start++; | |
511 | if (Start >= End) | |
512 | return false; | |
513 | ||
514 | EntryEnd = Start; | |
515 | /* Find the end of the third entry (the filename) */ | |
516 | while ((*EntryEnd != '\t' && *EntryEnd != ' ' && | |
517 | *EntryEnd != '\n' && *EntryEnd != '\r') | |
518 | && EntryEnd < End) | |
519 | EntryEnd++; | |
520 | ||
521 | Name.append(Start, EntryEnd-Start); | |
522 | Start = EntryEnd; //prepare for the next round | |
523 | return true; | |
524 | } | |
525 | /*}}}*/ | |
526 | ||
527 | bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll)/*{{{*/ | |
528 | { | |
261727f0 | 529 | std::vector<IndexTarget> const targets = GetIndexTargets(); |
653ef26c | 530 | #define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, false, std::map<std::string,std::string>()) |
3d8232bf | 531 | pkgAcqMetaClearSig * const TransactionManager = new pkgAcqMetaClearSig(Owner, |
448c38bd | 532 | APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"), |
5ad0096a | 533 | targets, this); |
448c38bd | 534 | #undef APT_TARGET |
5ad0096a | 535 | // special case for --print-uris |
448c38bd | 536 | if (GetAll) |
8dd562a8 DK |
537 | for (auto const &Target: targets) |
538 | new pkgAcqIndex(Owner, TransactionManager, Target); | |
fe0f7911 | 539 | |
55971004 | 540 | return true; |
7db98ffc | 541 | } |
463c8d80 | 542 | /*}}}*/ |
0741daeb | 543 | // ReleaseIndex::Set* TriState options /*{{{*/ |
5ad0096a | 544 | bool debReleaseIndex::SetTrusted(TriState const pTrusted) |
4b42f43b | 545 | { |
5ad0096a DK |
546 | if (Trusted == TRI_UNSET) |
547 | Trusted = pTrusted; | |
548 | else if (Trusted != pTrusted) | |
268ffceb | 549 | // TRANSLATOR: The first is an option name from sources.list manpage, the other two URI and Suite |
d04e44ac | 550 | return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Trusted", URI.c_str(), Dist.c_str()); |
268ffceb | 551 | return true; |
4b42f43b | 552 | } |
0741daeb DK |
553 | bool debReleaseIndex::SetCheckValidUntil(TriState const pCheckValidUntil) |
554 | { | |
555 | if (d->CheckValidUntil == TRI_UNSET) | |
556 | d->CheckValidUntil = pCheckValidUntil; | |
557 | else if (d->CheckValidUntil != pCheckValidUntil) | |
d04e44ac | 558 | return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Check-Valid-Until", URI.c_str(), Dist.c_str()); |
0741daeb DK |
559 | return true; |
560 | } | |
561 | bool debReleaseIndex::SetValidUntilMin(time_t const Valid) | |
562 | { | |
563 | if (d->ValidUntilMin == 0) | |
564 | d->ValidUntilMin = Valid; | |
565 | else if (d->ValidUntilMin != Valid) | |
d04e44ac | 566 | return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Min-ValidTime", URI.c_str(), Dist.c_str()); |
0741daeb DK |
567 | return true; |
568 | } | |
569 | bool debReleaseIndex::SetValidUntilMax(time_t const Valid) | |
570 | { | |
571 | if (d->ValidUntilMax == 0) | |
572 | d->ValidUntilMax = Valid; | |
573 | else if (d->ValidUntilMax != Valid) | |
d04e44ac | 574 | return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Max-ValidTime", URI.c_str(), Dist.c_str()); |
0741daeb | 575 | return true; |
b0d40854 DK |
576 | } |
577 | bool debReleaseIndex::SetSignedBy(std::string const &pSignedBy) | |
578 | { | |
579 | if (SignedBy.empty() == true && pSignedBy.empty() == false) | |
580 | { | |
581 | if (pSignedBy[0] == '/') // no check for existence as we could be chrooting later or such things | |
582 | ; // absolute path to a keyring file | |
583 | else | |
584 | { | |
585 | // we could go all fancy and allow short/long/string matches as gpgv/apt-key does, | |
586 | // but fingerprints are harder to fake than the others and this option is set once, | |
587 | // not interactively all the time so easy to type is not really a concern. | |
588 | std::string finger = pSignedBy; | |
589 | finger.erase(std::remove(finger.begin(), finger.end(), ' '), finger.end()); | |
590 | std::transform(finger.begin(), finger.end(), finger.begin(), ::toupper); | |
591 | if (finger.length() != 40 || finger.find_first_not_of("0123456789ABCDEF") != std::string::npos) | |
d04e44ac | 592 | return _error->Error(_("Invalid value set for option %s regarding source %s %s (%s)"), "Signed-By", URI.c_str(), Dist.c_str(), "not a fingerprint"); |
b0d40854 DK |
593 | } |
594 | SignedBy = pSignedBy; | |
595 | } | |
596 | else if (SignedBy != pSignedBy) | |
d04e44ac | 597 | return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Signed-By", URI.c_str(), Dist.c_str()); |
b0d40854 | 598 | return true; |
0741daeb DK |
599 | } |
600 | /*}}}*/ | |
601 | // ReleaseIndex::IsTrusted /*{{{*/ | |
7db98ffc MZ |
602 | bool debReleaseIndex::IsTrusted() const |
603 | { | |
5ad0096a | 604 | if (Trusted == TRI_YES) |
4b42f43b | 605 | return true; |
5ad0096a | 606 | else if (Trusted == TRI_NO) |
4b42f43b DK |
607 | return false; |
608 | ||
609 | ||
4e0ad446 | 610 | if(_config->FindB("APT::Authentication::TrustCDROM", false)) |
e8cdc56a MV |
611 | if(URI.substr(0,strlen("cdrom:")) == "cdrom:") |
612 | return true; | |
fe0f7911 | 613 | |
463c8d80 | 614 | if (FileExists(MetaIndexFile("Release.gpg"))) |
7db98ffc | 615 | return true; |
fe0f7911 | 616 | |
463c8d80 | 617 | return FileExists(MetaIndexFile("InRelease")); |
7db98ffc | 618 | } |
463c8d80 | 619 | /*}}}*/ |
1dd20368 DK |
620 | bool debReleaseIndex::IsArchitectureSupported(std::string const &arch) const/*{{{*/ |
621 | { | |
622 | if (d->Architectures.empty()) | |
623 | return true; | |
624 | return std::find(d->Architectures.begin(), d->Architectures.end(), arch) != d->Architectures.end(); | |
625 | } | |
626 | /*}}}*/ | |
463c8d80 | 627 | std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() /*{{{*/ |
59148d96 | 628 | { |
e3c1cfc7 DK |
629 | if (Indexes != NULL) |
630 | return Indexes; | |
59148d96 | 631 | |
e3c1cfc7 | 632 | Indexes = new std::vector<pkgIndexFile*>(); |
e3c1cfc7 | 633 | bool const istrusted = IsTrusted(); |
8dd562a8 | 634 | for (auto const &T: GetIndexTargets()) |
59148d96 | 635 | { |
8dd562a8 | 636 | std::string const TargetName = T.Option(IndexTarget::CREATED_BY); |
59148d96 | 637 | if (TargetName == "Packages") |
8dd562a8 | 638 | Indexes->push_back(new debPackagesIndex(T, istrusted)); |
59148d96 | 639 | else if (TargetName == "Sources") |
8dd562a8 | 640 | Indexes->push_back(new debSourcesIndex(T, istrusted)); |
59148d96 | 641 | else if (TargetName == "Translations") |
8dd562a8 | 642 | Indexes->push_back(new debTranslationsIndex(T)); |
59148d96 | 643 | } |
e3c1cfc7 | 644 | return Indexes; |
5dd4c8b8 | 645 | } |
463c8d80 | 646 | /*}}}*/ |
a7a5b0d9 | 647 | |
463c8d80 | 648 | static bool ReleaseFileName(debReleaseIndex const * const That, std::string &ReleaseFile)/*{{{*/ |
b07aeb1a DK |
649 | { |
650 | ReleaseFile = That->MetaIndexFile("InRelease"); | |
651 | bool releaseExists = false; | |
652 | if (FileExists(ReleaseFile) == true) | |
653 | releaseExists = true; | |
654 | else | |
655 | { | |
656 | ReleaseFile = That->MetaIndexFile("Release"); | |
657 | if (FileExists(ReleaseFile)) | |
658 | releaseExists = true; | |
659 | } | |
660 | return releaseExists; | |
661 | } | |
463c8d80 | 662 | /*}}}*/ |
b07aeb1a DK |
663 | bool debReleaseIndex::Merge(pkgCacheGenerator &Gen,OpProgress * /*Prog*/) const/*{{{*/ |
664 | { | |
665 | std::string ReleaseFile; | |
666 | bool const releaseExists = ReleaseFileName(this, ReleaseFile); | |
667 | ||
668 | ::URI Tmp(URI); | |
669 | if (Gen.SelectReleaseFile(ReleaseFile, Tmp.Host) == false) | |
670 | return _error->Error("Problem with SelectReleaseFile %s", ReleaseFile.c_str()); | |
671 | ||
672 | if (releaseExists == false) | |
673 | return true; | |
674 | ||
675 | FileFd Rel; | |
676 | // Beware: The 'Release' file might be clearsigned in case the | |
677 | // signature for an 'InRelease' file couldn't be checked | |
678 | if (OpenMaybeClearSignedFile(ReleaseFile, Rel) == false) | |
679 | return false; | |
b07aeb1a DK |
680 | |
681 | // Store the IMS information | |
682 | pkgCache::RlsFileIterator File = Gen.GetCurRlsFile(); | |
683 | pkgCacheGenerator::Dynamic<pkgCache::RlsFileIterator> DynFile(File); | |
684 | // Rel can't be used as this is potentially a temporary file | |
685 | struct stat Buf; | |
686 | if (stat(ReleaseFile.c_str(), &Buf) != 0) | |
687 | return _error->Errno("fstat", "Unable to stat file %s", ReleaseFile.c_str()); | |
688 | File->Size = Buf.st_size; | |
689 | File->mtime = Buf.st_mtime; | |
690 | ||
691 | pkgTagFile TagFile(&Rel, Rel.Size()); | |
692 | pkgTagSection Section; | |
95278287 | 693 | if (Rel.IsOpen() == false || Rel.Failed() || TagFile.Step(Section) == false) |
b07aeb1a DK |
694 | return false; |
695 | ||
696 | std::string data; | |
697 | #define APT_INRELEASE(TYPE, TAG, STORE) \ | |
698 | data = Section.FindS(TAG); \ | |
699 | if (data.empty() == false) \ | |
700 | { \ | |
701 | map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::TYPE, data); \ | |
95278287 | 702 | if (storage == 0) return false; \ |
b07aeb1a DK |
703 | STORE = storage; \ |
704 | } | |
705 | APT_INRELEASE(MIXED, "Suite", File->Archive) | |
706 | APT_INRELEASE(VERSIONNUMBER, "Version", File->Version) | |
707 | APT_INRELEASE(MIXED, "Origin", File->Origin) | |
708 | APT_INRELEASE(MIXED, "Codename", File->Codename) | |
709 | APT_INRELEASE(MIXED, "Label", File->Label) | |
710 | #undef APT_INRELEASE | |
711 | Section.FindFlag("NotAutomatic", File->Flags, pkgCache::Flag::NotAutomatic); | |
712 | Section.FindFlag("ButAutomaticUpgrades", File->Flags, pkgCache::Flag::ButAutomaticUpgrades); | |
713 | ||
95278287 | 714 | return true; |
b07aeb1a DK |
715 | } |
716 | /*}}}*/ | |
717 | // ReleaseIndex::FindInCache - Find this index /*{{{*/ | |
3fd89e62 | 718 | pkgCache::RlsFileIterator debReleaseIndex::FindInCache(pkgCache &Cache, bool const ModifyCheck) const |
b07aeb1a DK |
719 | { |
720 | std::string ReleaseFile; | |
721 | bool const releaseExists = ReleaseFileName(this, ReleaseFile); | |
722 | ||
723 | pkgCache::RlsFileIterator File = Cache.RlsFileBegin(); | |
724 | for (; File.end() == false; ++File) | |
725 | { | |
726 | if (File->FileName == 0 || ReleaseFile != File.FileName()) | |
727 | continue; | |
728 | ||
729 | // empty means the file does not exist by "design" | |
3fd89e62 | 730 | if (ModifyCheck == false || (releaseExists == false && File->Size == 0)) |
b07aeb1a DK |
731 | return File; |
732 | ||
733 | struct stat St; | |
734 | if (stat(File.FileName(),&St) != 0) | |
735 | { | |
736 | if (_config->FindB("Debug::pkgCacheGen", false)) | |
737 | std::clog << "ReleaseIndex::FindInCache - stat failed on " << File.FileName() << std::endl; | |
738 | return pkgCache::RlsFileIterator(Cache); | |
739 | } | |
740 | if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime) | |
741 | { | |
742 | if (_config->FindB("Debug::pkgCacheGen", false)) | |
743 | std::clog << "ReleaseIndex::FindInCache - size (" << St.st_size << " <> " << File->Size | |
744 | << ") or mtime (" << St.st_mtime << " <> " << File->mtime | |
745 | << ") doesn't match for " << File.FileName() << std::endl; | |
746 | return pkgCache::RlsFileIterator(Cache); | |
747 | } | |
748 | return File; | |
749 | } | |
750 | ||
751 | return File; | |
752 | } | |
753 | /*}}}*/ | |
754 | ||
463c8d80 DK |
755 | static std::vector<std::string> parsePlusMinusOptions(std::string const &Name, /*{{{*/ |
756 | std::map<std::string, std::string> const &Options, std::vector<std::string> const &defaultValues) | |
7db98ffc | 757 | { |
463c8d80 DK |
758 | std::map<std::string, std::string>::const_iterator val = Options.find(Name); |
759 | std::vector<std::string> Values; | |
760 | if (val != Options.end()) | |
761 | Values = VectorizeString(val->second, ','); | |
762 | else | |
763 | Values = defaultValues; | |
7db98ffc | 764 | |
1dd20368 DK |
765 | // all is a very special architecture users shouldn't be concerned with explicitly |
766 | if (Name == "arch" && std::find(Values.begin(), Values.end(), "all") == Values.end()) | |
767 | Values.push_back("all"); | |
768 | ||
463c8d80 | 769 | if ((val = Options.find(Name + "+")) != Options.end()) |
7db98ffc | 770 | { |
8dd562a8 DK |
771 | std::vector<std::string> const plus = VectorizeString(val->second, ','); |
772 | std::copy_if(plus.begin(), plus.end(), std::back_inserter(Values), [&Values](std::string const &v) { | |
773 | return std::find(Values.begin(), Values.end(), v) == Values.end(); | |
774 | }); | |
463c8d80 DK |
775 | } |
776 | if ((val = Options.find(Name + "-")) != Options.end()) | |
777 | { | |
8dd562a8 DK |
778 | std::vector<std::string> const minus = VectorizeString(val->second, ','); |
779 | Values.erase(std::remove_if(Values.begin(), Values.end(), [&minus](std::string const &v) { | |
780 | return std::find(minus.begin(), minus.end(), v) != minus.end(); | |
781 | }), Values.end()); | |
463c8d80 DK |
782 | } |
783 | return Values; | |
784 | } | |
785 | /*}}}*/ | |
786 | class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ | |
787 | { | |
0741daeb DK |
788 | metaIndex::TriState GetTriStateOption(std::map<std::string, std::string>const &Options, char const * const name) const |
789 | { | |
790 | std::map<std::string, std::string>::const_iterator const opt = Options.find(name); | |
791 | if (opt != Options.end()) | |
792 | return StringToBool(opt->second, false) ? metaIndex::TRI_YES : metaIndex::TRI_NO; | |
793 | return metaIndex::TRI_DONTCARE; | |
794 | } | |
795 | ||
796 | time_t GetTimeOption(std::map<std::string, std::string>const &Options, char const * const name) const | |
797 | { | |
798 | std::map<std::string, std::string>::const_iterator const opt = Options.find(name); | |
799 | if (opt == Options.end()) | |
800 | return 0; | |
801 | return strtoull(opt->second.c_str(), NULL, 10); | |
802 | } | |
803 | ||
463c8d80 | 804 | protected: |
3d1be93d | 805 | |
463c8d80 DK |
806 | bool CreateItemInternal(std::vector<metaIndex *> &List, std::string const &URI, |
807 | std::string const &Dist, std::string const &Section, | |
808 | bool const &IsSrc, std::map<std::string, std::string> const &Options) const | |
809 | { | |
261727f0 | 810 | debReleaseIndex *Deb = NULL; |
463c8d80 | 811 | for (std::vector<metaIndex *>::const_iterator I = List.begin(); |
f7f0d6c7 | 812 | I != List.end(); ++I) |
7db98ffc | 813 | { |
5dd4c8b8 DK |
814 | // We only worry about debian entries here |
815 | if (strcmp((*I)->GetType(), "deb") != 0) | |
816 | continue; | |
817 | ||
5dd4c8b8 DK |
818 | /* This check insures that there will be only one Release file |
819 | queued for all the Packages files and Sources files it | |
820 | corresponds to. */ | |
261727f0 | 821 | if ((*I)->GetURI() == URI && (*I)->GetDist() == Dist) |
7db98ffc | 822 | { |
261727f0 DK |
823 | Deb = dynamic_cast<debReleaseIndex*>(*I); |
824 | if (Deb != NULL) | |
825 | break; | |
7db98ffc MZ |
826 | } |
827 | } | |
4b42f43b | 828 | |
7db98ffc | 829 | // No currently created Release file indexes this entry, so we create a new one. |
261727f0 DK |
830 | if (Deb == NULL) |
831 | { | |
4b42f43b | 832 | Deb = new debReleaseIndex(URI, Dist); |
261727f0 DK |
833 | List.push_back(Deb); |
834 | } | |
4b42f43b | 835 | |
e6a12ff7 | 836 | std::vector<std::string> const alltargets = _config->FindVector(std::string("Acquire::IndexTargets::") + Name, "", true); |
9adb9778 DK |
837 | std::vector<std::string> deftargets; |
838 | deftargets.reserve(alltargets.size()); | |
839 | std::copy_if(alltargets.begin(), alltargets.end(), std::back_inserter(deftargets), [&](std::string const &t) { | |
840 | std::string c = "Acquire::IndexTargets::"; | |
841 | c.append(Name).append("::").append(t).append("::DefaultEnabled"); | |
842 | return _config->FindB(c, true); | |
843 | }); | |
844 | std::vector<std::string> mytargets = parsePlusMinusOptions("target", Options, deftargets); | |
8dd562a8 DK |
845 | for (auto const &target : alltargets) |
846 | { | |
847 | std::map<std::string, std::string>::const_iterator const opt = Options.find(target); | |
848 | if (opt == Options.end()) | |
849 | continue; | |
850 | auto const tarItr = std::find(mytargets.begin(), mytargets.end(), target); | |
851 | bool const optValue = StringToBool(opt->second); | |
852 | if (optValue == true && tarItr == mytargets.end()) | |
853 | mytargets.push_back(target); | |
854 | else if (optValue == false && tarItr != mytargets.end()) | |
855 | mytargets.erase(std::remove(mytargets.begin(), mytargets.end(), target), mytargets.end()); | |
856 | } | |
857 | ||
1a3a14ac DK |
858 | bool UsePDiffs = _config->FindB("Acquire::PDiffs", true); |
859 | { | |
860 | std::map<std::string, std::string>::const_iterator const opt = Options.find("pdiffs"); | |
861 | if (opt != Options.end()) | |
862 | UsePDiffs = StringToBool(opt->second); | |
863 | } | |
8dd562a8 | 864 | |
24e8f24e DK |
865 | std::string UseByHash = _config->Find("APT::Acquire::By-Hash", "yes"); |
866 | UseByHash = _config->Find("Acquire::By-Hash", UseByHash); | |
867 | { | |
868 | std::string const host = ::URI(URI).Host; | |
869 | UseByHash = _config->Find("APT::Acquire::" + host + "::By-Hash", UseByHash); | |
870 | UseByHash = _config->Find("Acquire::" + host + "::By-Hash", UseByHash); | |
871 | std::map<std::string, std::string>::const_iterator const opt = Options.find("by-hash"); | |
872 | if (opt != Options.end()) | |
873 | UseByHash = opt->second; | |
874 | } | |
875 | ||
3090ae69 | 876 | auto const entry = Options.find("sourceslist-entry"); |
463c8d80 | 877 | Deb->AddComponent( |
3090ae69 | 878 | entry->second, |
463c8d80 DK |
879 | IsSrc, |
880 | Section, | |
e6a12ff7 | 881 | mytargets, |
463c8d80 | 882 | parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()), |
1a3a14ac | 883 | parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true)), |
24e8f24e DK |
884 | UsePDiffs, |
885 | UseByHash | |
463c8d80 | 886 | ); |
261727f0 | 887 | |
0741daeb DK |
888 | if (Deb->SetTrusted(GetTriStateOption(Options, "trusted")) == false || |
889 | Deb->SetCheckValidUntil(GetTriStateOption(Options, "check-valid-until")) == false || | |
890 | Deb->SetValidUntilMax(GetTimeOption(Options, "valid-until-max")) == false || | |
891 | Deb->SetValidUntilMin(GetTimeOption(Options, "valid-until-min")) == false) | |
268ffceb | 892 | return false; |
261727f0 | 893 | |
b0d40854 DK |
894 | std::map<std::string, std::string>::const_iterator const signedby = Options.find("signed-by"); |
895 | if (signedby == Options.end()) | |
896 | { | |
897 | if (Deb->SetSignedBy("") == false) | |
898 | return false; | |
899 | } | |
900 | else | |
901 | { | |
902 | if (Deb->SetSignedBy(signedby->second) == false) | |
903 | return false; | |
904 | } | |
905 | ||
7db98ffc MZ |
906 | return true; |
907 | } | |
0d29b9d4 | 908 | |
463c8d80 DK |
909 | debSLTypeDebian(char const * const Name, char const * const Label) : Type(Name, Label) |
910 | { | |
911 | } | |
912 | }; | |
913 | /*}}}*/ | |
914 | class APT_HIDDEN debSLTypeDeb : public debSLTypeDebian /*{{{*/ | |
7db98ffc MZ |
915 | { |
916 | public: | |
917 | ||
463c8d80 DK |
918 | bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI, |
919 | std::string const &Dist, std::string const &Section, | |
3b302846 | 920 | std::map<std::string, std::string> const &Options) const APT_OVERRIDE |
7db98ffc | 921 | { |
5dd4c8b8 | 922 | return CreateItemInternal(List, URI, Dist, Section, false, Options); |
7db98ffc MZ |
923 | } |
924 | ||
463c8d80 | 925 | debSLTypeDeb() : debSLTypeDebian("deb", "Debian binary tree") |
7db98ffc | 926 | { |
463c8d80 | 927 | } |
7db98ffc | 928 | }; |
463c8d80 DK |
929 | /*}}}*/ |
930 | class APT_HIDDEN debSLTypeDebSrc : public debSLTypeDebian /*{{{*/ | |
7db98ffc MZ |
931 | { |
932 | public: | |
933 | ||
463c8d80 DK |
934 | bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI, |
935 | std::string const &Dist, std::string const &Section, | |
3b302846 | 936 | std::map<std::string, std::string> const &Options) const APT_OVERRIDE |
7db98ffc | 937 | { |
5dd4c8b8 | 938 | return CreateItemInternal(List, URI, Dist, Section, true, Options); |
7db98ffc | 939 | } |
463c8d80 DK |
940 | |
941 | debSLTypeDebSrc() : debSLTypeDebian("deb-src", "Debian source tree") | |
7db98ffc | 942 | { |
463c8d80 | 943 | } |
7db98ffc | 944 | }; |
463c8d80 | 945 | /*}}}*/ |
7db98ffc | 946 | |
dce45dbe DK |
947 | APT_HIDDEN debSLTypeDeb _apt_DebType; |
948 | APT_HIDDEN debSLTypeDebSrc _apt_DebSrcType; |