mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2025-01-12 01:39:45 +00:00
abuild: verify subpkgnames
Refactor pkgname check and also check subpkgnames Add tests for invalid subpkgnames
This commit is contained in:
parent
070341e21d
commit
8824e43ad9
20
abuild.in
20
abuild.in
@ -170,12 +170,18 @@ spell_error() {
|
|||||||
die "APKBUILD contains '$1'. It should be '$2'"
|
die "APKBUILD contains '$1'. It should be '$2'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_pkgname() {
|
||||||
|
local name=${1%%=*}
|
||||||
|
case "$name" in
|
||||||
|
""|*" "*|-*) return 1;;
|
||||||
|
esac
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# check if apkbuild is basically sane
|
# check if apkbuild is basically sane
|
||||||
default_sanitycheck() {
|
default_sanitycheck() {
|
||||||
local i= j= suggestion=
|
local i= j= suggestion=
|
||||||
msg "Checking sanity of $APKBUILD..."
|
msg "Checking sanity of $APKBUILD..."
|
||||||
[ -z "$pkgname" ] && die "Missing pkgname in APKBUILD"
|
|
||||||
[ -z "${pkgname##* *}" ] && die "pkgname contains spaces"
|
|
||||||
[ -z "$pkgver" ] && die "Missing pkgver in APKBUILD"
|
[ -z "$pkgver" ] && die "Missing pkgver in APKBUILD"
|
||||||
if [ "$pkgver" != "volatile" ] && [ -z "$nodeps" ]; then
|
if [ "$pkgver" != "volatile" ] && [ -z "$nodeps" ]; then
|
||||||
$APK version --check --quiet "$pkgver" ||\
|
$APK version --check --quiet "$pkgver" ||\
|
||||||
@ -203,11 +209,9 @@ default_sanitycheck() {
|
|||||||
die "provider_priority must be a number"
|
die "provider_priority must be a number"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check so no package names starts with -
|
# check pkgname and subpkgnames
|
||||||
for i in $pkgname $subpackages; do
|
for i in "$pkgname" $subpackages; do
|
||||||
case $i in
|
verify_pkgname "${i%%:*}" || die "${i%%:*} is not a valid package name"
|
||||||
-*) die "${i%%:*} is not a valid package name";;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $install; do
|
for i in $install; do
|
||||||
@ -462,7 +466,7 @@ initdcheck() {
|
|||||||
local i line
|
local i line
|
||||||
for i in $source; do
|
for i in $source; do
|
||||||
case $i in
|
case $i in
|
||||||
*.initd)
|
*.initd)
|
||||||
line=$(head -n 1 "$srcdir"/"$(filename_from_uri $i)")
|
line=$(head -n 1 "$srcdir"/"$(filename_from_uri $i)")
|
||||||
;;
|
;;
|
||||||
*) continue ;;
|
*) continue ;;
|
||||||
|
@ -230,3 +230,9 @@ teardown() {
|
|||||||
&& ! TESTNAME="name with spaces" $ABUILD sanitycheck
|
&& ! TESTNAME="name with spaces" $ABUILD sanitycheck
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "abuild: invalid subpkgnames" {
|
||||||
|
cd testrepo/test-pkgname
|
||||||
|
! TESTSUBNAME="" $ABUILD sanitycheck \
|
||||||
|
&& ! TESTSUBNAME="-foo" $ABUILD sanitycheck
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user