From f5d6e5e34b722f888505a481525106023df318e2 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Thu, 19 May 2022 13:43:27 +0200 Subject: [PATCH] abuild: Do not store whitespaces in license field Currently, abuild stores the license variable ad-verbatim in the PKGINFO file. This causes many downstream systems to fail. For example, `apk info` won't show anything after the newline, our webview that lists licenses do not show these either. Signed-off-by: Olliver Schinagl --- abuild.in | 2 +- tests/abuild.bats | 6 ++++++ tests/testrepo/test-licenses/APKBUILD | 31 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/testrepo/test-licenses/APKBUILD diff --git a/abuild.in b/abuild.in index 1500485..38cb842 100755 --- a/abuild.in +++ b/abuild.in @@ -1135,7 +1135,7 @@ prepare_metafiles() { echo "provider_priority = $provider_priority" >> "$pkginfo" fi - echo "license = $license" >> "$pkginfo" + echo "license = $(echo $license)" >> "$pkginfo" for i in $replaces; do echo "replaces = $i" >> "$pkginfo" done diff --git a/tests/abuild.bats b/tests/abuild.bats index 4ff57df..f204acf 100644 --- a/tests/abuild.bats +++ b/tests/abuild.bats @@ -239,3 +239,9 @@ setup() { ! TESTDEPVER="1.0-0" $ABUILD all } +@test "abuild: check multi-line licenses" { + cd 'testrepo/test-licenses' + $ABUILD rootpkg + grep '^license = MIT AND GPL-3.0-only OR GPL-3.0-or-later AND BSD-Clause-4$' \ + "${APORTSDIR}/test-licenses/pkg/.control.test-licenses/.PKGINFO" +} diff --git a/tests/testrepo/test-licenses/APKBUILD b/tests/testrepo/test-licenses/APKBUILD new file mode 100644 index 0000000..6f1ecb0 --- /dev/null +++ b/tests/testrepo/test-licenses/APKBUILD @@ -0,0 +1,31 @@ +# Maintainer: Olliver Schinagl + +# test package +pkgname="${TESTNAME-test-licenses}" +pkgver="1.0" +pkgrel=0 +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-or-later AND + BSD-Clause-4 +' + +prepare() { + mkdir -p "${builddir}" +} + +build() { + touch foo +} + +check() { + true +} + +package() { + mkdir -p "${pkgdir}" +}