diff options
author | maxice8 <thinkabit.ukim@gmail.com> | 2018-12-06 05:59:19 +0000 |
---|---|---|
committer | Enno Boland <g@s01.de> | 2019-01-27 09:20:32 +0000 |
commit | c5d40ba0781fd48c7129d4ef1c247794bbf32ce2 (patch) | |
tree | d46ff59815c1b71db6d749eb4190464d0dbf409a | |
parent | b2b7380a91eb4e28fae448ac4736db5d9afda99c (diff) | |
download | void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.tar void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.tar.gz void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.tar.bz2 void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.tar.lz void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.tar.xz void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.tar.zst void-packages-c5d40ba0781fd48c7129d4ef1c247794bbf32ce2.zip |
hooks/pre-pkg: add pkglint-subpkgs hook
-rw-r--r-- | common/hooks/pre-pkg/99-pkglint-subpkgs.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh new file mode 100644 index 00000000000..13edbf0f4d9 --- /dev/null +++ b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh @@ -0,0 +1,44 @@ +# vim: set ts=4 sw=4 et: +# +# This hook executes the following tasks: +# - Warns if the main package is in subpackages= +# - Warns if a subpackage is unreachable (never appears in subpackages=) + +hook() { + local subpkgs matches + + # Run this only against the main package + if [ "$pkgname" != "$sourcepkg" ]; then + return 0 + fi + + if [ -z "$subpackages" ]; then + return 0 + fi + + subpkgs=$(get_subpkgs) + + subpackages="${subpackages// /$'\n'}" + + # Sort the strings so they can be compare for equality + subpkgs="$(printf "%s\\n" "$subpkgs" | sort)" + subpackages="$(printf "%s\\n" "$subpackages" | sort)" + + if [ "$subpackages" = "$subpkgs" ]; then + return 0 + fi + + # XXX: Make the sed call work when subpackages has multiple lines + # this can be done with grep with perl regexp (-P) but chroot-grep + # is compiled without it + matches="$(sed -n 's/subpackages.*"\(.*\)"[^"]*$/\1/p' $XBPS_SRCPKGDIR/$pkgname/template \ + | tr " " "\n" | sort)" + + for s in $subpkgs; do + grep -q "^$s" <<< "$matches" || + msg_warn "${s}_package() defined but will never be built.\n" + done + + grep -q "^$pkgname" <<< "$matches" && + msg_warn "$pkgname is sourcepkg but is in subpackages=.\n" +} |