From fd6c41ba14d31a2ef7b17e5ec762a4efef194b1a Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Fri, 27 Mar 2026 13:06:46 -0600 Subject: [PATCH] Change eghooks to be opt-in If not using --with-eghooks, do not install any example hooks in DATADIR --- BUILDING.md | 12 +++++++----- configure | 20 +++++++++++++++++--- hooks/Makefile | 14 ++++++++++---- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index b70022c82..9640629d6 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -176,13 +176,15 @@ Example: `make DESTDIR=/usr/src/contrib/dhcpcd import-src` ## Hooks Not all the hooks in dhcpcd-hooks are installed by default. -By default we install `01-test`, `20-resolv.conf`and `30-hostname`. -The other hooks, `10-wpa_supplicant`, `15-timezone` and `29-lookup-hostname` -are installed to `$(datadir)/dhcpcd/hooks` by default and need to be -copied to `$(libexecdir)/dhcpcd-hooks` for use. +By default we install `01-test`, `20-resolv.conf` and `30-hostname`. +The other hooks, `10-wpa_supplicant`, `15-timezone` and `29-lookup-hostname`, +plus any example hooks configure resolves (such as YP-related hooks when opted in), +are installed to `$(datadir)/dhcpcd/hooks` only when you pass `--with-eghook` or +`--with-eghooks` and at least one such hook is found; copy them from there to +`$(libexecdir)/dhcpcd-hooks` for use. The configure program attempts to find hooks for systems you have installed. To add more simply -`./configure -with-hook=ntp.conf` +`./configure --with-hook=ntp.conf` If using resolvconf, the `20-resolv.conf` hook now requires a version with the `-C` and `-c` options to deprecate and activate interfaces to support wireless diff --git a/configure b/configure index e9c08f180..724ca504d 100755 --- a/configure +++ b/configure @@ -6,6 +6,8 @@ exec 3>config.log # Ensure that we do not inherit these from env HOOKSET=false +EGHOOKSET=false +EGHOOKSCRIPTS= INET= ARP= ARPING= @@ -95,7 +97,7 @@ for x do PKG_CONFIG) PKG_CONFIG=$var;; --with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";; --with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;; - --with-eghook) EGHOOKSCRIPTS="$EGHOOKSCRIPTS${EGHOOKSCRIPTS+ }$var";; + --with-eghook) EGHOOKSCRIPTS="$EGHOOKSCRIPTS${EGHOOKSCRIPTS+ }$var"; EGHOOKSET=true;; --with-eghooks|EGHOOKSCRIPTS) EGHOOKSCRIPTS=$var; EGHOOKSET=true;; --with-default-hostname) _DEFAULT_HOSTNAME=$var;; --build) BUILD=$var;; @@ -1756,7 +1758,9 @@ if ! $HOOKSET; then echo "YPDOMAIN_SUFFIX=" >>$CONFIG_MK fi echo "$YPBIND ($YPHOOK${YPOS:+ }$YPOS)" - EGHOOKS="$EGHOOKS${EGHOOKS:+ }$YPHOOK" + if $EGHOOKSET; then + EGHOOKS="$EGHOOKS${EGHOOKS:+ }$YPHOOK" + fi else echo "not found" YPHOOK="50-ypbind" @@ -1786,7 +1790,9 @@ if ! $HOOKSET; then esac if [ -n "$YPHOOK" ]; then echo "Assuming ypbind is $YPOS" - EGHOOKS="$EGHOOKS${EGHOOKS:+ }$YPHOOK" + if $EGHOOKSET; then + EGHOOKS="$EGHOOKS${EGHOOKS:+ }$YPHOOK" + fi fi fi fi @@ -1842,6 +1848,9 @@ if cd hooks; then fi echo "HOOKSCRIPTS= $HOOKS" >>$CONFIG_MK echo "EGHOOKSCRIPTS= $EGHOOKS" >>$CONFIG_MK +if $EGHOOKSET && [ -n "$EGHOOKS" ]; then + echo "INSTALL_DATADIR_HOOKS= yes" >>$CONFIG_MK +fi echo echo " SYSCONFDIR = $SYSCONFDIR" @@ -1854,6 +1863,11 @@ echo " MANDIR = $MANDIR" echo " DATADIR = $DATADIR" echo " HOOKSCRIPTS = $HOOKS" echo " EGHOOKSCRIPTS = $EGHOOKS" +if $EGHOOKSET && [ -n "$EGHOOKS" ]; then + echo " INSTALL_DATADIR_HOOKS = yes" +else + echo " INSTALL_DATADIR_HOOKS = no" +fi echo " STATUSARG = $STATUSARG" if [ "$PRIVSEP" = yes ]; then echo " PRIVSEPUSER = $PRIVSEP_USER" diff --git a/hooks/Makefile b/hooks/Makefile index aee0255c6..b3219b0a1 100644 --- a/hooks/Makefile +++ b/hooks/Makefile @@ -52,8 +52,10 @@ proginstall: ${PROG} ${SCRIPTS} rm -f ${DESTDIR}${SCRIPTSDIR}/10-mtu eginstall: ${FILES} - ${INSTALL} -d ${DESTDIR}${FILESDIR} - ${INSTALL} -m ${NONBINMODE} ${FILES} ${DESTDIR}${FILESDIR} + @if [ "${INSTALL_DATADIR_HOOKS}" = yes ]; then \ + ${INSTALL} -d ${DESTDIR}${FILESDIR}; \ + ${INSTALL} -m ${NONBINMODE} ${FILES} ${DESTDIR}${FILESDIR}; \ + fi maninstall: ${MAN8} ${INSTALL} -d ${DESTDIR}${MANDIR}/man8 @@ -64,12 +66,16 @@ install: proginstall eginstall maninstall import: ${SCRIPTS} ${FILES} ${INSTALL} -d /tmp/${DISTPREFIX}/dhcpcd-hooks ${INSTALL} -m ${NONBINMODE} ${SCRIPTS} /tmp/${DISTPREFIX}/dhcpcd-hooks - ${INSTALL} -m ${NONBINMODE} ${FILES} /tmp/${DISTPREFIX}/dhcpcd-hooks + @if [ "${INSTALL_DATADIR_HOOKS}" = yes ]; then \ + ${INSTALL} -m ${NONBINMODE} ${FILES} /tmp/${DISTPREFIX}/dhcpcd-hooks; \ + fi _import-src: all ${INSTALL} -d ${DESTDIR}/hooks ${INSTALL} -m ${NONBINMODE} ${PROG} ${MAN8} ${DESTDIR}/hooks ${INSTALL} -m ${NONBINMODE} ${SCRIPTS} ${DESTDIR}/hooks - ${INSTALL} -m ${NONBINMODE} ${FILES} ${DESTDIR}/hooks + @if [ "${INSTALL_DATADIR_HOOKS}" = yes ]; then \ + ${INSTALL} -m ${NONBINMODE} ${FILES} ${DESTDIR}/hooks; \ + fi include ${TOP}/Makefile.inc