From 6cdfe45ecebc63eada09b31d09eb9506db573ffd Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 17 Nov 2018 00:03:02 +0100 Subject: [PATCH] grubby-bls: print the absolute kernel and initramfs images paths The BLS file "linux" and "initrd" fields expect a relative paths from the root of the partition that contains the kernel and initramfs. The grubby tool was printing the value of thse fields and not their full path. So if there is a partition and /boot is a mount point, he BLS would have: linux /vmlinuz-4.18.0-38.el8.x86_64 initrd /initramfs-4.18.0-38.el8.x86_64.img And grubby would print: kernel="/vmlinuz-4.18.0-38.el8.x86_64" initrd="/initramfs-4.18.0-38.el8.x86_64.img" But the old tool used to print the full paths of the images, so should be: kernel="/boot/vmlinuz-4.18.0-38.el8.x86_64" initrd="/boot/initramfs-4.18.0-38.el8.x86_64.img" Resolves: rhbz#1649778 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/grubby-bls b/grubby-bls index 71dcb31..add7b0a 100755 --- a/grubby-bls +++ b/grubby-bls @@ -206,8 +206,17 @@ param_to_indexes() { echo -n "-1" } +get_prefix() { + if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then + echo "/boot" + else + echo "" + fi +} + display_info_values() { local indexes=($(param_to_indexes "$1")) + local prefix=$(get_prefix) if [[ $indexes = "-1" ]]; then print_error "The param $1 is incorrect" @@ -215,9 +224,9 @@ display_info_values() { for i in ${indexes[*]}; do echo "index=$i" - echo "kernel=\"${bls_linux[$i]}\"" + echo "kernel=\"${prefix}${bls_linux[$i]}\"" echo "args=\"${bls_options[$i]}\"" - echo "initrd=\"${bls_initrd[$i]}\"" + echo "initrd=\"${prefix}${bls_initrd[$i]}\"" echo "title=\"${bls_title[$i]}\"" echo "id=\"${bls_id[$i]}\"" done @@ -231,6 +240,11 @@ mkbls() { local debugname="" local flavor="" + local prefix="" + + if [[ $(get_prefix) = "" ]]; then + prefix="/boot" + fi if [[ $kernelver == *\+* ]] ; then local flavor=-"${kernelver##*+}" @@ -244,7 +258,7 @@ mkbls() { title ${NAME} (${kernelver}) ${VERSION}${debugname} version ${kernelver}${debugid} linux ${kernel} -initrd /initramfs-${kernelver}.img +initrd ${prefix}/initramfs-${kernelver}.img options \$kernelopts id ${ID}-${datetime}-${kernelver}${debugid} grub_users \$grub_users @@ -468,7 +482,7 @@ set_default_bls() { fi fi - print_info "The default is ${bls_file[$index]} with index $index and kernel ${bls_linux[$index]}" + print_info "The default is ${bls_file[$index]} with index $index and kernel $(get_prefix)${bls_linux[$index]}" } remove_var_prefix() { @@ -686,7 +700,7 @@ if [[ -n $display_info ]]; then display_info_values "${display_info}" fi -if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then +if [[ $(get_prefix) == "/boot" ]]; then remove_var_prefix fi