2018-12-06 05:59:19 +00:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
# Sort the strings so they can be compare for equality
|
2020-12-05 01:13:56 +00:00
|
|
|
subpkgs="$(printf '%s\n' $subpkgs | sort)"
|
|
|
|
subpackages="$(printf '%s\n' $subpackages | sort)"
|
2018-12-06 05:59:19 +00:00
|
|
|
|
|
|
|
if [ "$subpackages" = "$subpkgs" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2020-12-05 01:13:56 +00:00
|
|
|
# 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 |
|
2020-12-07 13:02:47 +00:00
|
|
|
tr '\v\t\r\n' ' ')"
|
2018-12-06 05:59:19 +00:00
|
|
|
|
|
|
|
for s in $subpkgs; do
|
2020-12-07 13:02:47 +00:00
|
|
|
case " $matches " in
|
|
|
|
*" $s "*) ;;
|
|
|
|
*) msg_warn "${s}_package() defined but will never be built.\n" ;;
|
|
|
|
esac
|
2018-12-06 05:59:19 +00:00
|
|
|
done
|
|
|
|
|
2020-12-07 13:02:47 +00:00
|
|
|
case " $matches " in
|
|
|
|
*" $pkgname "*)
|
|
|
|
msg_warn "$pkgname is sourcepkg but is in subpackages=.\n" ;;
|
|
|
|
esac
|
2018-12-06 05:59:19 +00:00
|
|
|
}
|