summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-09-03 14:38:58 +0200
committerJulian Andres Klode <jak@debian.org>2017-09-09 20:12:15 +0200
commit8d23827be3043daf7fed1b86da1d41578889eaeb (patch)
tree824caa9e5112763a71053cf9284ec0cb4549e589
parent03ba8fcc5fe9560084b40b955067da7e60b2e1c0 (diff)
downloadapt-8d23827be3043daf7fed1b86da1d41578889eaeb.tar.gz
ftparchive: Do not pass through disabled hashes in Sources
When writing a Sources files hashes that were already present in the .dsc were always copied through (or modified), even if disabled. Remove them instead when they are disabled, otherwise we end up with hashes for tarballs and stuff but not for dsc files (as the dsc obviously does not hash itself). Also adjust the tests: test-compressed-indexes relied on Files being present in showsrc, and test-apt-update-weak-hashes expected the tarball to be downloaded when an archive only has MD5 and we are requiring SHA256 because that used to work because the tarball was always included. Closes: #872963
-rw-r--r--ftparchive/writer.cc8
-rwxr-xr-xtest/integration/test-apt-update-weak-hashes2
-rwxr-xr-xtest/integration/test-bug-872963-apt-ftparchive-disable-hashes40
-rwxr-xr-xtest/integration/test-compressed-indexes2
4 files changed, 50 insertions, 2 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index bdf9893c2..bb855d532 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -849,12 +849,20 @@ bool SourcesWriter::DoPackage(string FileName)
Changes.push_back(pkgTagSection::Tag::Rewrite("Package", Package));
if (Files.empty() == false)
Changes.push_back(pkgTagSection::Tag::Rewrite("Files", Files));
+ else
+ Changes.push_back(pkgTagSection::Tag::Remove("Files"));
if (ChecksumsSha1.empty() == false)
Changes.push_back(pkgTagSection::Tag::Rewrite("Checksums-Sha1", ChecksumsSha1));
+ else
+ Changes.push_back(pkgTagSection::Tag::Remove("Checksums-Sha1"));
if (ChecksumsSha256.empty() == false)
Changes.push_back(pkgTagSection::Tag::Rewrite("Checksums-Sha256", ChecksumsSha256));
+ else
+ Changes.push_back(pkgTagSection::Tag::Remove("Checksums-Sha256"));
if (ChecksumsSha512.empty() == false)
Changes.push_back(pkgTagSection::Tag::Rewrite("Checksums-Sha512", ChecksumsSha512));
+ else
+ Changes.push_back(pkgTagSection::Tag::Remove("Checksums-Sha512"));
if (Directory != "./")
Changes.push_back(pkgTagSection::Tag::Rewrite("Directory", Directory));
Changes.push_back(pkgTagSection::Tag::Rewrite("Priority", BestPrio));
diff --git a/test/integration/test-apt-update-weak-hashes b/test/integration/test-apt-update-weak-hashes
index b07dba6a2..c44ab9ab0 100755
--- a/test/integration/test-apt-update-weak-hashes
+++ b/test/integration/test-apt-update-weak-hashes
@@ -198,5 +198,5 @@ testsuccess apt source foo4
cp ../rootdir/tmp/testsuccess.output source.output
testsuccess grep 'Skipping download of file' source.output
testfailure test -e foo4_1.dsc
-testsuccess test -e foo4_1.tar.*
+testfailure test -e foo4_1.tar.*
cd ..
diff --git a/test/integration/test-bug-872963-apt-ftparchive-disable-hashes b/test/integration/test-bug-872963-apt-ftparchive-disable-hashes
new file mode 100755
index 000000000..ff0124684
--- /dev/null
+++ b/test/integration/test-bug-872963-apt-ftparchive-disable-hashes
@@ -0,0 +1,40 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+
+touch aptarchive/apt_1.5~rc1.tar.xz
+cat >> aptarchive/apt_1.5~rc1.dsc << EOF
+Format: 3.0 (native)
+Source: apt
+Binary: apt
+Architecture: any all
+Version: 1.5~rc1
+Build-Depends: foo
+Package-List:
+ apt deb admin important arch=any
+Checksums-Sha1:
+ 332b354b0c7cbd936a4a95f3ce149aa03677cabf 2095076 apt_1.5~rc1.tar.xz
+Checksums-Sha256:
+ 14d09b2c1e13f9a70aac3322987ff26f36c53010639763573c9aa4987e52e47a 2095076 apt_1.5~rc1.tar.xz
+Checksums-Sha512:
+ 4f570c10c3fd549b2e27db4481fbc1ebebed52bd06a8ba7c0716b3917a8452bb3d3cd4fbb02561e02af09b1973a65a4cc69a42c21e858b1d5c3caa970aea4fd4 2095076 apt_1.5~rc1.tar.xz
+Files:
+ 7ea24e77b6203e08ca4158831df26825 2095076 apt_1.5~rc1.tar.xz
+EOF
+
+
+rm rootdir/etc/apt/apt.conf.d/*
+
+for HASH in MD5 SHA1 SHA256 SHA512; do
+ testsuccess aptftparchive -qq sources -o APT::FTPArchive::$HASH=false "aptarchive/"
+ cp rootdir/tmp/testsuccess.output aptarchive/Sources
+ if [ "$HASH" = "MD5" ]; then
+ testfailure grep "Files:" aptarchive/Sources
+ else
+ testfailure grep -i "$HASH:" aptarchive/Sources
+ fi
+done
diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes
index ef02b45f6..858bf1178 100755
--- a/test/integration/test-compressed-indexes
+++ b/test/integration/test-compressed-indexes
@@ -140,7 +140,7 @@ test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Ar
testsuccessequal "$GOODSHOW" aptcache show testpkg
GOODSHOWSRC="$(aptcache showsrc testpkg)
"
-test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
+test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Checksums-Sha256:' | wc -l) -eq 3 || msgdie 'showsrc is broken'
testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
GOODPOLICY="$(aptcache policy testpkg)"
test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'file policy is broken'