diff options
author | Julian Andres Klode <jak@debian.org> | 2017-09-09 19:17:37 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2017-09-09 20:11:57 +0200 |
commit | 03ba8fcc5fe9560084b40b955067da7e60b2e1c0 (patch) | |
tree | 9da8b02083efe5fc30e753856f85c470cbfcb803 | |
parent | 5a747462baef6cecf6ed389c7b7492443930f7ed (diff) |
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.
-rw-r--r-- | apt-pkg/indexcopy.cc | 16 |
1 files changed, 15 insertions, 1 deletions
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; |