From e45417c4767c2e54def08f52d55350ed0651d95a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 10 Jun 2021 12:51:45 +0200 Subject: [PATCH 1/4] Use full item description in broken repo error The error says the repository is broken but doesn't mention which one it is. The item description gives us at least all the information, but is not as nicely formatted. As this message is not even marked for translation this is a rather temporary affair and we can survive without the eye candy for a while. --- apt-pkg/acquire-item.cc | 5 ++--- test/integration/test-ubuntu-bug-1921626-unsized-packages | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index d6ffaf34d..37a715390 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -3471,9 +3471,8 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *const Owner, pkgSourceList *const Sourc } if (FileSize == 0 && not _config->FindB("Acquire::AllowUnsizedPackages", false)) { - _error->Error("Repository is broken: %s (= %s) has no Size information", - Version.ParentPkg().FullName(false).c_str(), - Version.VerStr()); + _error->Error("Repository is broken: %s has no Size information", + Desc.Description.c_str()); return; } diff --git a/test/integration/test-ubuntu-bug-1921626-unsized-packages b/test/integration/test-ubuntu-bug-1921626-unsized-packages index 361cccd2e..441bc7043 100755 --- a/test/integration/test-ubuntu-bug-1921626-unsized-packages +++ b/test/integration/test-ubuntu-bug-1921626-unsized-packages @@ -40,4 +40,4 @@ Get:2 http://localhost:${APTHTTPPORT} stable/main all b all 1.0 [$size_b B] Get:3 http://localhost:${APTHTTPPORT} stable/main all c all 1.0 [$size_c B]" apt download a b c -o Acquire::AllowUnsizedPackages=true rm *.deb -testfailureequal "E: Repository is broken: b:i386 (= 1.0) has no Size information" apt download a b c +testfailureequal "E: Repository is broken: http://localhost:${APTHTTPPORT} stable/main all b all 1.0 has no Size information" apt download a b c From 7adecd8b2543fc8ee5288b91525a366cf9525cb8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 10 Jun 2021 12:58:24 +0200 Subject: [PATCH 2/4] Store size from volatile sources for already installed versions Volatile sources are parsed after the status file, so if we have a version already installed the size information is not stored, so that a reinstall of said version is refused claiming a broken repository. References: 1412cf51403286e9c040f9f86fd4d8306e62aff2 --- apt-pkg/deb/deblistparser.cc | 7 ++++++- test/integration/test-apt-get-install-deb | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index d0f0838d0..966246ca7 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -404,8 +404,13 @@ uint32_t debListParser::VersionHash() half-configured, triggers-awaited, triggers-pending, installed */ bool debListParser::ParseStatus(pkgCache::PkgIterator &, - pkgCache::VerIterator &) + pkgCache::VerIterator &Ver) { + // the status file has no info about the download size and + // usually this is fine as we will have picked that info up already – + // except if we have volatile sources which are parsed after the status file. + if (Ver->Size == 0) + Ver->Size = Section.FindULL(pkgTagSection::Key::Size); return true; } bool debStatusListParser::ParseStatus(pkgCache::PkgIterator &Pkg, diff --git a/test/integration/test-apt-get-install-deb b/test/integration/test-apt-get-install-deb index 3d0b9a80d..56963819a 100755 --- a/test/integration/test-apt-get-install-deb +++ b/test/integration/test-apt-get-install-deb @@ -7,6 +7,9 @@ TESTDIR="$(readlink -f "$(dirname "$0")")" setupenvironment configarchitecture 'amd64' 'i386' +# XXX: Remove temporary hack +rm rootdir/etc/apt/apt.conf.d/temporary-allow-unsized-packages + # regression test for #754904 cat > foo.rpm < Date: Thu, 10 Jun 2021 16:38:09 +0200 Subject: [PATCH 3/4] Give our test packages proper size information Temporary hacks should be temporary, especially if they hide bugs. After fixing one in the previous commit this is just busy work to add download information to the places which check that output. Gbp-Dch: Ignore --- .../Packages-releasefile-verification | 6 ++--- .../Packages-releasefile-verification-new | 6 ++--- test/integration/framework | 7 ++---- test/integration/test-apt-cli-show | 24 +++++++++---------- test/integration/test-apt-get-install-deb | 3 --- .../test-bug-604222-new-and-autoremove | 3 +++ .../test-bug-612557-garbage-upgrade | 2 ++ .../test-bug-613420-new-garbage-dependency | 2 ++ ...bug-64141-install-dependencies-for-on-hold | 2 ++ ...est-bug-657695-resolver-breaks-on-virtuals | 1 + .../test-bug-680041-apt-mark-holds-correctly | 4 ++++ ...t-bug-722207-print-uris-even-if-very-quiet | 8 +++---- .../test-explore-or-groups-in-markinstall | 2 +- .../test-release-candidate-switching | 16 +++++++++++++ .../integration/test-releasefile-verification | 10 +++++--- .../test-ubuntu-bug-1921626-unsized-packages | 11 ++++----- 16 files changed, 66 insertions(+), 41 deletions(-) diff --git a/test/integration/Packages-releasefile-verification b/test/integration/Packages-releasefile-verification index 1e5c47096..c013dcb6b 100644 --- a/test/integration/Packages-releasefile-verification +++ b/test/integration/Packages-releasefile-verification @@ -7,9 +7,9 @@ Replaces: libapt-pkg-dev (<< 0.3.7), libapt-pkg-doc (<< 0.3.7) Provides: libapt-pkg-libc6.9-6-4.8 Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt Filename: apt.deb -Size: 0 -MD5sum: d41d8cd98f00b204e9800998ecf8427e -SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +Size: 3 +MD5sum: 583f72a833c7dfd63c03edba3776247a +SHA256: 5009a047a11fbd680bb40d2f23cd3fcd626ac2d672c38e16f53bd622c3961534 Description: Advanced front-end for dpkg This is Debian's next generation front-end for the dpkg package manager. It provides the apt-get utility and APT dselect method that provides a diff --git a/test/integration/Packages-releasefile-verification-new b/test/integration/Packages-releasefile-verification-new index 7f03829d6..ca2657fd4 100644 --- a/test/integration/Packages-releasefile-verification-new +++ b/test/integration/Packages-releasefile-verification-new @@ -10,9 +10,9 @@ Provides: libapt-pkg4.10 Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt Conflicts: python-apt (<< 0.7.93.2~) Filename: apt.deb -Size: 0 -MD5sum: d41d8cd98f00b204e9800998ecf8427e -SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +Size: 3 +MD5sum: 583f72a833c7dfd63c03edba3776247a +SHA256: 5009a047a11fbd680bb40d2f23cd3fcd626ac2d672c38e16f53bd622c3961534 Description: Advanced front-end for dpkg This is Debian's next generation front-end for the dpkg package manager. It provides the apt-get utility and APT dselect method that provides a diff --git a/test/integration/framework b/test/integration/framework index f14b4da64..8c9abfbe4 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -486,10 +486,6 @@ EOF echo 'APT::Machine-ID "912e43bd1c1d4ba481f9f8ccab25f9ee";' > rootdir/etc/apt/apt.conf.d/machine-id - # XXX: We really ought to make the packages in the test suite all have Size fields. - # But this needs a lot more changes, so let's keep it simple for stable updates. - echo 'Acquire::AllowUnsizedPackages "true";' >> rootdir/etc/apt/apt.conf.d/temporary-allow-unsized-packages - configcompression '.' 'gz' #'bz2' 'lzma' 'xz' confighashes 'SHA256' # these are tests, not security best-practices @@ -974,6 +970,8 @@ insertpackage() { Priority: $PRIORITY Section: $SECTION Installed-Size: 42 +Size: 42 +SHA256: 0000000000000000000000000000000000000000000000000000000000000000 Maintainer: Joe Sixpack " test "$arch" = 'none' || echo "Architecture: $arch" echo "Version: $VERSION @@ -981,7 +979,6 @@ Filename: pool/${DISTSECTION}/${NAME}/${NAME}_${VERSION}_${arch}.deb" test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" echo "Description: $(printf '%s' "$DESCRIPTION" | head -n 1)" echo "Description-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)" - echo "SHA256: 0000000000000000000000000000000000000000000000000000000000000000" echo } >> "${PPATH}/Packages" done diff --git a/test/integration/test-apt-cli-show b/test/integration/test-apt-cli-show index 4f9e9a16c..72f079c1e 100755 --- a/test/integration/test-apt-cli-show +++ b/test/integration/test-apt-cli-show @@ -36,7 +36,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Manual-Installed: yes APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description @@ -48,7 +48,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main i386 Packages Description: Some description That has multiple lines @@ -59,7 +59,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main amd64 Packages Description: Some description That has multiple lines @@ -70,7 +70,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 4229 MB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main amd64 Packages Description: Some description That has multiple lines @@ -83,7 +83,7 @@ Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB Provides: pkga$(generatelotsofnames) -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -95,7 +95,7 @@ Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB Provides: foobar, pkga$(generatelotsofnames) -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -108,7 +108,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -121,7 +121,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -132,7 +132,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -145,7 +145,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -158,7 +158,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines @@ -169,7 +169,7 @@ Priority: optional Section: other Maintainer: Joe Sixpack Installed-Size: 43.0 kB -Download-Size: unknown +Download-Size: 42 B APT-Sources: file:$APTARCHIVE unstable/main all Packages Description: Some description That has multiple lines diff --git a/test/integration/test-apt-get-install-deb b/test/integration/test-apt-get-install-deb index 56963819a..3d0b9a80d 100755 --- a/test/integration/test-apt-get-install-deb +++ b/test/integration/test-apt-get-install-deb @@ -7,9 +7,6 @@ TESTDIR="$(readlink -f "$(dirname "$0")")" setupenvironment configarchitecture 'amd64' 'i386' -# XXX: Remove temporary hack -rm rootdir/etc/apt/apt.conf.d/temporary-allow-unsized-packages - # regression test for #754904 cat > foo.rpm < 2.3.1-1+sid) amarok-common (3 => 2.3.1-1+sid) 0 upgraded, 3 newly installed, 2 downgraded, 0 to remove and 0 not upgraded. +Need to get 0 B/210 B of archives. After this operation, 129 kB of additional disk space will be used. E: Trivial Only specified but this is not a trivial operation." apt install amarok/sid --trivial-only -V diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification index 382d89ecd..5f873b82c 100755 --- a/test/integration/test-releasefile-verification +++ b/test/integration/test-releasefile-verification @@ -40,8 +40,9 @@ Suggested packages: The following NEW packages will be installed: apt 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Need to get 3 B of archives. After this operation, 5370 kB of additional disk space will be used. -Get:1 http://localhost:${APTHTTPPORT} apt 0.7.25.3 +Get:1 http://localhost:${APTHTTPPORT} apt 0.7.25.3 [3 B] Download complete and in download only mode" aptget install apt -dy } @@ -54,8 +55,9 @@ Suggested packages: The following NEW packages will be installed: apt 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Need to get 3 B of archives. After this operation, 5808 kB of additional disk space will be used. -Get:1 http://localhost:${APTHTTPPORT} apt 0.8.0~pre1 +Get:1 http://localhost:${APTHTTPPORT} apt 0.8.0~pre1 [3 B] Download complete and in download only mode" aptget install apt -dy } @@ -67,6 +69,7 @@ Suggested packages: The following NEW packages will be installed: apt 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Need to get 3 B of archives. After this operation, 5370 kB of additional disk space will be used. WARNING: The following packages cannot be authenticated! apt @@ -81,6 +84,7 @@ Suggested packages: The following NEW packages will be installed: apt 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Need to get 3 B of archives. After this operation, 5808 kB of additional disk space will be used. WARNING: The following packages cannot be authenticated! apt @@ -88,7 +92,7 @@ E: There were unauthenticated packages and -y was used without --allow-unauthent } # fake our downloadable file -touch aptarchive/apt.deb +echo -n 'apt' > aptarchive/apt.deb PKGFILE="${TESTDIR}/$(echo "$(basename "$0")" | sed 's#^test-#Packages-#')" diff --git a/test/integration/test-ubuntu-bug-1921626-unsized-packages b/test/integration/test-ubuntu-bug-1921626-unsized-packages index 441bc7043..477ed526d 100755 --- a/test/integration/test-ubuntu-bug-1921626-unsized-packages +++ b/test/integration/test-ubuntu-bug-1921626-unsized-packages @@ -15,14 +15,9 @@ buildsimplenativepackage 'a' 'all' '1.0' 'stable' buildsimplenativepackage 'b' 'all' '1.0' 'stable' '' '' '' '' "$PWD/tree" buildsimplenativepackage 'c' 'all' '1.0' 'stable' -setupaptarchive +setupaptarchive --no-update changetowebserver -# Disable sandbox -echo 'APT::Sandbox::User "root";' > rootdir/etc/apt/apt.conf.d/no-acquire-sandbox -# XXX: Remove temporary hack -rm rootdir/etc/apt/apt.conf.d/temporary-allow-unsized-packages - testsuccess apt update for file in rootdir/var/lib/apt/lists/*Packages; do @@ -35,9 +30,11 @@ size_a=$(wc -c aptarchive/pool/a_1.0_all.deb | awk '{print $1}') size_b=$(wc -c aptarchive/pool/b_1.0_all.deb | awk '{print $1}') size_c=$(wc -c aptarchive/pool/c_1.0_all.deb | awk '{print $1}') +cd downloaded testsuccessequal "Get:1 http://localhost:${APTHTTPPORT} stable/main all a all 1.0 [$size_a B] Get:2 http://localhost:${APTHTTPPORT} stable/main all b all 1.0 [$size_b B] Get:3 http://localhost:${APTHTTPPORT} stable/main all c all 1.0 [$size_c B]" apt download a b c -o Acquire::AllowUnsizedPackages=true - rm *.deb + testfailureequal "E: Repository is broken: http://localhost:${APTHTTPPORT} stable/main all b all 1.0 has no Size information" apt download a b c +cd .. From e6056cbc8faf82c368d4439b0fcdcf4f46047d59 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 10 Jun 2021 16:41:04 +0200 Subject: [PATCH 4/4] Test that tiny differences result in different versions Just because two packages have the same version number doesn't mean it is the same package. APT can detect rebuilds and other "inconsistencies", but we had no explicit test for it so far. It turned out to be the wrong track in this branch, but as I wrote it already, lets add it at least. Gbp-Dch: Ignore --- .../test-same-version-but-different | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 test/integration/test-same-version-but-different diff --git a/test/integration/test-same-version-but-different b/test/integration/test-same-version-but-different new file mode 100755 index 000000000..df6753a43 --- /dev/null +++ b/test/integration/test-same-version-but-different @@ -0,0 +1,98 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' + +insertpackage 'unstable' 'all-same' 'all' '1' +insertpackage 'testing' 'all-same' 'all' '1' + +insertpackage 'unstable' 'diff-depends' 'all' '1' 'Depends: all-same (= 1)' +insertpackage 'testing' 'diff-depends' 'all' '1' 'Depends: all-same (= 2)' + +insertpackage 'unstable' 'diff-arch' 'all' '1' +insertpackage 'testing' 'diff-arch' 'amd64' '1' + +insertpackage 'unstable' 'diff-ma-1' 'all' '1' 'Multi-Arch: foreign' +insertpackage 'testing' 'diff-ma-1' 'all' '1' + +insertpackage 'unstable' 'diff-ma-2' 'all' '1' 'Multi-Arch: foreign' +insertpackage 'testing' 'diff-ma-2' 'all' '1' 'Multi-Arch: no' + +insertpackage 'unstable' 'diff-ma-3' 'amd64' '1' 'Multi-Arch: foreign' +insertpackage 'testing' 'diff-ma-3' 'amd64' '1' 'Multi-Arch: same' + +insertpackage 'unstable' 'diff-size' 'all' '1' 'Size: 21' +insertpackage 'testing' 'diff-size' 'all' '1' 'Size: 42' + +insertpackage 'unstable' 'diff-instsize' 'all' '1' 'Installed-Size: 21' +insertpackage 'testing' 'diff-instsize' 'all' '1' 'Installed-Size: 42' + +setupaptarchive + +APTARCHIVE="$(readlink -f ./aptarchive)" +testsuccessequal "all-same: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main all Packages + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy all-same +testsuccessequal "diff-depends: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main all Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy diff-depends +testsuccessequal "diff-arch: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main amd64 Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy diff-arch +testsuccessequal "diff-ma-1: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main all Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy diff-ma-1 +testsuccessequal "diff-ma-2: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main all Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy diff-ma-2 +testsuccessequal "diff-ma-3: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main amd64 Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main amd64 Packages" apt policy diff-ma-3 +testsuccessequal "diff-size: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main all Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy diff-size +testsuccessequal "diff-instsize: + Installed: (none) + Candidate: 1 + Version table: + 1 500 + 500 file:${APTARCHIVE} testing/main all Packages + 1 500 + 500 file:${APTARCHIVE} unstable/main all Packages" apt policy diff-instsize