From b7813c377c64f77f2cfd5a30638da20eaf76bf75 Mon Sep 17 00:00:00 2001 From: Kevin Daudt Date: Sat, 15 Oct 2022 10:52:11 +0000 Subject: [PATCH] abump: demonstrate abump environment polution abump sources the APKBUILD to be able to check some variables. When the APKBUILD exports variables in the global scope, that affects the abump environment as well. When abump then executes abuild, it will inherrit the environment from abump. This is an issue under the following circumstances: * The APKBUILD only updates the value of an exported variable if it's not set * The default value includes a variable set by abuild, like `$srcdir`. Because the variable is set by abuild, but not abump, the resulting exported variable is different. Because it's then set incorrectly in the abump environment, it's no longer updated with the correct variable when abuild is invoked. --- tests/abump_test | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/abump_test b/tests/abump_test index 1e6ef43..eadf173 100755 --- a/tests/abump_test +++ b/tests/abump_test @@ -5,7 +5,8 @@ init_tests \ abump_help \ abump_invalid_opt \ abump_missing_args \ - abump_simple_bump + abump_simple_bump \ + abump_isolates_apkbuild export ABUILD_SHAREDIR=$(atf_get_srcdir)/.. export GIT_CONFIG_GLOBAL="$(atf_get_srcdir)/testdata/gitconfig" @@ -76,3 +77,39 @@ abump_simple_bump_body() { abump foo-1.2 } +abump_isolates_apkbuild_body() { + cp -r "$(atf_get_srcdir)"/testdata/.abuild . + git init + mkdir -p main/bar + cd main/bar + echo "first" > bar-1.0.txt + cat > APKBUILD <<-"EOF" + # Maintainer: Test user + pkgname="bar" + pkgver=1.0 + pkgrel=0 + pkgdesc="dummy package for test" + url="https://alpinelinux.org" + license="MIT" + arch="noarch" + source="bar-$pkgver.txt" + options="!check" + + export BUILDFLAGS="${BUILDFLAGS:-"repo=$repo"}" + + package() { + echo "BUILDFLAGS: $BUILDFLAGS" + install -D "$srcdir"/bar-$pkgver.txt "$pkgdir"/bar + } + EOF + abuild checksum + abuild + git add APKBUILD bar-1.0.txt + git commit -m "test commit" + + echo "second" > bar-1.1.txt + atf_check \ + -o match:"BUILDFLAGS: repo=main" \ + -e ignore \ + abump bar-1.1 +}