From 03ba8fcc5fe9560084b40b955067da7e60b2e1c0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 9 Sep 2017 19:17:37 +0200 Subject: cdrom: Don't hardcode "Files" field for copying source files This fails if no Files field exists anymore, for example, because the Sources index only contains SHA256 hashes. Instead check all hashes. --- apt-pkg/indexcopy.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'apt-pkg/indexcopy.cc') diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 968734118..d4cab1a04 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -438,7 +438,21 @@ bool PackageCopy::RewriteEntry(FileFd &Target,string const &File) /* */ bool SourceCopy::GetFile(string &File,unsigned long long &Size) { - string Files = Section->FindS("Files"); + string Files; + + for (char const *const *type = HashString::SupportedHashes(); *type != NULL; ++type) + { + // derive field from checksum type + std::string checksumField("Checksums-"); + if (strcmp(*type, "MD5Sum") == 0) + checksumField = "Files"; // historic name for MD5 checksums + else + checksumField.append(*type); + + Files = Section->FindS(checksumField.c_str()); + if (Files.empty() == false) + break; + } if (Files.empty() == true) return false; -- cgit v1.2.3