mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
kernel-install: replace 00-entry-directory with K_I_LAYOUT in k-i
341890de86
made "bootctl install" create ESP\MID, in preparation ofcf73f65089
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,31e57550b5
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.
This commit is contained in:
parent
ba679b8d56
commit
641e2124de
@ -71,23 +71,21 @@
|
||||
<programlisting>add <replaceable>KERNEL-VERSION</replaceable> <filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename> <replaceable>KERNEL-IMAGE</replaceable> [<replaceable>INITRD-FILE</replaceable> ...]</programlisting>
|
||||
</para>
|
||||
|
||||
<para>Three default plugins execute the following operations in this case:</para>
|
||||
<para>Two default plugins execute the following operations in this case:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para><filename>00-entry-directory.install</filename> creates the directory
|
||||
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
|
||||
if <filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/</filename> already exists.
|
||||
</para></listitem>
|
||||
<listitem><para><command>kernel-install</command> creates
|
||||
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable></filename>,
|
||||
if enabled (see <varname>$KERNEL_INSTALL_LAYOUT=</varname>).</para></listitem>
|
||||
|
||||
<listitem><para><filename>50-depmod.install</filename> runs
|
||||
<citerefentry project='man-pages'><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry> for the
|
||||
<replaceable>KERNEL-VERSION</replaceable>.</para></listitem>
|
||||
|
||||
<listitem><para><filename>90-loaderentry.install</filename> copies <replaceable>KERNEL-IMAGE</replaceable>
|
||||
to
|
||||
<listitem><para><filename>90-loaderentry.install</filename>
|
||||
copies <replaceable>KERNEL-IMAGE</replaceable> to
|
||||
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/linux</filename>.
|
||||
If an <replaceable>INITRD-FILE</replaceable> is provided, it also copies <replaceable>INITRD-FILE</replaceable>
|
||||
to
|
||||
If <replaceable>INITRD-FILE</replaceable>s are provided, it also copies them to
|
||||
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL_VERSION</replaceable>/<replaceable>INITRD-FILE</replaceable></filename>.
|
||||
It also creates a boot loader entry according to the <ulink
|
||||
url="https://systemd.io/BOOT_LOADER_SPECIFICATION">Boot Loader Specification</ulink> in
|
||||
@ -96,9 +94,7 @@
|
||||
<filename>/etc/os-release</filename> or <filename>/usr/lib/os-release</filename> (if the former is
|
||||
missing), or "Linux <replaceable>KERNEL-VERSION</replaceable>", if unset.</para>
|
||||
|
||||
<para>If the entry directory
|
||||
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
|
||||
does not exist, this plugin does nothing.</para></listitem>
|
||||
<para>If <varname>$KERNEL_INSTALL_LAYOUT=</varname> is not "bls", this plugin does nothing.</para></listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@ -119,13 +115,15 @@
|
||||
<para>Two default plugins execute the following operations in this case:</para>
|
||||
|
||||
<itemizedlist>
|
||||
|
||||
<listitem><para><filename>50-depmod.install</filename> removes the files generated by <command>depmod</command> for this kernel again.</para></listitem>
|
||||
|
||||
<listitem><para><filename>90-loaderentry.install</filename> removes the file
|
||||
<filename>$BOOT/loader/entries/<replaceable>MACHINE-ID</replaceable>-<replaceable>KERNEL-VERSION</replaceable>.conf</filename>.</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<listitem><para><command>kernel-install</command> removes
|
||||
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable></filename>,
|
||||
if enabled (see <varname>$KERNEL_INSTALL_LAYOUT=</varname>).</para></listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@ -172,6 +170,30 @@
|
||||
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 overridden by setting <varname>BOOT_ROOT=</varname>.</para>
|
||||
|
||||
<para><varname>KERNEL_INSTALL_LAYOUT=bls|other|...</varname> specifies the installation layout.
|
||||
Defaults to <option>bls</option> if <filename>$BOOT/<replaceable>MACHINE-ID</replaceable></filename> exists, or <option>other</option> otherwise.
|
||||
Additional layout names may be defined by convention. If a plugin uses a special layout,
|
||||
it's encouraged to declare its own layout name and configure <varname>layout=</varname> in <filename>install.conf</filename> upon initial installation.</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>bls</term>
|
||||
<listitem>
|
||||
<para>Standard <ulink url="https://systemd.io/BOOT_LOADER_SPECIFICATION">Boot Loader Specification</ulink> layout,
|
||||
compatible with <citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>: entries in
|
||||
<filename>$BOOT/loader/entries/<replaceable>MACHINE-ID</replaceable>-<replaceable>KERNEL-VERSION</replaceable>[+<replaceable>TRIES</replaceable>].conf</filename>,
|
||||
kernel and initrds under <filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename></para>
|
||||
<para>Provided by <filename>90-loaderentry.install</filename>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>other</term>
|
||||
<listitem>
|
||||
<para>Some other layout not understood natively by <command>kernel-install</command>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
@ -251,6 +273,18 @@
|
||||
Otherwise, <literal>Linux <replaceable>KERNEL-VERSION</replaceable></literal> will be used.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/usr/lib/kernel/install.conf</filename>
|
||||
<filename>/etc/kernel/install.conf</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Configuration options for <command>kernel-install</command>,
|
||||
as a series of <varname>KEY=</varname><replaceable>VALUE</replaceable> assignments,
|
||||
compatible with shell syntax.
|
||||
See the Environment variables section for supported keys.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -171,7 +171,8 @@ udevlibexecdir = rootprefixdir / 'lib/udev'
|
||||
udevrulesdir = udevlibexecdir / 'rules.d'
|
||||
udevhwdbdir = udevlibexecdir / 'hwdb.d'
|
||||
catalogdir = prefixdir / 'lib/systemd/catalog'
|
||||
kernelinstalldir = prefixdir / 'lib/kernel/install.d'
|
||||
kerneldir = prefixdir / 'lib/kernel'
|
||||
kernelinstalldir = kerneldir / 'install.d'
|
||||
factorydir = datadir / 'factory'
|
||||
bootlibdir = prefixdir / 'lib/systemd/boot/efi'
|
||||
testsdir = prefixdir / 'lib/systemd/tests'
|
||||
|
@ -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
|
@ -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
|
||||
|
10
src/kernel-install/install.conf
Normal file
10
src/kernel-install/install.conf
Normal file
@ -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|...
|
@ -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
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -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'))
|
||||
|
Loading…
Reference in New Issue
Block a user