abuild: allow options to only effect specific packages

This is sometimes needed for options like !tracedeps which needs to only
apply to a specific subpackage in some cases.

Ref https://gitlab.alpinelinux.org/alpine/aports/-/issues/16632#note_458449
This commit is contained in:
Sertonix 2024-11-24 18:47:09 +01:00 committed by Natanael Copa
parent a694f476bb
commit c3019e1b5d
2 changed files with 15 additions and 4 deletions

View File

@ -1845,7 +1845,7 @@ create_apks() {
size=$(pkginfo_val size "$file")
local apk=$name-$ver.apk
local datadir="$pkgbasedir"/$name
local subpkgname=$name
subpkgname=$name
subpkgarch=$(pkginfo_val arch "$file")
# See https://gitlab.alpinelinux.org/alpine/tsc/-/issues/16
@ -2734,6 +2734,8 @@ deplist_has() {
}
options_has() {
[ -n "${subpkgname:-pkgname}" ] &&
list_has "${subpkgname:-pkgname}:$1" $options ||
list_has "$1" $options
}

View File

@ -1196,9 +1196,8 @@ abuild_command_provides_body() {
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
prepare() { mkdir -p "\$builddir"; }
build() { true; }
check() { true; }
subpackages="noprovides"
options="noprovides:!tracedeps"
package() {
mkdir -p "\$pkgdir/usr/bin"
printf "%s\n" '#!/bin/sh' >"\$pkgdir/usr/bin/foo"
@ -1207,6 +1206,12 @@ abuild_command_provides_body() {
mkdir -p "\$pkgdir/usr/bin/dir/"
ln -s /usr/bin/not-on-the-host-system-but-in-a-dependency "\$pkgdir/usr/bin/link"
}
noprovides() {
mkdir -p "\$subpkgdir/usr/bin"
printf "%s\n" '#!/bin/sh' >"\$subpkgdir/usr/bin/foo"
chmod +x "\$subpkgdir/usr/bin/foo"
}
EOF
abuild rootpkg
@ -1216,6 +1221,10 @@ abuild_command_provides_body() {
-o match:"provides = cmd:link=1.0-r0" \
-o not-match:"provides = cmd:dir=1.0-r0" \
grep '^provides = ' pkg/.control.testprovides/.PKGINFO
atf_check -s exit:1 \
-o not-match:"provides" \
grep '^provides = ' pkg/.control.noprovides/.PKGINFO
}
abuild_gocache_dir_body() {