abuild: warn for more version suffixes

give a warning when version suffix a<digit>/b<digit> probably should be
_alpha<digit>/_beta<digit>.

ref: https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10972#note_380899
This commit is contained in:
Natanael Copa 2024-03-13 11:43:10 +01:00
parent 648529aa35
commit 8da2501613
2 changed files with 18 additions and 6 deletions

View File

@ -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 <letter><digit> should be <suffix><digit>
# 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"

View File

@ -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() {