]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut.sh): add missing default output file paths
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Fri, 22 Apr 2022 16:21:45 +0000 (18:21 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Mon, 25 Apr 2022 21:29:30 +0000 (21:29 +0000)
dracut.sh

index 66a4ed0789c51258531a838850e8a44afb63b470..94a3b068da29bbd99cb6dadf33d247aeb45b1b7e 100755 (executable)
--- 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