Bug#931499: initramfs hook scripts which use log_* functions die
Package: initramfs-tools-core
Version: 0.133
initramfs hook scripts which source
. /usr/share/initramfs-tools/scripts/functions
and then later use one of the log_*() functions such as
log_begin_msg "Installing terminfo entries: $tinfos"
will make the hook script fail with the message "quiet: parameter not
set", which will make the invoking "update-initramfs" also fail as a
consequence.
The reason is simple: The script contains a parameter expansion
$ grep -F 'quiet?' /usr/share/initramfs-tools/scripts/functions
if [ "${quiet?}" = "y" ]; then return; fi
which will fail if "$quiet" is not defined at all at this place. This
can easily be tested as follows:
$ (set +e; unset quiet; echo "${quiet?}"; echo "RC: $?")
-bash: quiet: parameter not set
Note that this failure was so severe that the whole subshell terminated
even though "set -e" has been disabled!
The easiest way to make to problem go away would be to set the variable
if it is not defined, because this works:
$ (set +e; : ${quiet:=}; echo "${quiet?}"; echo "RC: $?")
RC: 0
It would suffice to add a line
: ${quiet:=}
or maybe better
: ${quiet:=n}
somewhere outside of any function to the file
/usr/share/initramfs-tools/scripts/functions.
I am using Debian 10 on branch "buster"
on branch ascii
with kernel
Linux 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64
GNU/Linux
Reply to: