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.
This commit is contained in:
Kevin Daudt 2022-10-15 10:52:11 +00:00
parent 5c542377a8
commit b7813c377c
1 changed files with 38 additions and 1 deletions

View File

@ -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 <user@example.com>
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
}