From 9baffd002dd7d118ae60ac8c2cc8067af5927dda Mon Sep 17 00:00:00 2001 From: Yuval Turgeman Date: Mon, 5 Aug 2019 20:01:52 +0200 Subject: [PATCH] grubby-bls: strip only /boot from paths If the /boot directory is a mount point, then the paths of the kernel and initramfs images paths in the BLS snippet have to be relative to the root of the boot partition. So the /boot prefix has to be stripped from paths in this case. But the function was wrongly stripping the entire path instead of only the /boot prefix, which prevented having kernels and initrds in subdirectories. Signed-off-by: Yuval Turgeman --- grubby-bls | 18 ++++++++++-------- grubby.spec | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/grubby-bls b/grubby-bls index 274107f..90db0a5 100755 --- a/grubby-bls +++ b/grubby-bls @@ -544,24 +544,28 @@ set_default_bls() { } remove_var_prefix() { + local prefix="$1" + + [ -z "${prefix}" ] && return + if [[ -n $remove_kernel && $remove_kernel =~ ^/ ]]; then - remove_kernel="/${remove_kernel##*/}" + remove_kernel="/${remove_kernel##${prefix}/}" fi if [[ -n $initrd ]]; then - initrd="/${initrd##*/}" + initrd="/${initrd##${prefix}/}" fi if [[ -n $extra_initrd ]]; then - extra_initrd=" /${extra_initrd##*/}" + extra_initrd=" /${extra_initrd##${prefix}/}" fi if [[ -n $kernel ]]; then - kernel="/${kernel##*/}" + kernel="/${kernel##${prefix}/}" fi if [[ -n $update_kernel && $update_kernel =~ ^/ ]]; then - update_kernel="/${update_kernel##*/}" + update_kernel="/${update_kernel##${prefix}/}" fi } @@ -762,9 +766,7 @@ if [[ -n $display_info ]]; then display_info_values "${display_info}" fi -if [[ $(get_prefix) == "/boot" ]]; then - remove_var_prefix -fi +remove_var_prefix "$(get_prefix)" if [[ -n $kernel ]]; then if [[ $copy_default = "true" ]]; then diff --git a/grubby.spec b/grubby.spec index e0f13cc..152cc26 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 35%{?dist} +Release: 36%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Aug 06 2019 Yuval Turgeman - 8.40-36 +- grubby-bls: strip only /boot from paths + * Thu Jul 25 2019 Fedora Release Engineering - 8.40-35 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild