From 8da25016132f801f275eb9c2d2e4563e5e63278c Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 13 Mar 2024 11:43:10 +0100 Subject: [PATCH] abuild: warn for more version suffixes give a warning when version suffix a/b probably should be _alpha/_beta. ref: https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10972#note_380899 --- abuild.in | 14 ++++++++++---- tests/abuild_test | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/abuild.in b/abuild.in index c77ae41..0fc699e 100644 --- a/abuild.in +++ b/abuild.in @@ -200,10 +200,16 @@ default_sanitycheck() { # give 0 as it is always valid and give the pkgrel $APK version --check --quiet 0-r"$pkgrel" || \ die "$pkgrel is not a valid pkgrel" - # warn when p1 should be _p1 - case "$pkgver" in - *[0-9]p[0-9]) warning "pkgver should probably be $(echo "$pkgver" | sed -E -e 's/(.*[0-9])p([0-9])/\1_p\2/')";; - esac + + # warn when should be + # eg p1 -> _p1, a5 -> _alpha5 and b10 -> _beta10 + suggestion=$(echo "$pkgver" | sed -E \ + -e 's/(.*[0-9])a([0-9]+)$/\1_alpha\2/' \ + -e 's/(.*[0-9])b([0-9]+)$/\1_beta\2/' \ + -e 's/(.*[0-9])p([0-9]+)$/\1_p\2/') + if [ "$pkgver" != "$suggestion" ]; then + warning "Did you mean 'pkgver=$suggestion'?" + fi [ -z "$pkgdesc" ] && die "Missing pkgdesc in APKBUILD" [ -z "$url" ] && die "Missing url in APKBUILD" [ -z "$license" ] && die "Missing license in APKBUILD" diff --git a/tests/abuild_test b/tests/abuild_test index 2a0ad15..58ec1a3 100755 --- a/tests/abuild_test +++ b/tests/abuild_test @@ -26,7 +26,7 @@ init_tests \ abuild_subpackage_arch \ abuild_large_doc_subpackage \ abuild_bigdocs \ - abuild_warn_pkgver_patch_version \ + abuild_warn_pkgver_suffix \ abuild_multiline_license \ abuild_license_spdx \ abuild_git_ceiling \ @@ -485,7 +485,7 @@ abuild_bigdocs_body() { abuild all } -abuild_warn_pkgver_patch_version_body() { +abuild_warn_pkgver_suffix_body() { cp -ra "$testrepo"/test-pkgname . cd test-pkgname TESTPKGVER=1.0_p1 atf_check -s exit:0 \ @@ -494,6 +494,12 @@ abuild_warn_pkgver_patch_version_body() { TESTPKGVER=1.0p1 atf_check -s exit:0 \ -e match:'WARNING.*1.0_p1' \ abuild sanitycheck + TESTPKGVER=1.0a1 atf_check -s exit:0 \ + -e match:'WARNING.*1.0_alpha1' \ + abuild sanitycheck + TESTPKGVER=1.0b10 atf_check -s exit:0 \ + -e match:'WARNING.*1.0_beta10' \ + abuild sanitycheck } abuild_multiline_license_body() {