Commit 796c05c6 authored by Kevin Daudt's avatar Kevin Daudt Committed by Leo

apkbuild-lint: warn on pkgname in source even with archive name

The check for pkgname in the source url assumed the value started with
the url protocol. This is not the case when a custom archive name has
been specified.

Fix this by allowing an optional archive name followed by `::` before
the actual url.

Fixes #22
parent 4942c9e3
......@@ -224,7 +224,7 @@ literal_integer_is_quoted() {
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'
scan '^source="(.*?::)?[a-z]+://[^"]+\$\{?pkgname\}?' '$pkgname should not be used in the source url' 'AL29' 'MC'
}
double_underscore_in_variable() {
......
......@@ -554,6 +554,16 @@ is_travis() {
assert_match "${lines[0]}" "\[AL29\].*:.*$pkgname should not be used in the source url"
}
@test '\"\$pkgname\" should not be used in source url with archive name' {
cat <<-"EOF" >$apkbuild
source="\$pkgname-\$pkgver.tar.gz::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"
}
@test 'double underscore in variable' {
cat <<-"EOF" >$apkbuild
__invalid=1.0
......
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