debmetaindex.cc 38 KB

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