diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2014-10-13 04:12:57 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2014-10-13 04:12:57 +0100 |
commit | 85295509a63e5d454574e1f395978e8f404d4ba5 (patch) | |
tree | 620b0f412e6b9c84a7cbdba5c8a6dfe0648fe5b7 /scripts/functions | |
parent | bf238f6aceb206e25969d64f5b496eb5d051f481 (diff) |
Move get_source, set_initlist, get_prereq_pairs, call_scripts to hook-functions
These functions are not needed at boot time.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 94 |
1 files changed, 0 insertions, 94 deletions
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() { |