<refsect1>
<title>Environment variables</title>
+
<para>If <option>--verbose</option> is used, <varname>$KERNEL_INSTALL_VERBOSE=1</varname> will be set for
the plugins. They may output additional logs in this case.</para>
+
+ <para>If <varname>MACHINE_ID=</varname> is set and not empty, it will be used as <replaceable>MACHINE-ID</replaceable>,
+ overriding any automatic detection attempts. The value must be a valid machine ID (32 hexadecimal characters).</para>
</refsect1>
<refsect1>
</term>
<listitem>
<para>The content of this file specifies the machine identification
- <replaceable>MACHINE-ID</replaceable>. If <filename>$BOOT/Default</filename> exists,
- or <filename>/etc/machine-id</filename> doesn't, <command>kernel-install</command>
- will use the literal <literal>Default</literal> as the machine ID instead.</para>
+ <replaceable>MACHINE-ID</replaceable>. If <filename>/etc/machine-id</filename>
+ cannot be read or is temporary (backed by a file on <constant>tmpfs</constant>),
+ <command>kernel-install</command> will use <literal>Default</literal> instead.</para>
</listitem>
</varlistentry>
<varlistentry>
KERNEL_VERSION="$1"
KERNEL_IMAGE="$2"
-# Reuse directory created without a machine ID present if it exists.
-if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then
- MACHINE_ID="Default"
-elif [[ -f /etc/machine-id ]]; then
- read MACHINE_ID < /etc/machine-id
-else
- MACHINE_ID="Default"
-fi
-
if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
echo "Not enough arguments" >&2
exit 1
fi
+[ -z "$MACHINE_ID" ] && [ -f /etc/machine-id ] && [ "$(stat -fc %T /etc/machine-id)" != "tmpfs" ] && read -r MACHINE_ID < /etc/machine-id
+[ -z "$MACHINE_ID" ] && MACHINE_ID="Default"
+
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"
fi
-export KERNEL_INSTALL_MACHINE_ID=$MACHINE_ID
+export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
ret=0