From dc7663b3a8bbcd67cdf630c8038d3f8f6762cf60 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Mon, 6 Jan 2020 11:10:31 +0100 Subject: [PATCH] coverage.sh: allow running tests on architectures other than amd64 with reduced functionality --- coverage.sh | 28 ++++++++++++++++++++++------ make_mirror.sh | 28 +++++++++++++++++++--------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/coverage.sh b/coverage.sh index bee02f4..4947abf 100755 --- a/coverage.sh +++ b/coverage.sh @@ -16,6 +16,8 @@ rm -f shared/cover_db.img : "${HAVE_QEMU:=yes}" : "${RUN_MA_SAME_TESTS:=yes}" +HOSTARCH=$(dpkg --print-architecture) + if [ "$HAVE_QEMU" = "yes" ]; then # prepare image for cover_db guestfish -N shared/cover_db.img=disk:256M -- mkfs vfat /dev/sda @@ -176,7 +178,7 @@ if [ -e "/tmp/debian-$dist-debootstrap/run/mount" ]; then rmdir "/tmp/debian-$dist-debootstrap/run/mount" fi # debootstrap doesn't clean apt -rm /tmp/debian-$dist-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_${dist}_main_binary-amd64_Packages \ +rm /tmp/debian-$dist-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_${dist}_main_binary-${HOSTARCH}_Packages \ /tmp/debian-$dist-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_${dist}_Release \ /tmp/debian-$dist-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_${dist}_Release.gpg @@ -886,7 +888,9 @@ if [ "\$ret" = 0 ]; then exit 1 fi END -if [ "$HAVE_QEMU" = "yes" ]; then +if [ "$HOSTARCH" != amd64 ]; then + echo "HOSTARCH != amd64 -- Skipping test..." +elif [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh else echo "HAVE_QEMU != yes -- Skipping test..." @@ -933,7 +937,9 @@ $CMD --mode=$defaultmode --variant=apt --architectures=i386 $DEFAULT_DIST /tmp/d } | sort | diff -u - tar2.txt rm /tmp/debian-chroot.tar END -if [ "$HAVE_QEMU" = "yes" ]; then +if [ "$HOSTARCH" != amd64 ]; then + echo "HOSTARCH != amd64 -- Skipping test..." +elif [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh else echo "HAVE_QEMU != yes -- Skipping test..." @@ -970,7 +976,9 @@ tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1. rm -r /tmp/debian-chroot END if [ "$RUN_MA_SAME_TESTS" = "yes" ]; then - if [ "$HAVE_QEMU" = "yes" ]; then + if [ "$HOSTARCH" != amd64 ]; then + echo "HOSTARCH != amd64 -- Skipping test..." + elif [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh else ./run_null.sh SUDO @@ -1005,7 +1013,9 @@ tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1. rm -r /tmp/debian-chroot END if [ "$RUN_MA_SAME_TESTS" = "yes" ]; then - if [ "$HAVE_QEMU" = "yes" ]; then + if [ "$HOSTARCH" != amd64 ]; then + echo "HOSTARCH != amd64 -- Skipping test..." + elif [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh else ./run_null.sh SUDO @@ -1988,7 +1998,9 @@ rm /tmp/debian-chroot/var/lib/dpkg/info/libmagic-mgc.list # the rest should be empty directories that we can rmdir recursively find /tmp/debian-chroot -depth -print0 | xargs -0 rmdir END -if [ "$HAVE_BINFMT" = "yes" ]; then +if [ "$HOSTARCH" != amd64 ]; then + echo "HOSTARCH != amd64 -- Skipping test..." +elif [ "$HAVE_BINFMT" = "yes" ]; then if [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh else @@ -2038,6 +2050,10 @@ fi for mode in root unshare fakechroot proot; do print_header "mode=$mode,variant=apt: create armhf tarball" + if [ "$HOSTARCH" != amd64 ]; then + echo "HOSTARCH != amd64 -- Skipping test..." + continue + fi if [ "$HAVE_BINFMT" != "yes" ]; then echo "HAVE_BINFMT != yes -- Skipping test..." continue diff --git a/make_mirror.sh b/make_mirror.sh index 7fee79f..f5ac97a 100755 --- a/make_mirror.sh +++ b/make_mirror.sh @@ -326,14 +326,11 @@ newmirrordir="$newcachedir/debian" mirror="http://deb.debian.org/debian" security_mirror="http://security.debian.org/debian-security" -if [ "$(dpkg --print-architecture)" != amd64 ]; then - echo "script only supports being run on amd64" >&2 - exit 1 -fi components=main : "${DEFAULT_DIST:=unstable}" : "${HAVE_QEMU:=yes}" +: "${RUN_MA_SAME_TESTS:=yes}" if [ -e "$oldmirrordir/dists/$DEFAULT_DIST/Release" ]; then http_code=$(curl --output /dev/null --silent --location --head --time-cond "$oldmirrordir/dists/$DEFAULT_DIST/Release" --write-out '%{http_code}' "$mirror/dists/$DEFAULT_DIST/Release") @@ -349,10 +346,17 @@ trap "cleanup_newcachedir" EXIT INT TERM mkdir -p "$newcachedir" touch "$newcachedir/mmdebstrapcache" -for nativearch in amd64 armhf i386; do +HOSTARCH=$(dpkg --print-architecture) +if [ "$HOSTARCH" = amd64 ]; then + arches="amd64 armhf i386" +else + arches="$HOSTARCH" +fi + +for nativearch in $arches; do for dist in stable testing unstable; do - # only store non-amd64 architectures for $DEFAULT_DIST - if [ $nativearch != amd64 ] && [ $DEFAULT_DIST != $dist ]; then + # non-host architectures are only downloaded for $DEFAULT_DIST + if [ $nativearch != $HOSTARCH ] && [ $DEFAULT_DIST != $dist ]; then continue fi cat << END | update_cache "$dist" "$nativearch" @@ -403,8 +407,14 @@ if [ "$HAVE_QEMU" = "yes" ]; then tmpdir="$(mktemp -d)" trap "cleanuptmpdir; cleanup_newcachedir" EXIT INT TERM - ./mmdebstrap --variant=apt --architectures=amd64,armhf \ - --include=perl-doc,linux-image-amd64,systemd-sysv,perl,arch-test,fakechroot,fakeroot,mount,uidmap,proot,qemu-user-static,binfmt-support,qemu-user,dpkg-dev,mini-httpd,libdevel-cover-perl,debootstrap,libfakechroot:armhf,libfakeroot:armhf,procps,apt-cudf,aspcud \ + pkgs=perl-doc,linux-image-amd64,systemd-sysv,perl,arch-test,fakechroot,fakeroot,mount,uidmap,proot,qemu-user-static,binfmt-support,qemu-user,dpkg-dev,mini-httpd,libdevel-cover-perl,debootstrap,procps,apt-cudf,aspcud + if [ "$HOSTARCH" = amd64 ] && [ "$RUN_MA_SAME_TESTS" = "yes" ]; then + arches=amd64,armhf + pkgs="$pkgs,libfakechroot:armhf,libfakeroot:armhf" + else + arches=$HOSTARCH + fi + ./mmdebstrap --variant=apt --architectures=$arches --include="$pkgs" \ $DEFAULT_DIST - "$mirror" > "$tmpdir/debian-chroot.tar" cat << END > "$tmpdir/extlinux.conf"