From 66078fcba25ef899cef594f3ae1dbdd6dc13087b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Oct 2018 11:10:09 +0200 Subject: [PATCH] Update the saved entry correctly after a kernel install. Resolves: rhbz#1638117 Signed-off-by: Peter Jones --- 20-grub.install | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/20-grub.install b/20-grub.install index eda11d8..de1182f 100755 --- a/20-grub.install +++ b/20-grub.install @@ -76,8 +76,10 @@ case "$COMMAND" in fi if [[ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]] || [[ ! -f /sbin/new-kernel-pkg ]]; then + eval "$(grub2-get-kernel-settings)" || true [[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR" - BLS_TARGET="${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" + BLS_ID="${MACHINE_ID}-${KERNEL_VERSION}" + BLS_TARGET="${BLS_DIR}/${BLS_ID}.conf" if [[ -f "${KERNEL_DIR}/bls.conf" ]]; then cp -aT "${KERNEL_DIR}/bls.conf" "${BLS_TARGET}" || exit $? else @@ -96,17 +98,21 @@ case "$COMMAND" in sed -i -e "s,^initrd.*,initrd ${BOOTPREFIX}${INITRD},g" "${BLS_TARGET}" fi - eval "$(grub2-get-kernel-settings)" || true + NEWDEFAULT="${BLS_ID}" if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ARCH="$(uname -m)" + BLS_DEBUG_ID="$(echo ${BLS_ID} | sed -e "s/\.${ARCH}/-debug.${ARCH}/")" BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/\.${ARCH}/-debug.${ARCH}/")" cp -aT "${BLS_TARGET}" "${BLS_DEBUG}" TITLE="$(grep '^title[ \t]' "${BLS_DEBUG}" | sed -e 's/^title[ \t]*//')" - BLSID="$(grep '^id[ \t]' "${BLS_DEBUG}" | sed -e "s/\.${ARCH}/-debug.${ARCH}/")" sed -i -e "s/^title.*/title ${TITLE}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${BLS_DEBUG}" - sed -i -e "s/^id.*/${BLSID}/" "${BLS_DEBUG}" + sed -i -e "s/^id.*/id ${BLS_DEBUG_ID}/" "${BLS_DEBUG}" sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${BLS_DEBUG}" - fi + if [ "x$GRUB_UPDATE_DEFAULT_KERNEL" = "xtrue" -a "x$GRUB_DEFAULT_TO_DEBUG" = "xtrue" ]; then + NEWDEFAULT="${BLS_DEBUG_ID}" + fi + fi + grub2-editenv - set "saved_entry=${NEWDEFAULT}" exit 0 fi