From 28ef3bc6a6f1efcd8d8c16228a6dee9d563342e7 Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Fri, 22 Apr 2022 18:21:45 +0200 Subject: [PATCH] fix(dracut.sh): add missing default output file paths --- dracut.sh | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/dracut.sh b/dracut.sh index 66a4ed0789..94a3b068da 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1028,7 +1028,15 @@ stdloglvl=$((stdloglvl + verbosity_mod_l)) if ! [[ $outfile ]]; then if [[ $machine_id != "no" ]]; then - [[ -f "$dracutsysrootdir"/etc/machine-id ]] && read -r MACHINE_ID < "$dracutsysrootdir"/etc/machine-id + if [[ -d "$dracutsysrootdir"/efi/Default ]] \ + || [[ -d "$dracutsysrootdir"/boot/Default ]] \ + || [[ -d "$dracutsysrootdir"/boot/efi/Default ]]; then + MACHINE_ID="Default" + elif [[ -f "$dracutsysrootdir"/etc/machine-id ]]; then + read -r MACHINE_ID < "$dracutsysrootdir"/etc/machine-id + else + MACHINE_ID="Default" + fi fi if [[ $uefi == "yes" ]]; then @@ -1052,7 +1060,7 @@ if ! [[ $outfile ]]; then efidir=/efi/EFI else efidir=/boot/EFI - if [[ -d $dracutsysrootdir/boot/efi/EFI ]]; then + if [[ -d /boot/efi/EFI ]]; then efidir=/boot/efi/EFI fi fi @@ -1065,12 +1073,28 @@ if ! [[ $outfile ]]; then mkdir -p "$dracutsysrootdir$efidir/Linux" outfile="$dracutsysrootdir$efidir/Linux/linux-$kernel${MACHINE_ID:+-${MACHINE_ID}}${BUILD_ID:+-${BUILD_ID}}.efi" else - if [[ -e $dracutsysrootdir/boot/vmlinuz-$kernel ]]; then - outfile="/boot/initramfs-$kernel.img" - elif [[ $MACHINE_ID ]] && { [[ -d $dracutsysrootdir/boot/${MACHINE_ID} ]] || [[ -L $dracutsysrootdir/boot/${MACHINE_ID} ]]; }; then - outfile="$dracutsysrootdir/boot/${MACHINE_ID}/$kernel/initrd" + if [[ -d "$dracutsysrootdir"/efi/loader/entries || -L "$dracutsysrootdir"/efi/loader/entries ]] \ + && [[ $MACHINE_ID ]] \ + && [[ -d "$dracutsysrootdir"/efi/${MACHINE_ID} || -L "$dracutsysrootdir"/efi/${MACHINE_ID} ]]; then + outfile="$dracutsysrootdir/efi/${MACHINE_ID}/${kernel}/initrd" + elif [[ -d "$dracutsysrootdir"/boot/loader/entries || -L "$dracutsysrootdir"/boot/loader/entries ]] \ + && [[ $MACHINE_ID ]] \ + && [[ -d "$dracutsysrootdir"/boot/${MACHINE_ID} || -L "$dracutsysrootdir"/boot/${MACHINE_ID} ]]; then + outfile="$dracutsysrootdir/boot/${MACHINE_ID}/${kernel}/initrd" + elif [[ -d "$dracutsysrootdir"/boot/efi/loader/entries || -L "$dracutsysrootdir"/boot/efi/loader/entries ]] \ + && [[ $MACHINE_ID ]] \ + && [[ -d "$dracutsysrootdir"/boot/efi/${MACHINE_ID} || -L "$dracutsysrootdir"/boot/efi/${MACHINE_ID} ]]; then + outfile="$dracutsysrootdir/boot/efi/${MACHINE_ID}/${kernel}/initrd" + elif [[ -f "$dracutsysrootdir"/lib/modules/${kernel}/initrd ]]; then + outfile="$dracutsysrootdir/lib/modules/${kernel}/initrd" + elif [[ -e $dracutsysrootdir/boot/vmlinuz-${kernel} ]]; then + outfile="$dracutsysrootdir/boot/initramfs-${kernel}.img" + elif [[ -z $dracutsysrootdir ]] && mountpoint -q /efi; then + outfile="/efi/${MACHINE_ID}/${kernel}/initrd" + elif [[ -z $dracutsysrootdir ]] && mountpoint -q /boot/efi; then + outfile="/boot/efi/${MACHINE_ID}/${kernel}/initrd" else - outfile="$dracutsysrootdir/boot/initramfs-$kernel.img" + outfile="$dracutsysrootdir/boot/initramfs-${kernel}.img" fi fi fi