1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

kernel-install: export $BOOT_ROOT and use it in downstreams

The previous approach, to strip "$MACHINE_ID/$KERNEL_VERSION" from the
end, is pretty bad and encourages this for users, which makes them
inflexible to this being modified locally
This commit is contained in:
наб 2021-03-16 17:02:59 +01:00
parent efea45f19c
commit 9e82a74cb0
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1
3 changed files with 29 additions and 23 deletions

View File

@ -32,10 +32,9 @@ if [[ $COMMAND != add ]]; then
exit 0 exit 0
fi fi
# If the boot dir exists (e.g. $ESP/<machine-id>), # Create the entry directory if its parent exists
# create the entry directory ($ESP/<machine-id>/<kernel-version>). # this is an administrative decision and the only function of this plugin.
# This is the only function of this plugin. MACHINE_ID_DIR="$KERNEL_INSTALL_BOOT_ROOT/$KERNEL_INSTALL_MACHINE_ID"
MACHINE_ID_DIR="${ENTRY_DIR_ABS%/*}"
if ! [ -d "$MACHINE_ID_DIR" ]; then if ! [ -d "$MACHINE_ID_DIR" ]; then
exit 0 exit 0
fi fi

View File

@ -32,14 +32,14 @@ if ! [[ -d "$ENTRY_DIR_ABS" ]]; then
exit 0 exit 0
fi 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")"
BOOT_MNT=$(stat -c %m $BOOT_ROOT) if [[ "$BOOT_MNT" == '/' ]]; then
if [[ $BOOT_MNT == '/' ]]; then ENTRY_DIR="$ENTRY_DIR_ABS"
ENTRY_DIR=$ENTRY_DIR_ABS
else else
ENTRY_DIR=${ENTRY_DIR_ABS#$BOOT_MNT} ENTRY_DIR="${ENTRY_DIR_ABS#$BOOT_MNT}"
fi fi
if [[ $COMMAND == remove ]]; then if [[ $COMMAND == remove ]]; then

View File

@ -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" ] && [ -f /etc/machine-id ] && [ "$(stat -fc %T /etc/machine-id)" != "tmpfs" ] && read -r MACHINE_ID < /etc/machine-id
[ -z "$MACHINE_ID" ] && MACHINE_ID="Default" [ -z "$MACHINE_ID" ] && MACHINE_ID="Default"
if [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then [ -z "$BOOT_ROOT" ] && for suff in "$MACHINE_ID" "Default" "loader/entries"; do
ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION" for pref in "/efi" "/boot/efi" "/boot"; do
elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then if [ -d "$pref/$suff" ]; then
ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION" BOOT_ROOT="$pref"
elif [[ -d /boot/efi/loader/entries ]] || [[ -d /boot/efi/$MACHINE_ID ]]; then break 2
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 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_MACHINE_ID="$MACHINE_ID"
export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT"
ret=0 ret=0