Skip to content

Commit

Permalink
fix(dracut.sh): add missing default output file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
aafeijoo-suse authored and johannbg committed Apr 25, 2022
1 parent ab6f573 commit 28ef3bc
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 28ef3bc

Please sign in to comment.