From 4ae1b399100bc7fdedea44bda7e39f1fd07050bd Mon Sep 17 00:00:00 2001 From: Sertonix Date: Mon, 12 Feb 2024 12:36:20 +0100 Subject: [PATCH] abuild: fix quote handling in check_license --- abuild.in | 4 ++-- tests/abuild_test | 11 ++++++++++- tests/testrepo/test-licenses/APKBUILD | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/abuild.in b/abuild.in index 9adb37a..6cfb6a2 100644 --- a/abuild.in +++ b/abuild.in @@ -1041,12 +1041,12 @@ check_maintainer() { check_license() { local ret=0 local license_list=/usr/share/spdx/license.lst - local exclude="AND OR WITH ( )" if options_has "!spdx" || ! [ -f "$license_list" ]; then return 0 fi + local IFS="$IFS()" local i; for i in $license; do - list_has "$i" $exclude && continue + list_has "$i" AND OR WITH && continue if ! grep -q -x -F "$i" "$license_list"; then ret=1 warning "\"$i\" is not a known license" diff --git a/tests/abuild_test b/tests/abuild_test index 2b7ea99..2a0ad15 100755 --- a/tests/abuild_test +++ b/tests/abuild_test @@ -28,6 +28,7 @@ init_tests \ abuild_bigdocs \ abuild_warn_pkgver_patch_version \ abuild_multiline_license \ + abuild_license_spdx \ abuild_git_ceiling \ abuild_package_size_zero \ abuild_package_size_nonzero \ @@ -499,10 +500,18 @@ abuild_multiline_license_body() { cp -ra "$testrepo"/test-licenses . cd test-licenses abuild rootpkg - atf_check -o match:'^license = MIT AND GPL-3.0-only OR GPL-3.0-or-later AND BSD-Clause-4$' \ + atf_check -o match:'^license = MIT AND \(GPL-3.0-only OR GPL-3.0-or-later AND BSD-Clause-4\)$' \ cat pkg/.control.test-licenses/.PKGINFO } +abuild_license_spdx_body() { + cp -ra "$testrepo"/test-licenses . + cd test-licenses + TESTPKGVER=1.0_p1 atf_check -s exit:0 \ + -e not-match:'WARNING' \ + abuild sanitycheck +} + abuild_git_ceiling_body() { init_keys git init diff --git a/tests/testrepo/test-licenses/APKBUILD b/tests/testrepo/test-licenses/APKBUILD index 6f1ecb0..986ae07 100644 --- a/tests/testrepo/test-licenses/APKBUILD +++ b/tests/testrepo/test-licenses/APKBUILD @@ -8,10 +8,10 @@ pkgdesc='Dummy test package that has multi-line licenses' url='https://gitlab.alpinelinux.org/alpine/aports' arch='noarch' license='MIT AND - GPL-3.0-only OR + (GPL-3.0-only OR GPL-3.0-or-later AND - BSD-Clause-4 + BSD-Clause-4) ' prepare() {