summaryrefslogtreecommitdiff
path: root/src/kernel-install
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2021-03-16 16:47:34 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-12-17 14:57:56 +0100
commit641e2124de6047e6010cd2925ea22fba29b25309 (patch)
tree2d89885a320cbbb11e5c470bf8bfdc2cac8d0d62 /src/kernel-install
parentba679b8d567e2e5b347865800da421a1bb87df75 (diff)
downloadsystemd-641e2124de6047e6010cd2925ea22fba29b25309.tar.gz
kernel-install: replace 00-entry-directory with K_I_LAYOUT in k-i
341890de866f2ee34919a47ce3fc6c8cd3c1924c made "bootctl install" create ESP\MID, in preparation of cf73f650890b56a59bfb713c4c82b4e29daa7316 that followed it and created 00-entry-directory.install to make ESP\MID\KVER if ESP\MID existed ‒ this meant that "bootctl install" followed by "kernel-install $(uname -r) /boot/vml*$(uname -r) /boot/ini*$(uname -r)" actually installed the kernel correctly. Later, 31e57550b552e113bd3d44355b237c41e42beb58 reverted the first commit, meaning, that now running those two commands first installs sd-boot, but then does nothing. Everything appears to work right, nothing errors out, but no changes are actually done. To the untrained eye (all of them), even running with -v appears to work: all the hooks are run, as is depmod, but, again, nothing happens. This is horrible. Nothing in either manpage suggests what to do (nor should it, really), but the user is left with a bootloader that appears fully funxional, since nothing suggests a failure in the output, but with an unbootable machine, /no way to boot it/, even if they drop to an EFI shell, since the boot bundle isn't present on the ESP, and no real recourse even if they boot into a recovery system, apart from installing like GRUB or whatever. 00- is purely instrumentation for 90-, and separating one from the other has led to downstream dissatisfaxion (indeed, the last mentioned commit cited cited exactly that as the reversion reason), while creating $ENTRY_DIR_ABS is only required for bootloaders using the BLS, and shouldn't itself toggle anything. To that end, introduce an /{e,l}/k/install.conf file that allows overriding the detected layout, and detect it as "bls" if $BOOT_ROOT/$MACHINE_ID ($ENTRY_DIR_ABS/..) exists, otherwise "other" ‒ if a user wishes to select a different bootloader, like GRUB, they (or, indeed, the postinst script) can specify layout=grub. This disables 90- and $ENTRY_DIR_ABS manipulation.
Diffstat (limited to 'src/kernel-install')
-rw-r--r--src/kernel-install/00-entry-directory.install47
-rw-r--r--src/kernel-install/90-loaderentry.install11
-rw-r--r--src/kernel-install/install.conf10
-rwxr-xr-xsrc/kernel-install/kernel-install47
-rw-r--r--src/kernel-install/meson.build6
5 files changed, 66 insertions, 55 deletions
diff --git a/src/kernel-install/00-entry-directory.install b/src/kernel-install/00-entry-directory.install
deleted file mode 100644
index 5576179d52..0000000000
--- a/src/kernel-install/00-entry-directory.install
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-# SPDX-License-Identifier: LGPL-2.1-or-later
-#
-# This file is part of systemd.
-#
-# systemd is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-#
-# systemd is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-
-COMMAND="$1"
-KERNEL_VERSION="$2"
-ENTRY_DIR_ABS="$3"
-KERNEL_IMAGE="$4"
-INITRD_OPTIONS_START="5"
-
-if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
- exit 0
-fi
-
-if [[ $COMMAND != add ]]; then
- exit 0
-fi
-
-# 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
-
-if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
- echo "+mkdir -v -p $ENTRY_DIR_ABS"
- exec mkdir -v -p "$ENTRY_DIR_ABS"
-else
- exec mkdir -p "$ENTRY_DIR_ABS"
-fi
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
index a4dba1396d..044eced3f0 100644
--- a/src/kernel-install/90-loaderentry.install
+++ b/src/kernel-install/90-loaderentry.install
@@ -28,7 +28,7 @@ if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
exit 0
fi
-if ! [[ -d "$ENTRY_DIR_ABS" ]]; then
+if [ "$KERNEL_INSTALL_LAYOUT" != "bls" ]; then
exit 0
fi
@@ -92,6 +92,15 @@ else
LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
fi
+if ! [ -d "$ENTRY_DIR_ABS" ]; then
+ if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
+ echo "+mkdir -v -p $ENTRY_DIR_ABS"
+ mkdir -v -p "$ENTRY_DIR_ABS"
+ else
+ mkdir -p "$ENTRY_DIR_ABS"
+ fi
+fi
+
install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
echo "Could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
exit 1
diff --git a/src/kernel-install/install.conf b/src/kernel-install/install.conf
new file mode 100644
index 0000000000..e4802e6fae
--- /dev/null
+++ b/src/kernel-install/install.conf
@@ -0,0 +1,10 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# See kernel-install(8) for details.
+
+#layout=bls|other|...
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
index 103b44ebda..b358b03b2f 100755
--- a/src/kernel-install/kernel-install
+++ b/src/kernel-install/kernel-install
@@ -90,6 +90,12 @@ if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
exit 1
fi
+if [ -r "/etc/kernel/install.conf" ]; then
+ . /etc/kernel/install.conf
+elif [ -r "/usr/lib/kernel/install.conf" ]; then
+ . /usr/lib/kernel/install.conf
+fi
+
# Prefer to use an existing machine ID from /etc/machine-info or /etc/machine-id. If we're using the machine
# ID /etc/machine-id, try to persist it in /etc/machine-info. If no machine ID is found, try to generate
# a new machine ID in /etc/machine-info. If that fails, use "Default".
@@ -124,6 +130,26 @@ ENTRY_DIR_ABS="$BOOT_ROOT/$MACHINE_ID/$KERNEL_VERSION"
export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT"
+if [ -z "$layout" ]; then
+ # Administrative decision: if not present, some scripts generate into /boot.
+ if [ -d "$BOOT_ROOT/$MACHINE_ID" ]; then
+ layout="bls"
+ else
+ layout="other"
+ fi
+fi
+
+
+ENTRY_DIR_ABS="$BOOT_ROOT/$MACHINE_ID/$KERNEL_VERSION"
+
+export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
+export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT"
+export KERNEL_INSTALL_LAYOUT="$layout"
+
+[ "$layout" = "bls" ]
+MAKE_ENTRY_DIR_ABS=$?
+
+
ret=0
readarray -t PLUGINS <<<"$(
@@ -144,6 +170,18 @@ case $COMMAND in
exit 1
fi
+ if [ "$MAKE_ENTRY_DIR_ABS" -eq 0 ]; then
+ # Compatibility with earlier versions that used the presence of $BOOT_ROOT/$MACHINE_ID
+ # to signal to 00-entry-directory to create $ENTRY_DIR_ABS
+ # to serve as the indication to use or to not use the BLS
+ if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
+ echo "+mkdir -v -p $ENTRY_DIR_ABS"
+ mkdir -v -p "$ENTRY_DIR_ABS"
+ else
+ mkdir -p "$ENTRY_DIR_ABS"
+ fi
+ fi
+
for f in "${PLUGINS[@]}"; do
if [[ -x $f ]]; then
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
@@ -172,11 +210,10 @@ case $COMMAND in
fi
done
- [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
- echo "Removing $ENTRY_DIR_ABS"
-
- rm -rf "$ENTRY_DIR_ABS"
- ((ret+=$?))
+ if [ "$MAKE_ENTRY_DIR_ABS" -eq 0 ]; then
+ [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Removing $ENTRY_DIR_ABS/"
+ rm -rf "$ENTRY_DIR_ABS"
+ fi
;;
*)
diff --git a/src/kernel-install/meson.build b/src/kernel-install/meson.build
index 893832461e..508058f1cf 100644
--- a/src/kernel-install/meson.build
+++ b/src/kernel-install/meson.build
@@ -7,12 +7,14 @@ if want_kernel_install
install_mode : 'rwxr-xr-x',
install_dir : bindir)
- install_data('00-entry-directory.install',
- '50-depmod.install',
+ install_data('50-depmod.install',
'90-loaderentry.install',
install_mode : 'rwxr-xr-x',
install_dir : kernelinstalldir)
+ install_data('install.conf',
+ install_dir : kerneldir)
+
if install_sysconfdir
meson.add_install_script('sh', '-c',
mkdir_p.format(sysconfdir / 'kernel/install.d'))