From 88619e4d9c3851bd4a7a024eedba7890c6155f52 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Fri, 7 Jan 2022 12:46:35 +0100 Subject: [PATCH] test codename apt pattern as well, requires apt >= 2.3.14 closes: #21 --- coverage.sh | 30 +++++++++++++++++++++++++++++- make_mirror.sh | 7 +++++++ mmdebstrap | 14 ++++++++++---- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/coverage.sh b/coverage.sh index 62b0cea..64da1c7 100755 --- a/coverage.sh +++ b/coverage.sh @@ -127,7 +127,7 @@ if [ ! -e shared/hooks/eatmydata/customize.sh ] || [ hooks/eatmydata/customize.s fi fi starttime= -total=177 +total=181 skipped=0 runtests=0 i=1 @@ -533,6 +533,34 @@ else runtests=$((runtests+1)) fi +# make sure that using codenames works https://bugs.debian.org/cgi-bin/1003191 +for dist in oldstable stable testing unstable; do + print_header "mode=$defaultmode,variant=apt: test $dist using codename" +cat << END > shared/test.sh +#!/bin/sh +set -eu +export LC_ALL=C.UTF-8 +/usr/lib/apt/apt-helper download-file "$mirror/dists/$dist/Release" Release +codename=\$(awk '/^Codename: / { print \$2; }' Release) +rm Release +$CMD --mode=$defaultmode --variant=apt \$codename /tmp/debian-chroot.tar $mirror +if [ "$dist" = "$DEFAULT_DIST" ]; then + tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt - +fi +rm /tmp/debian-chroot.tar +END + if [ "$HAVE_QEMU" = "yes" ]; then + ./run_qemu.sh + runtests=$((runtests+1)) + elif [ "$defaultmode" = "root" ]; then + ./run_null.sh SUDO + runtests=$((runtests+1)) + else + ./run_null.sh + runtests=$((runtests+1)) + fi +done + print_header "mode=unshare,variant=apt: fail without /etc/subuid" cat << END > shared/test.sh #!/bin/sh diff --git a/make_mirror.sh b/make_mirror.sh index 51c11b1..3c5052e 100755 --- a/make_mirror.sh +++ b/make_mirror.sh @@ -80,6 +80,9 @@ deletecache() { rm "$dir/debian$i" done rm "$dir/mmdebstrapcache" + # remove all symlinks + find "$dir" -type l -delete + # now the rest should only be empty directories if [ -e "$dir" ]; then find "$dir" -depth -print0 | xargs -0 --no-run-if-empty rmdir @@ -270,11 +273,14 @@ END curl --location "$mirror/dists/$dist/Release" > "$newmirrordir/dists/$dist/Release" curl --location "$mirror/dists/$dist/Release.gpg" > "$newmirrordir/dists/$dist/Release.gpg" curl --location "$mirror/dists/$dist/main/binary-$nativearch/Packages.xz" > "$newmirrordir/dists/$dist/main/binary-$nativearch/Packages.xz" + codename=$(awk '/^Codename: / { print $2; }' < "$newmirrordir/dists/$dist/Release") + [ -L "$newmirrordir/dists/$codename" ] || ln -s "$dist" "$newmirrordir/dists/$codename" case "$dist" in oldstable|stable) mkdir -p "$newmirrordir/dists/$dist-updates/main/binary-$nativearch/" curl --location "$mirror/dists/$dist-updates/Release" > "$newmirrordir/dists/$dist-updates/Release" curl --location "$mirror/dists/$dist-updates/Release.gpg" > "$newmirrordir/dists/$dist-updates/Release.gpg" curl --location "$mirror/dists/$dist-updates/main/binary-$nativearch/Packages.xz" > "$newmirrordir/dists/$dist-updates/main/binary-$nativearch/Packages.xz" + [ -L "$newmirrordir/dists/$codename-updates" ] || ln -s "$dist-updates" "$newmirrordir/dists/$codename-updates" ;; esac case "$dist" in @@ -289,6 +295,7 @@ END curl --location "$security_mirror/dists/$dist-security/Release" > "$newcachedir/debian-security/dists/$dist-security/Release" curl --location "$security_mirror/dists/$dist-security/Release.gpg" > "$newcachedir/debian-security/dists/$dist-security/Release.gpg" curl --location "$security_mirror/dists/$dist-security/main/binary-$nativearch/Packages.xz" > "$newcachedir/debian-security/dists/$dist-security/main/binary-$nativearch/Packages.xz" + [ -L "$newcachedir/debian-security/dists/$codename-security" ] || ln -s "$dist-security" "$newcachedir/debian-security/dists/$codename-security" ;; esac diff --git a/mmdebstrap b/mmdebstrap index 698b7ea..d71b9d0 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -2150,7 +2150,10 @@ sub run_download() { '?narrow(' . ( length($options->{suite}) - ? '?archive(' . $options->{suite} . '),' + ? '?or(?archive(^' + . $options->{suite} + . '$),?codename(^' + . $options->{suite} . '$)),' : '' ) . '?architecture(' @@ -2704,7 +2707,10 @@ sub run_install() { "?narrow(" . ( length($options->{suite}) - ? '?archive(' . $options->{suite} . '),' + ? '?or(?archive(^' + . $options->{suite} + . '$),?codename(^' + . $options->{suite} . '$)),' : '' ) . "?architecture($options->{nativearch})," @@ -4374,8 +4380,8 @@ sub main() { and $content =~ /^apt ([0-9]+\.[0-9]+\.[0-9]+) \([a-z0-9-]+\)$/m) { $aptversion = version->new($1); } - if ($aptversion < "2.3.10") { - error "need apt >= 2.3.10 but have $aptversion"; + if ($aptversion < "2.3.14") { + error "need apt >= 2.3.14 but have $aptversion"; } }