summary refs log tree commit diff
diff options
context:
space:
mode:
authorclassabbyamp <dev@placeviolette.net>2022-05-16 16:09:26 -0400
committerLeah Neukirchen <leah@vuxu.org>2022-05-17 22:13:02 +0200
commit2e0da76fef5f6659e0e98d7166e4497d23565831 (patch)
tree74c5d484bcdfd5a9bbc9af97f4554776902a01f0
parent29d03d6dc621881b78699efecad895bb2017b5bb (diff)
downloadxtools-2e0da76fef5f6659e0e98d7166e4497d23565831.tar.gz
xtools-2e0da76fef5f6659e0e98d7166e4497d23565831.tar.xz
xtools-2e0da76fef5f6659e0e98d7166e4497d23565831.zip
xlint: check if manually defined wrksrc is default
also add a regex_escape filter to reduce false-positives in a couple
places

Closes: #242 [via git-merge-pr]
-rwxr-xr-xxlint9
1 files changed, 8 insertions, 1 deletions
diff --git a/xlint b/xlint
index df26d94..9839b97 100755
--- a/xlint
+++ b/xlint
@@ -15,6 +15,10 @@ scan() {
 		done
 }
 
+regex_escape() {
+	sed 's/\([.*+]\)/\\\1/g'
+}
+
 once() {
 	head -n 1
 }
@@ -468,8 +472,11 @@ for argument; do
 	scan '^\t*[^ ]*\(\)$' 'do not use a newline before function opening brace'
 	scan 'python_version=.*#[[:space:]]*unverified' 'verify python_version and remove "#unverified"'
 	pkgname=$(grep -Po "^pkgname=\K.*" "$template" | once)
+	pkgname_re=$(echo "$pkgname" | regex_escape)
 	version=$(grep -Po "^version=\K.*" "$template" | once)
-	scan "distfiles=.*\Q$version\E" 'use ${version} in distfiles instead'
+	version_re=$(echo "$version" | regex_escape)
+	scan '^wrksrc="?(\$\{?pkgname\}?|'$pkgname_re')-(\$\{?version\}?|'$version_re')"?$' 'unnecessary wrksrc definition'
+	scan "distfiles=.*\Q$version_re\E" 'use ${version} in distfiles instead'
 	scan "system_accounts=.*\b(?!($old_accounts))[a-zA-Z]" 'new accounts should be prefixed with underscore'
 	variables_order
 	header