hooks/fsck: Fix invocation of fstype at build time

get_fstab prefers to use the fstype utility (from klibc) and then
falls back to blkid.  Since klibc utilities are not in $PATH at build
time, get_fsck_type_fstab defines fstype as an alias for its full
filename before calling get_fstab.

This never actually worked, because aliases are expanded during
function definition, not execution.

Replacing the alias and unalias with a shell function definition and
an 'unset -f' solves the problem.

Thanks: Simon Tatham <anakin@pobox.com>
Closes: #865691
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
Ben Hutchings 2018-07-18 00:59:46 +01:00
parent 5bf4c29af2
commit e8377b3c5f

View File

@ -59,9 +59,9 @@ get_fsck_type_fstab () {
# therefore never used at boot time
if [ "${MNT_DIR}" = "/" ] || [ "${MNT_TYPE}" = "auto" ]; then
MNT_FSNAME="$(resolve_device "${MNT_FSNAME}")"
alias fstype="/usr/lib/klibc/bin/fstype"
fstype() { "/usr/lib/klibc/bin/fstype" "$@"; }
get_fstype "${MNT_FSNAME}"
unalias fstype
unset -f fstype
else
echo "${MNT_TYPE}"
fi