Skip to content

Commit

Permalink
95-efistub-kernel-bootcfg.install: make shellcheck happy
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Apr 3, 2024
1 parent fbfe150 commit 5eb704e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions hooks/systemd/95-efistub-kernel-bootcfg.install
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#shellcheck disable=SC2034

# Copyright 2023-2024 Gentoo Authors
# This script is installed by sys-kernel/installkernel, it is executed by
Expand Down Expand Up @@ -26,18 +27,18 @@ if [[ ${KERNEL_INSTALL_LAYOUT} == "uki" ]]; then
exit 1
fi

PARTLABEL="$(df ${UKI} --output=source | tail -1 | xargs -r lsblk --output=PARTLABEL --noheadings)"
PARTLABEL="$(df "${UKI}" --output=source | tail -1 | xargs -r lsblk --output=PARTLABEL --noheadings)"
if [[ -n "${PARTLABEL}" ]]; then
TITLE="${KERNEL_VERSION} (UKI) on ${PARTLABEL}"
else
TITLE="${KERNEL_VERSION} (UKI)"
fi

[[ "${KERNEL_INSTALL_VERBOSE}" -gt 0 ]] && echo "Adding ${UKI} to UEFI boot entries"
kernel-bootcfg ${LOGLEVEL} --add-uki "${UKI}" --title "${TITLE}" --once || exit 1
kernel-bootcfg "${LOGLEVEL}" --add-uki "${UKI}" --title "${TITLE}" --once || exit 1
elif [[ ${COMMAND} == remove ]]; then
[[ "${KERNEL_INSTALL_VERBOSE}" -gt 0 ]] && echo "Removing ${UKI} from UEFI boot entries"
kernel-bootcfg ${LOGLEVEL} --remove-uki "${UKI}" || exit 1
kernel-bootcfg "${LOGLEVEL}" --remove-uki "${UKI}" || exit 1
fi
elif [[ ${KERNEL_INSTALL_LAYOUT} == "efistub" ]]; then
KERNEL_IMAGE="${KERNEL_INSTALL_BOOT_ROOT}/EFI/Gentoo/kernel-${KERNEL_VERSION}.efi"
Expand All @@ -50,7 +51,7 @@ elif [[ ${KERNEL_INSTALL_LAYOUT} == "efistub" ]]; then
fi

KERNEL_BOOTCFG_ARGS=(
${LOGLEVEL}
"${LOGLEVEL}"
--once
)

Expand All @@ -69,7 +70,7 @@ elif [[ ${KERNEL_INSTALL_LAYOUT} == "efistub" ]]; then

# Append initramfs to cmdline if it exists
if [[ -f ${INITRD} ]]; then
INITRD_EFI_PATH="${INITRD#${KERNEL_INSTALL_BOOT_ROOT}}"
INITRD_EFI_PATH="${INITRD#"${KERNEL_INSTALL_BOOT_ROOT}"}"
INITRD_EFI_PATH_DOS="${INITRD_EFI_PATH//\//\\}"
BOOT_OPTIONS="${BOOT_OPTIONS} initrd=${INITRD_EFI_PATH_DOS}"
fi
Expand All @@ -78,7 +79,7 @@ elif [[ ${KERNEL_INSTALL_LAYOUT} == "efistub" ]]; then
KERNEL_BOOTCFG_ARGS+=( --cmdline "${BOOT_OPTIONS}" )
fi

PARTLABEL="$(df ${KERNEL_IMAGE} --output=source | tail -1 | xargs -r lsblk --output=PARTLABEL --noheadings)"
PARTLABEL="$(df "${KERNEL_IMAGE}" --output=source | tail -1 | xargs -r lsblk --output=PARTLABEL --noheadings)"
if [[ -n "${PARTLABEL}" ]]; then
TITLE="${KERNEL_VERSION} (plain) on ${PARTLABEL}"
else
Expand All @@ -94,7 +95,7 @@ elif [[ ${KERNEL_INSTALL_LAYOUT} == "efistub" ]]; then
kernel-bootcfg "${KERNEL_BOOTCFG_ARGS[@]}" || exit 1
elif [[ ${COMMAND} == remove ]]; then
[[ "${KERNEL_INSTALL_VERBOSE}" -gt 0 ]] && echo "Removing ${KERNEL_IMAGE} from UEFI boot entries"
kernel-bootcfg ${LOGLEVEL} --remove-uki "${KERNEL_IMAGE}" || exit 1
kernel-bootcfg "${LOGLEVEL}" --remove-uki "${KERNEL_IMAGE}" || exit 1
fi
else
exit 0
Expand Down

0 comments on commit 5eb704e

Please sign in to comment.