diff options
-rw-r--r-- | common/hooks/pre-pkg/99-pkglint-subpkgs.sh | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh index add7fdd4a07..fd1fee6c445 100644 --- a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh +++ b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh @@ -18,21 +18,27 @@ hook() { 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)" + 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)" + # sed supports comment but let's put them here + # 1: print everything between pairs of <""> in subpackages[+]?="..." + # 2: multiline subpackages="...\n..." + # 2.1: For any line in the middle, i.e. no <"> exists, print it + # 2.2: For the first line, print everything after <"> + # 2.3: For last line, print everything before <"> + matches="$(sed -n -e 's/subpackages.*"\(.*\)"[^"]*$/\1/p' \ + -e '/subpackages[^"]*"[^"]*$/,/"/{ + /"/!p + /subpackages/s/.*"//p + s/".*//p + }' $XBPS_SRCPKGDIR/$pkgname/template | + tr ' ' '\n' | sort)" for s in $subpkgs; do grep -q "^$s$" <<< "$matches" || |