From e8c1ce61272006c9e1b32c6500683d98d41e23b8 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 6 Dec 2022 16:59:03 +0100 Subject: [PATCH] abuild: fix cleanoldpkg we should only delete packages of the specified architecture fixes https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10078 --- abuild.in | 2 +- tests/abuild_test | 58 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/abuild.in b/abuild.in index 95bbd26..154c4c6 100755 --- a/abuild.in +++ b/abuild.in @@ -615,7 +615,7 @@ cleanoldpkg() { msg "Cleaning all packages except $pkgver-r$pkgrel..." for i in $allpackages; do subpkg_set "$i" - for j in "$REPODEST"/$repo/*/$subpkgname-[0-9]*.apk ; do + for j in "$REPODEST"/$repo/$CARCH/$subpkgname-[0-9]*.apk ; do [ "${j##*/}" = "$subpkgname-$pkgver-r$pkgrel.apk" ] \ && continue rm -f "$j" diff --git a/tests/abuild_test b/tests/abuild_test index 7f8b3c1..8aa5ec2 100755 --- a/tests/abuild_test +++ b/tests/abuild_test @@ -28,10 +28,12 @@ init_tests \ abuild_amove \ abuild_doc \ abuild_dev \ - abuild_check_maintainer + abuild_check_maintainer \ + abuild_cleanoldpkg export ABUILD_SHAREDIR=$(atf_get_srcdir)/.. export ABUILD_CONF=/dev/null +export ABUILD_APK_INDEX_OPTS="--allow-untrusted" export GIT_CONFIG_GLOBAL="$(atf_get_srcdir)/testdata/gitconfig" export REPODEST="$PWD"/packages @@ -695,3 +697,57 @@ abuild_check_maintainer_body() { atf_check abuild check_maintainer done } + +abuild_cleanoldpkg_body() { + init_keys + mkdir -p main/foo + cd main/foo + for arch in aarch64 x86_64; do + for v in 0.9 1.0 1.1; do + cat > APKBUILD <<-EOF + # Maintainer: Test User 123 <123@example.com> + # test package + pkgname="foo" + pkgver="$v" + pkgrel=0 + pkgdesc='Dummy test package - dev' + url='https://gitlab.alpinelinux.org/alpine/aports' + arch='noarch' + license='MIT' + options='!check' + package() { + mkdir -p "\$pkgdir" + } + EOF + CARCH=$arch atf_check -e not-empty abuild + done + done + + CARCH=aarch64 atf_check -e match:"Cleaning" abuild cleanoldpkg + + find "$REPODEST" + + # should keep the current APKBUILD version + for arch in aarch64 x86_64; do + f="$REPODEST"/main/$arch/foo-1.1-r0.apk + if ! test -e "$f"; then + atf_fail "$f was deleted" + fi + done + + # should remove old packages of aarch64 + for i in 0.9 1.0; do + f="$REPODEST"/main/aarch64/foo-$i-r0.apk + if test -e "$f"; then + atf_fail "$f was not deleted" + fi + done + + # should not delete other arches than aarch64 + for i in 0.9 1.0; do + f="$REPODEST"/main/x86_64/foo-$i-r0.apk + if ! test -e "$f"; then + atf_fail "$f was deleted" + fi + done +}