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 <yturgema@redhat.com>
This commit is contained in:
Yuval Turgeman 2019-08-05 20:01:52 +02:00 committed by Javier Martinez Canillas
parent 4009bc7ed4
commit 9baffd002d
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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 <yturgema@redhat.com> - 8.40-36
- grubby-bls: strip only /boot from paths
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-35
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild