Commit f08798a7 authored by Kevin Daudt's avatar Kevin Daudt Committed by maxice8

Add pkgname-user-in-source

parent c96fbc83
......@@ -312,3 +312,14 @@ Severity: Serious, Certainty: Certain
A variable declaration containing only integers should not be quoted.
Severity: Minor, Certainty: Certain
## pkgname-used-in-source [AL29]
"$pkgname" is used in the source url. This tightly couples the pkgname to the
upstream name, which makes it harder to rename packages or create specialized /
variants of packages.
Instead, use the upstream name fully written out. This only counts for the url
itself, not the local archive name prefix.
Severity: Minor, Certainty: Certain
......@@ -221,6 +221,12 @@ literal_integer_is_quoted() {
scan '^[A-Za-z0-9_]*=('\''|")[0-9]+("|'\'')' 'literal integers must not be quoted' 'AL28' 'MC'
}
pkgname_used_in_source() {
[ "$SKIP_PKGNAME_USED_IN_SOURCE" ] && return 0
[ "$SKIP_AL29" ] && return 0
scan '^source="[a-z]+://[^"]+\$\{?pkgname\}?' '$pkgname should not be used in the source url' 'AL29' 'MC'
}
_run_apkbuild_leo() {
# Run all tests from Leo
pkgname_quoted &
......@@ -255,6 +261,7 @@ for apkbuild; do
space_after_function_parenthesis &
newline_opening_brace &
literal_integer_is_quoted &
pkgname_used_in_source &
# Don't perform these checks on packages from main
if ! [ -z "${apkbuild##*main/*}" ]; then
......
......@@ -532,4 +532,23 @@ is_travis() {
[[ $status -eq 0 ]]
}
@test '\"\$pkgname\" can be used as archive name in source' {
cat <<-"EOF" >$apkbuild
source="\$pkgname-$pkver.tar.gz::http://domain.com/my_package/\$pkgver.tar.gz"
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test '\"\$pkgname\" should not be used in source url' {
cat <<-"EOF" >$apkbuild
source="http://domain.com/\$pkgname/\$pkgver"
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL29\].*:.*$pkgname should not be used in the source url"
}
# vim: noexpandtab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment