]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: Add fallback to "Linux" if no machine-id is found 16687/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Aug 2020 20:56:36 +0000 (21:56 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 10 Aug 2020 18:56:32 +0000 (19:56 +0100)
This allows kernel-install to be used by image builders such as mkosi
which don't have a machine-id available when they call kernel-install.

man/kernel-install.xml
src/kernel-install/kernel-install

index 273270f55013d55f9dd6895b24b11d8112d0676d..3de95f70881087142bbee98b0b196213c0639f03 100644 (file)
           <filename>/etc/machine-id</filename>
         </term>
           <listitem>
-            <para>The content of the file specifies the machine identification <replaceable>MACHINE-ID</replaceable>.</para>
+            <para>The content of this file specifies the machine identification
+            <replaceable>MACHINE-ID</replaceable>. If it cannot read <filename>/etc/machine-id</filename>,
+            kernel-install will use "Linux" as the machine ID instead.</para>
           </listitem>
       </varlistentry>
       <varlistentry>
index e2590c434c345bace57467329218cd55ceb7fc17..ca21be7e6162ac6a2889e055bf394a527ee224d4 100755 (executable)
@@ -87,6 +87,8 @@ KERNEL_IMAGE="$2"
 
 if [[ -f /etc/machine-id ]]; then
     read MACHINE_ID < /etc/machine-id
+else
+    MACHINE_ID="Linux"
 fi
 
 if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
@@ -94,10 +96,7 @@ if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
     exit 1
 fi
 
-if ! [[ $MACHINE_ID ]]; then
-    ENTRY_DIR_ABS=$(mktemp -d /tmp/kernel-install.XXXXX) || exit 1
-    trap "rm -rf '$ENTRY_DIR_ABS'" EXIT INT QUIT PIPE
-elif [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
+if [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
     ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
 elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
     ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
@@ -146,14 +145,6 @@ case $COMMAND in
                 ((ret+=$x))
             fi
         done
-
-        if ! [[ $MACHINE_ID ]] && ! rmdir "$ENTRY_DIR_ABS"; then
-            echo "Warning: In kernel-install plugins, requiring ENTRY_DIR_ABS to be preset is deprecated." >&2
-            echo "         All plugins should not put anything in ENTRY_DIR_ABS if the environment" >&2
-            echo "         variable KERNEL_INSTALL_MACHINE_ID is empty." >&2
-            rm -rf "$ENTRY_DIR_ABS"
-            ((ret+=$?))
-        fi
         ;;
 
     remove)