Files
ports/.hooks/pre-commit.d/check_category_makefile
T
Luca Pizzamiglio 302c208fc5 Component: git hooks
Add common error function in hooks
Error messages are printed in stderr

Reviewed By: tcberner, #portmgr
Differential Revision: https://reviews.freebsd.org/D38026
2023-01-12 22:09:50 +01:00

23 lines
703 B
Bash
Executable File

#!/bin/sh
#
# Check that ports are hooked into the build
#
common_functions="$(realpath "$(dirname "$0")")/common.sh"
if [ -r "${common_functions}" ]; then
. "${common_functions}"
fi
newish_makefiles=$(git diff --name-only --cached --diff-filter=ACR | grep -E '^[^/]+/[^/]+/Makefile$')
if [ $? -eq 0 ] ; then
for newish_makefile in ${newish_makefiles} ; do
category=$(echo "${newish_makefile}" | awk -F '/' '{print $1}')
port=$(echo "${newish_makefile}" | awk -F '/' '{print $2}')
grep -q -E "^[[:space:]]+SUBDIR[[:space:]]\+=[[:space:]]*${port}\$" ${category}/Makefile
if [ $? -ne 0 ] ; then
pre_commit_error "Missing 'SUBDIR += ${port}' in ${category}/Makefile"
exit 1
fi
done
fi