Skip to content

Commit 641e212

Browse files
nabijaczlewelikeszybz
authored andcommitted
kernel-install: replace 00-entry-directory with K_I_LAYOUT in k-i
341890d made "bootctl install" create ESP\MID, in preparation of cf73f65 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, 31e5755 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.
1 parent ba679b8 commit 641e212

File tree

7 files changed

+116
-70
lines changed

7 files changed

+116
-70
lines changed

man/kernel-install.xml

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,21 @@
7171
<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>
7272
</para>
7373

74-
<para>Three default plugins execute the following operations in this case:</para>
74+
<para>Two default plugins execute the following operations in this case:</para>
7575

7676
<itemizedlist>
77-
<listitem><para><filename>00-entry-directory.install</filename> creates the directory
78-
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
79-
if <filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/</filename> already exists.
80-
</para></listitem>
77+
<listitem><para><command>kernel-install</command> creates
78+
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable></filename>,
79+
if enabled (see <varname>$KERNEL_INSTALL_LAYOUT=</varname>).</para></listitem>
8180

8281
<listitem><para><filename>50-depmod.install</filename> runs
8382
<citerefentry project='man-pages'><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry> for the
8483
<replaceable>KERNEL-VERSION</replaceable>.</para></listitem>
8584

86-
<listitem><para><filename>90-loaderentry.install</filename> copies <replaceable>KERNEL-IMAGE</replaceable>
87-
to
85+
<listitem><para><filename>90-loaderentry.install</filename>
86+
copies <replaceable>KERNEL-IMAGE</replaceable> to
8887
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/linux</filename>.
89-
If an <replaceable>INITRD-FILE</replaceable> is provided, it also copies <replaceable>INITRD-FILE</replaceable>
90-
to
88+
If <replaceable>INITRD-FILE</replaceable>s are provided, it also copies them to
9189
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL_VERSION</replaceable>/<replaceable>INITRD-FILE</replaceable></filename>.
9290
It also creates a boot loader entry according to the <ulink
9391
url="https://systemd.io/BOOT_LOADER_SPECIFICATION">Boot Loader Specification</ulink> in
@@ -96,9 +94,7 @@
9694
<filename>/etc/os-release</filename> or <filename>/usr/lib/os-release</filename> (if the former is
9795
missing), or "Linux <replaceable>KERNEL-VERSION</replaceable>", if unset.</para>
9896

99-
<para>If the entry directory
100-
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
101-
does not exist, this plugin does nothing.</para></listitem>
97+
<para>If <varname>$KERNEL_INSTALL_LAYOUT=</varname> is not "bls", this plugin does nothing.</para></listitem>
10298
</itemizedlist>
10399
</listitem>
104100
</varlistentry>
@@ -119,13 +115,15 @@
119115
<para>Two default plugins execute the following operations in this case:</para>
120116

121117
<itemizedlist>
122-
123118
<listitem><para><filename>50-depmod.install</filename> removes the files generated by <command>depmod</command> for this kernel again.</para></listitem>
124119

125120
<listitem><para><filename>90-loaderentry.install</filename> removes the file
126121
<filename>$BOOT/loader/entries/<replaceable>MACHINE-ID</replaceable>-<replaceable>KERNEL-VERSION</replaceable>.conf</filename>.</para></listitem>
127-
</itemizedlist>
128122

123+
<listitem><para><command>kernel-install</command> removes
124+
<filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable></filename>,
125+
if enabled (see <varname>$KERNEL_INSTALL_LAYOUT=</varname>).</para></listitem>
126+
</itemizedlist>
129127
</listitem>
130128
</varlistentry>
131129

@@ -172,6 +170,30 @@
172170
either 32 hexadecimal characters or the special value <literal>Default</literal>.</para>
173171
<para><varname>KERNEL_INSTALL_BOOT_ROOT=</varname> is set for the plugins to the root directory (mount point, usually) of the hierarchy
174172
where boot-loader entries, kernel images, and associated resources should be placed. Can be overridden by setting <varname>BOOT_ROOT=</varname>.</para>
173+
174+
<para><varname>KERNEL_INSTALL_LAYOUT=bls|other|...</varname> specifies the installation layout.
175+
Defaults to <option>bls</option> if <filename>$BOOT/<replaceable>MACHINE-ID</replaceable></filename> exists, or <option>other</option> otherwise.
176+
Additional layout names may be defined by convention. If a plugin uses a special layout,
177+
it's encouraged to declare its own layout name and configure <varname>layout=</varname> in <filename>install.conf</filename> upon initial installation.</para>
178+
179+
<variablelist>
180+
<varlistentry>
181+
<term>bls</term>
182+
<listitem>
183+
<para>Standard <ulink url="https://systemd.io/BOOT_LOADER_SPECIFICATION">Boot Loader Specification</ulink> layout,
184+
compatible with <citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>: entries in
185+
<filename>$BOOT/loader/entries/<replaceable>MACHINE-ID</replaceable>-<replaceable>KERNEL-VERSION</replaceable>[+<replaceable>TRIES</replaceable>].conf</filename>,
186+
kernel and initrds under <filename>$BOOT/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename></para>
187+
<para>Provided by <filename>90-loaderentry.install</filename>.</para>
188+
</listitem>
189+
</varlistentry>
190+
<varlistentry>
191+
<term>other</term>
192+
<listitem>
193+
<para>Some other layout not understood natively by <command>kernel-install</command>.</para>
194+
</listitem>
195+
</varlistentry>
196+
</variablelist>
175197
</refsect1>
176198

177199
<refsect1>
@@ -251,6 +273,18 @@
251273
Otherwise, <literal>Linux <replaceable>KERNEL-VERSION</replaceable></literal> will be used.</para>
252274
</listitem>
253275
</varlistentry>
276+
<varlistentry>
277+
<term>
278+
<filename>/usr/lib/kernel/install.conf</filename>
279+
<filename>/etc/kernel/install.conf</filename>
280+
</term>
281+
<listitem>
282+
<para>Configuration options for <command>kernel-install</command>,
283+
as a series of <varname>KEY=</varname><replaceable>VALUE</replaceable> assignments,
284+
compatible with shell syntax.
285+
See the Environment variables section for supported keys.</para>
286+
</listitem>
287+
</varlistentry>
254288
</variablelist>
255289
</refsect1>
256290

meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ udevlibexecdir = rootprefixdir / 'lib/udev'
171171
udevrulesdir = udevlibexecdir / 'rules.d'
172172
udevhwdbdir = udevlibexecdir / 'hwdb.d'
173173
catalogdir = prefixdir / 'lib/systemd/catalog'
174-
kernelinstalldir = prefixdir / 'lib/kernel/install.d'
174+
kerneldir = prefixdir / 'lib/kernel'
175+
kernelinstalldir = kerneldir / 'install.d'
175176
factorydir = datadir / 'factory'
176177
bootlibdir = prefixdir / 'lib/systemd/boot/efi'
177178
testsdir = prefixdir / 'lib/systemd/tests'

src/kernel-install/00-entry-directory.install

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/kernel-install/90-loaderentry.install

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
2828
exit 0
2929
fi
3030

31-
if ! [[ -d "$ENTRY_DIR_ABS" ]]; then
31+
if [ "$KERNEL_INSTALL_LAYOUT" != "bls" ]; then
3232
exit 0
3333
fi
3434

@@ -92,6 +92,15 @@ else
9292
LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
9393
fi
9494

95+
if ! [ -d "$ENTRY_DIR_ABS" ]; then
96+
if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
97+
echo "+mkdir -v -p $ENTRY_DIR_ABS"
98+
mkdir -v -p "$ENTRY_DIR_ABS"
99+
else
100+
mkdir -p "$ENTRY_DIR_ABS"
101+
fi
102+
fi
103+
95104
install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
96105
echo "Could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
97106
exit 1

src/kernel-install/install.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file is part of systemd.
2+
#
3+
# systemd is free software; you can redistribute it and/or modify it under the
4+
# terms of the GNU Lesser General Public License as published by the Free
5+
# Software Foundation; either version 2.1 of the License, or (at your option)
6+
# any later version.
7+
#
8+
# See kernel-install(8) for details.
9+
10+
#layout=bls|other|...

src/kernel-install/kernel-install

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
9090
exit 1
9191
fi
9292

93+
if [ -r "/etc/kernel/install.conf" ]; then
94+
. /etc/kernel/install.conf
95+
elif [ -r "/usr/lib/kernel/install.conf" ]; then
96+
. /usr/lib/kernel/install.conf
97+
fi
98+
9399
# Prefer to use an existing machine ID from /etc/machine-info or /etc/machine-id. If we're using the machine
94100
# ID /etc/machine-id, try to persist it in /etc/machine-info. If no machine ID is found, try to generate
95101
# 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"
124130
export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
125131
export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT"
126132

133+
if [ -z "$layout" ]; then
134+
# Administrative decision: if not present, some scripts generate into /boot.
135+
if [ -d "$BOOT_ROOT/$MACHINE_ID" ]; then
136+
layout="bls"
137+
else
138+
layout="other"
139+
fi
140+
fi
141+
142+
143+
ENTRY_DIR_ABS="$BOOT_ROOT/$MACHINE_ID/$KERNEL_VERSION"
144+
145+
export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
146+
export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT"
147+
export KERNEL_INSTALL_LAYOUT="$layout"
148+
149+
[ "$layout" = "bls" ]
150+
MAKE_ENTRY_DIR_ABS=$?
151+
152+
127153
ret=0
128154

129155
readarray -t PLUGINS <<<"$(
@@ -144,6 +170,18 @@ case $COMMAND in
144170
exit 1
145171
fi
146172

173+
if [ "$MAKE_ENTRY_DIR_ABS" -eq 0 ]; then
174+
# Compatibility with earlier versions that used the presence of $BOOT_ROOT/$MACHINE_ID
175+
# to signal to 00-entry-directory to create $ENTRY_DIR_ABS
176+
# to serve as the indication to use or to not use the BLS
177+
if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
178+
echo "+mkdir -v -p $ENTRY_DIR_ABS"
179+
mkdir -v -p "$ENTRY_DIR_ABS"
180+
else
181+
mkdir -p "$ENTRY_DIR_ABS"
182+
fi
183+
fi
184+
147185
for f in "${PLUGINS[@]}"; do
148186
if [[ -x $f ]]; then
149187
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
@@ -172,11 +210,10 @@ case $COMMAND in
172210
fi
173211
done
174212

175-
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
176-
echo "Removing $ENTRY_DIR_ABS"
177-
178-
rm -rf "$ENTRY_DIR_ABS"
179-
((ret+=$?))
213+
if [ "$MAKE_ENTRY_DIR_ABS" -eq 0 ]; then
214+
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Removing $ENTRY_DIR_ABS/"
215+
rm -rf "$ENTRY_DIR_ABS"
216+
fi
180217
;;
181218

182219
*)

src/kernel-install/meson.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ if want_kernel_install
77
install_mode : 'rwxr-xr-x',
88
install_dir : bindir)
99

10-
install_data('00-entry-directory.install',
11-
'50-depmod.install',
10+
install_data('50-depmod.install',
1211
'90-loaderentry.install',
1312
install_mode : 'rwxr-xr-x',
1413
install_dir : kernelinstalldir)
1514

15+
install_data('install.conf',
16+
install_dir : kerneldir)
17+
1618
if install_sysconfdir
1719
meson.add_install_script('sh', '-c',
1820
mkdir_p.format(sysconfdir / 'kernel/install.d'))

0 commit comments

Comments
 (0)