about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README3
-rwxr-xr-xxlint96
2 files changed, 98 insertions, 1 deletions
diff --git a/README b/README
index d66cc47..824a813 100644
--- a/README
+++ b/README
@@ -10,6 +10,7 @@ https://github.com/voidlinux/xbps
   xgensum [-i] TEMPLATE - update SHA256 sums in templates
   xgrep PATTERN PKGS... - search files limited to XBPS package contents
   xlg PKG - open short commit log for XBPS template
+  xlint TEMPLATE - scan XBPS template for common mistakes
   xlocate PATTERN - locate files in all XBPS packages
   xlog PKG - open commit log for XBPS template
   xls PKGS... - list files contained in PKGS (including binpkgs)
@@ -19,7 +20,7 @@ https://github.com/voidlinux/xbps
   xoptdiff [-q] [PKGS...] - show template options which differ from binary package
   xq [-R] PKGS... - query information about XBPS package
   xsrc PKG - list source files for XBPS template
-  xsubpkg PKG - list all subpackages of a package based on srcpkgs dir
+  xsubpkg PKG - lists all subpackages of a package
 
 Tools working on the void-packages tree use xdistdir to find it,
 check it's output is reasonable first.
diff --git a/xlint b/xlint
new file mode 100755
index 0000000..083dc53
--- /dev/null
+++ b/xlint
@@ -0,0 +1,96 @@
+#!/bin/sh
+# xlint TEMPLATE - scan XBPS template for common mistakes
+
+scan() {
+	local rx=$1 msg=$2 limit=${3:-1}
+	grep -P -Hn -m$limit -e "$rx" "$template" |
+		sed "s/^\([^:]*:[^:]*:\)\(.*\)/\1 $msg/"
+}
+
+variables="#.*
+_.*
+.*_descr
+.*_homedir
+.*_shell
+CFLAGS
+CPPFLAGS
+CXXFLAGS
+LDFLAGS
+XBPS_FETCH_COMMAND
+bootstrap
+broken
+build_options
+build_style
+build_wrksrc
+checksum
+conf_files
+configure_args
+configure_script
+conflicts
+create_wrksrc
+depends
+desc_option_.*
+disable_parallel_build
+distfiles
+dkms_modules
+force_debug_pkgs
+font_dirs
+homepage
+hostmakedepends
+keep_libtool_archives
+lib32disabled
+lib32mode
+license
+maintainer
+make_build_args
+make_build_args
+make_dirs
+make_install_args
+make_install_target
+makedepends
+mutable_files
+noarch
+nocross
+nonfree
+nostrip
+nostrip_files
+noverifyrdeps
+only_for_archs
+patch_args
+pkgname
+provides
+pycompile_dirs
+pycompile_module
+pycompile_version
+python_versions
+register_shell
+replaces
+revision
+sgml_entries
+short_desc
+skip_extraction
+subpackages
+system_accounts
+system_groups
+systemd_services
+triggers
+version
+wrksrc
+xml_entries"
+
+for template; do
+	scan 'short_desc=.*\."' "unwanted trailing dot in short_desc"
+	scan 'short_desc=["'\''][a-z]' "short_desc should start uppercase"
+	scan 'short_desc=["'\''].{72}' "short_desc should be less than 72 chars"
+	scan 'license=.*GPL[^-]' "license GPL without version"
+	scan 'vinstall.* usr/bin' "use vbin" -1
+	scan 'vinstall.* usr/share/man' "use vman" -1
+	scan 'vinstall.* usr/share/licenses' "use vlicense" -1
+	scan '^  ' "indent with tabs"
+	scan '`' "use \$() instead of backticks" -1
+	scan 'replaces=[^<>]*$' "replaces needs depname with version"
+	scan 'conflicts=[^<>]*$' "conflicts needs depname with version"
+	scan 'maintainer=(?!.*<.*@.*>).*' "maintainer needs email address"
+	scan '^(?!\s*('"$(echo -n "$variables" | tr '\n' '|')"'))[^\s=-]+=' \
+		"custom variables should use _ prefix: \2" -1
+done