mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-12 08:58:20 +03:00
Merge pull request #21637 from nabijaczleweli/EBA
kernel-install: export BOOT_ROOT instead of hacking it in hooks, note KERNEL_INSTALL_* ABI
This commit is contained in:
commit
8097f80500
@ -167,6 +167,11 @@
|
||||
|
||||
<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>
|
||||
|
||||
<para><varname>KERNEL_INSTALL_MACHINE_ID=</varname> is set for the plugins to the desired <replaceable>MACHINE-ID</replaceable> –
|
||||
either 32 hexadecimal characters or the special value <literal>Default</literal>.</para>
|
||||
<para><varname>KERNEL_INSTALL_BOOT_ROOT=</varname> is set for the plugins to the root directory (mount point, usually) of the hierarchy
|
||||
where boot-loader entries, kernel images, and associated resources should be placed. Can be overriden by setting <varname>BOOT_ROOT=</varname>.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -32,10 +32,9 @@ if [[ $COMMAND != add ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If the boot dir exists (e.g. $ESP/<machine-id>),
|
||||
# create the entry directory ($ESP/<machine-id>/<kernel-version>).
|
||||
# This is the only function of this plugin.
|
||||
MACHINE_ID_DIR="${ENTRY_DIR_ABS%/*}"
|
||||
# Create the entry directory if its parent exists ‒
|
||||
# this is an administrative decision and the only function of this plugin.
|
||||
MACHINE_ID_DIR="$KERNEL_INSTALL_BOOT_ROOT/$KERNEL_INSTALL_MACHINE_ID"
|
||||
if ! [ -d "$MACHINE_ID_DIR" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
@ -32,14 +32,14 @@ if ! [[ -d "$ENTRY_DIR_ABS" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
|
||||
MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID"
|
||||
BOOT_ROOT="$KERNEL_INSTALL_BOOT_ROOT"
|
||||
|
||||
BOOT_ROOT=${ENTRY_DIR_ABS%/$MACHINE_ID/$KERNEL_VERSION}
|
||||
BOOT_MNT=$(stat -c %m $BOOT_ROOT)
|
||||
if [[ $BOOT_MNT == '/' ]]; then
|
||||
ENTRY_DIR=$ENTRY_DIR_ABS
|
||||
BOOT_MNT="$(stat -c %m "$BOOT_ROOT")"
|
||||
if [[ "$BOOT_MNT" == '/' ]]; then
|
||||
ENTRY_DIR="$ENTRY_DIR_ABS"
|
||||
else
|
||||
ENTRY_DIR=${ENTRY_DIR_ABS#$BOOT_MNT}
|
||||
ENTRY_DIR="${ENTRY_DIR_ABS#$BOOT_MNT}"
|
||||
fi
|
||||
|
||||
if [[ $COMMAND == remove ]]; then
|
||||
|
@ -93,21 +93,28 @@ 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"
|
||||
elif [[ -d /boot/efi/loader/entries ]] || [[ -d /boot/efi/$MACHINE_ID ]]; then
|
||||
ENTRY_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
|
||||
elif mountpoint -q /efi; then
|
||||
ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
|
||||
elif mountpoint -q /boot/efi; then
|
||||
ENTRY_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
|
||||
else
|
||||
ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
|
||||
fi
|
||||
[ -z "$BOOT_ROOT" ] && for suff in "$MACHINE_ID" "Default" "loader/entries"; do
|
||||
for pref in "/efi" "/boot/efi" "/boot"; do
|
||||
if [ -d "$pref/$suff" ]; then
|
||||
BOOT_ROOT="$pref"
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
[ -z "$BOOT_ROOT" ] && for pref in "/efi" "/boot/efi"; do
|
||||
if mountpoint -q "$pref"; then
|
||||
BOOT_ROOT="$pref"
|
||||
break
|
||||
fi
|
||||
done
|
||||
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/boot"
|
||||
|
||||
|
||||
ENTRY_DIR_ABS="$BOOT_ROOT/$MACHINE_ID/$KERNEL_VERSION"
|
||||
|
||||
export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
|
||||
export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT"
|
||||
|
||||
ret=0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user