From 27f50aef9acdd0ec6a06eff8c48cf96c2ca840fc Mon Sep 17 00:00:00 2001 From: Roland Clobus Date: Sat, 4 Mar 2023 10:26:02 +0100 Subject: [PATCH] Use either ${LIVE_BUILD}/share/hooks or /usr/share/live/build/hooks, not both --- scripts/build/binary_hooks | 21 +-------------------- scripts/build/chroot_hooks | 32 +------------------------------- scripts/build/config | 10 ++++++++-- scripts/build/source_hooks | 21 +-------------------- 4 files changed, 11 insertions(+), 73 deletions(-) diff --git a/scripts/build/binary_hooks b/scripts/build/binary_hooks index 7d442957a..3a42fa189 100755 --- a/scripts/build/binary_hooks +++ b/scripts/build/binary_hooks @@ -32,26 +32,7 @@ Check_stagefile # Acquire lock file Acquire_lockfile -## Processing distribution hooks - -# Running hooks -for _HOOK in ${LB_BINARY_HOOKS} -do - for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks - do - for FILE in "${LOCATION}"/????-"${_HOOK}".binary - do - if [ -e "${FILE}" ] - then - cd binary - "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} - cd "${OLDPWD}" - fi - done - done -done - -## Processing local hooks +## Processing hooks for HOOK in config/hooks/normal/*.binary config/hooks/live/*.binary do if [ ! -e "${HOOK}" ] diff --git a/scripts/build/chroot_hooks b/scripts/build/chroot_hooks index 4e3702b14..df0a427dc 100755 --- a/scripts/build/chroot_hooks +++ b/scripts/build/chroot_hooks @@ -32,8 +32,6 @@ Check_stagefile # Acquire lock file Acquire_lockfile -## Processing distribution hooks - # Make build config available to chroot hooks. First, make the bind # mount and then make it read-only. This can't happen in one mount # command, then the resulting mount will be rw (see mount(8)). Making it @@ -43,35 +41,7 @@ mkdir -p chroot/live-build/config mount -o bind config chroot/live-build/config mount -o remount,ro,bind config chroot/live-build/config -# Copying hooks -mkdir -p chroot/root/lb_chroot_hooks -for _HOOK in ${LB_CHROOT_HOOKS} -do - for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks - do - for FILE in "${LOCATION}"/????-"${_HOOK}".chroot - do - if [ -e "${FILE}" ] - then - cp "${FILE}" chroot/root/lb_chroot_hooks - fi - done - done -done - -# Running hooks -if ls chroot/root/lb_chroot_hooks/* > /dev/null 2>&1 -then - for _HOOK in chroot/root/lb_chroot_hooks/* - do - Chroot chroot "/root/lb_chroot_hooks/$(basename ${_HOOK})" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} - rm -f chroot/root/lb_chroot_hooks/"$(basename ${_HOOK})" - done -fi -rmdir chroot/root/lb_chroot_hooks -rmdir --ignore-fail-on-non-empty chroot/root - -## Processing local hooks +## Processing hooks if ls config/hooks/normal/*.chroot > /dev/null 2>&1 && ( ls config/hooks/live/*.chroot > /dev/null 2>&1 || ls config/hooks/live/*.container > /dev/null 2>&1 ) diff --git a/scripts/build/config b/scripts/build/config index 6bc72476c..8b8010acb 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -1347,8 +1347,14 @@ mkdir -p config/rootfs mkdir -p local/bin Echo_message "Symlinking hooks..." +if [ -n "${LIVE_BUILD}" ] && [ -d "${LIVE_BUILD}/share/hooks" ] +then + LOCATION="${LIVE_BUILD}/share/hooks" +else + LOCATION=/usr/share/live/build/hooks +fi -for _HOOK in "${LIVE_BUILD}"/share/hooks/normal/*.hook* /usr/share/live/build/hooks/normal/*.hook* +for _HOOK in "${LOCATION}"/normal/*.hook* do if [ -e "${_HOOK}" ] && [ ! -e "config/hooks/normal/$(basename ${_HOOK})" ] then @@ -1356,7 +1362,7 @@ do fi done -for _HOOK in "${LIVE_BUILD}"/share/hooks/live/*.hook* /usr/share/live/build/hooks/live/*.hook* +for _HOOK in "${LOCATION}"/live/*.hook* do if [ -e "${_HOOK}" ] && [ ! -e "config/hooks/live/$(basename ${_HOOK})" ] then diff --git a/scripts/build/source_hooks b/scripts/build/source_hooks index 198073d5a..a47facc51 100755 --- a/scripts/build/source_hooks +++ b/scripts/build/source_hooks @@ -32,26 +32,7 @@ Check_stagefile # Acquire lock file Acquire_lockfile -## Processing distribution hooks - -# Running hooks -for _HOOK in ${LB_BINARY_HOOKS} -do - for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks - do - for FILE in "${LOCATION}"/????-"${_HOOK}".source - do - if [ -e "${FILE}" ] - then - cd source - "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} - cd "${OLDPWD}" - fi - done - done -done - -## Processing local hooks +## Processing hooks for HOOK in config/hooks/normal/*.source config/hooks/live/*.source do if [ ! -e "${HOOK}" ]