These functions are not needed at boot time. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> --- hook-functions | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/functions | 94 ------------------------------------------------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/hook-functions b/hook-functions index 957e4c2..acac222 100644 --- a/hook-functions +++ b/hook-functions @@ -577,6 +577,76 @@ EOF } +# Find the source for a script file. This is needed to work around +# temporary directories mounted with the noexec option. The source +# will be on / or /usr which must be executable. +get_source() +{ + if [ -z "$scriptdir" ]; then + echo "${initdir}/$1" + elif [ -f "${CONFDIR}${scriptdir}/$1" ]; then + echo "${CONFDIR}${scriptdir}/$1" + else + echo "/usr/share/initramfs-tools${scriptdir}/$1" + fi +} + +set_initlist() +{ + unset initlist + for si_x in ${initdir}/*; do + # skip empty dirs without warning + [ "${si_x}" = "${initdir}/*" ] && return + + # only allow variable name chars + case ${si_x#${initdir}/} in + *[![:alnum:]\._-]*) + [ "${verbose}" = "y" ] \ + && echo "$si_x ignored: not alphanumeric or '_' file" >&2 + continue + ;; + esac + + # skip directories + if [ -d ${si_x} ]; then + [ "${verbose}" = "y" ] \ + && echo "$si_x ignored: a directory" >&2 + continue + fi + + si_x="$(get_source "${si_x#${initdir}/}")" + + # skip non executable scripts + if [ ! -x ${si_x} ]; then + [ "${verbose}" = "y" ] \ + && echo "$si_x ignored: not executable" >&2 + continue + fi + + # skip bad syntax + if ! sh -n ${si_x} ; then + [ "${verbose}" = "y" ] \ + && echo "$si_x ignored: bad syntax" >&2 + continue + fi + + initlist="${initlist:-} ${si_x##*/}" + done +} + +get_prereq_pairs() +{ + set_initlist + for gp_x in ${initlist:-}; do + echo ${gp_x} ${gp_x} + gp_src="$(get_source $gp_x)" + prereqs=$("${gp_src}" prereqs) + for prereq in ${prereqs}; do + echo ${prereq} ${gp_x} + done + done +} + # cache boot scripts order cache_run_scripts() { @@ -593,6 +663,30 @@ cache_run_scripts() done } +call_scripts() +{ + set -e + for cs_x in ${runlist}; do + [ -f ${initdir}/${cs_x} ] || continue + # mkinitramfs verbose output + if [ "${verbose}" = "y" ]; then + echo "Calling hook ${cs_x}" + fi + ${initdir}/${cs_x} && ec=$? || ec=$? + # allow hooks to abort build: + if [ "$ec" -ne 0 ]; then + echo "E: ${initdir}/${cs_x} failed with return $ec." + # only errexit on mkinitramfs + [ -n "${version}" ] && exit $ec + fi + # allow boot scripts to modify exported boot parameters + if [ -e /conf/param.conf ]; then + . /conf/param.conf + fi + done + set +e +} + run_scripts() { scriptdir=${2:-} diff --git a/scripts/functions b/scripts/functions index 7ae9ef3..c0dd684 100644 --- a/scripts/functions +++ b/scripts/functions @@ -68,100 +68,6 @@ render() eval "echo -n \${$@}" } -# Find the source for a script file. This is needed to work around -# temporary directories mounted with the noexec option. The source -# will be on / or /usr which must be executable. -get_source() -{ - if [ -z "$scriptdir" ]; then - echo "${initdir}/$1" - elif [ -f "${CONFDIR}${scriptdir}/$1" ]; then - echo "${CONFDIR}${scriptdir}/$1" - else - echo "/usr/share/initramfs-tools${scriptdir}/$1" - fi -} - -set_initlist() -{ - unset initlist - for si_x in ${initdir}/*; do - # skip empty dirs without warning - [ "${si_x}" = "${initdir}/*" ] && return - - # only allow variable name chars - case ${si_x#${initdir}/} in - *[![:alnum:]\._-]*) - [ "${verbose}" = "y" ] \ - && echo "$si_x ignored: not alphanumeric or '_' file" >&2 - continue - ;; - esac - - # skip directories - if [ -d ${si_x} ]; then - [ "${verbose}" = "y" ] \ - && echo "$si_x ignored: a directory" >&2 - continue - fi - - si_x="$(get_source "${si_x#${initdir}/}")" - - # skip non executable scripts - if [ ! -x ${si_x} ]; then - [ "${verbose}" = "y" ] \ - && echo "$si_x ignored: not executable" >&2 - continue - fi - - # skip bad syntax - if ! sh -n ${si_x} ; then - [ "${verbose}" = "y" ] \ - && echo "$si_x ignored: bad syntax" >&2 - continue - fi - - initlist="${initlist:-} ${si_x##*/}" - done -} - -get_prereq_pairs() -{ - set_initlist - for gp_x in ${initlist:-}; do - echo ${gp_x} ${gp_x} - gp_src="$(get_source $gp_x)" - prereqs=$("${gp_src}" prereqs) - for prereq in ${prereqs}; do - echo ${prereq} ${gp_x} - done - done -} - -call_scripts() -{ - set -e - for cs_x in ${runlist}; do - [ -f ${initdir}/${cs_x} ] || continue - # mkinitramfs verbose output - if [ "${verbose}" = "y" ]; then - echo "Calling hook ${cs_x}" - fi - ${initdir}/${cs_x} && ec=$? || ec=$? - # allow hooks to abort build: - if [ "$ec" -ne 0 ]; then - echo "E: ${initdir}/${cs_x} failed with return $ec." - # only errexit on mkinitramfs - [ -n "${version}" ] && exit $ec - fi - # allow boot scripts to modify exported boot parameters - if [ -e /conf/param.conf ]; then - . /conf/param.conf - fi - done - set +e -} - # For boot time only; this is overridden at build time in hook-functions run_scripts() { -- Ben Hutchings Any sufficiently advanced bug is indistinguishable from a feature.
Attachment:
signature.asc
Description: This is a digitally signed message part