]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut.sh: add default path for --uefi
authorHarald Hoyer <harald@redhat.com>
Thu, 8 Dec 2016 16:53:40 +0000 (17:53 +0100)
committerHarald Hoyer <harald@redhat.com>
Mon, 16 Jan 2017 13:27:39 +0000 (14:27 +0100)
The default output filename for --uefi is
<EFI>/EFI/Linux/linux-$kernel$-<MACHINE_ID>-<BUILD_ID>.efi.
<EFI> might be /efi, /boot or /boot/efi depending on where the ESP partition
is mounted. The <BUILD_ID> is taken from BUILD_ID in /usr/lib/os-release or
if it exists /etc/os-release and is left out, if BUILD_ID is non-existant or
empty.

Also a new option --no-machineid was added, which affects the default output
filename of --uefi and will discard the <MACHINE_ID> part.

dracut.8.asc
dracut.sh

index 0e017070a6e8909b217180406eb3531b1a26302a..4ab0872f8bc2262445662786facb531c5dfe574d 100644 (file)
@@ -485,7 +485,15 @@ will not be able to boot.
 
 **--uefi**::
     Instead of creating an initramfs image, dracut will create an UEFI executable,
-    which can be executed by an UEFI BIOS.
+    which can be executed by an UEFI BIOS. The default output filename is
+    _<EFI>/EFI/Linux/linux-$kernel$-<MACHINE_ID>-<BUILD_ID>.efi_. <EFI> might be
+    _/efi_, _/boot_ or _/boot/efi_ depending on where the ESP partition is mounted.
+    The <BUILD_ID> is taken from BUILD_ID in _/usr/lib/os-release_ or if it exists
+    _/etc/os-release_ and is left out, if BUILD_ID is non-existant or empty.
+
+**--no-machineid**::
+    affects the default output filename of **--uefi** and will discard the <MACHINE_ID>
+    part.
 
 **--uefi-stub _<FILE>_**::
     Specifies the UEFI stub loader, which will load the attached kernel, initramfs and
index 15ba669db1ea478a7edf5c588d22626d614ccd14..44d5bcb56c268118733f514c88786d5212092781 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -371,6 +371,7 @@ rearrange_params()
         --long kernel-image: \
         --long no-hostonly-i18n \
         --long hostonly-i18n \
+        --long no-machineid \
         -- "$@")
 
     if (( $? != 0 )); then
@@ -566,6 +567,8 @@ while :; do
                        uefi_stub_l="$2";               PARMS_TO_STORE+=" '$2'"; shift;;
         --kernel-image)
                        kernel_image_l="$2";            PARMS_TO_STORE+=" '$2'"; shift;;
+        --no-machineid)
+                       machine_id_l="no";;
         --) shift; break;;
 
         *)  # should not even reach this point
@@ -624,16 +627,6 @@ if [[ $kernel ]]; then
     fi
 fi
 
-if ! [[ $outfile ]]; then
-    [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
-
-    if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
-        outfile="/boot/${MACHINE_ID}/$kernel/initrd"
-    else
-        outfile="/boot/initramfs-$kernel.img"
-    fi
-fi
-
 unset LC_MESSAGES
 unset LC_CTYPE
 export LC_ALL=C
@@ -751,6 +744,36 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
 [[ $loginstall_l ]] && loginstall="$loginstall_l"
 [[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
 [[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
+[[ $machine_id_l ]] && machine_id="$machine_id_l"
+
+if ! [[ $outfile ]]; then
+    if [[ $machine_id != "no" ]]; then
+        [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
+    fi
+
+    if [[ $uefi == "yes" ]]; then
+        BUILD_ID=$(cat /etc/os-release /usr/lib/os-release \
+                       | while read -r line || [[ $line ]]; do \
+                       [[ $line =~ BUILD_ID\=* ]] && eval "$line" && echo "$BUILD_ID" && break; \
+                   done)
+        if [[ -d /efi ]] && mountpoint -q /efi; then
+            efidir=/efi
+        else
+            efidir=/boot/EFI
+            if [[ -d /boot/efi/EFI ]] && mountpoint -q /boot/efi; then
+                efidir=/boot/efi/EFI
+            fi
+        fi
+        mkdir -p "$efidir/Linux"
+        outfile="$efidir/Linux/linux-$kernel${MACHINE_ID:+-${MACHINE_ID}}${BUILD_ID:+-${BUILD_ID}}.efi"
+    else
+        if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
+            outfile="/boot/${MACHINE_ID}/$kernel/initrd"
+        else
+            outfile="/boot/initramfs-$kernel.img"
+        fi
+    fi
+fi
 
 # eliminate IFS hackery when messing with fw_dir
 export DRACUT_FIRMWARE_PATH=${fw_dir// /:}