X Tutup
Skip to content

Commit cf73f65

Browse files
committed
kernel-install: create the entry directory only if $BOOT/$MACHINE_ID exists
Things are currently fairly ugly in Fedora: we create $BOOT/$MACHINE_ID/$KERNEL_VERSION/, and then 20-grub.install that is installed by grub2-common.rpm wants to remove that directory before 50-dracut.install get a chance to run. 50-dracut.install checks for the presence of that directory to decide where to install the kernel. So let's make the creation of the directory conditional. Previous commit changes bootctl install to create $BOOT/$MACHINE_ID, and this commit makes kernel-install not create it. In effect, the entry directory will only be created if 'bootctl install' or something else created the parent directory. https://bugzilla.redhat.com/show_bug.cgi?id=1648907
1 parent 341890d commit cf73f65

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

man/kernel-install.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,20 @@
6767
<term><command>add <replaceable>KERNEL-VERSION</replaceable> <replaceable>KERNEL-IMAGE</replaceable> [<replaceable>INITRD-FILE</replaceable> ...]</command></term>
6868
<listitem>
6969
<para>This command expects a kernel version string and a path to a kernel image file as
70-
arguments. <command>kernel-install</command> creates the directory
71-
<filename>/boot/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
72-
and calls the executables from <filename>/usr/lib/kernel/install.d/*.install</filename> and
70+
arguments. <command>kernel-install</command> calls the executables from
71+
<filename>/usr/lib/kernel/install.d/*.install</filename> and
7372
<filename>/etc/kernel/install.d/*.install</filename> with the following arguments:
7473

7574
<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>
7675
</para>
7776

78-
<para>Two default plugins execute the following operations in this case:</para>
77+
<para>Three default plugins execute the following operations in this case:</para>
7978

8079
<itemizedlist>
80+
<listitem><para><filename>00-entry-directory.install</filename> creates the directory
81+
<filename>/boot/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
82+
if <filename>/boot/<replaceable>MACHINE-ID</replaceable>/</filename> already exists.
83+
</para></listitem>
8184

8285
<listitem><para><filename>50-depmod.install</filename> runs
8386
<citerefentry><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry> for the
@@ -94,7 +97,11 @@
9497
<filename>/boot/loader/entries/<replaceable>MACHINE-ID</replaceable>-<replaceable>KERNEL-VERSION</replaceable>.conf</filename>.
9598
The title of the entry is the <replaceable>PRETTY_NAME</replaceable> parameter specified in
9699
<filename>/etc/os-release</filename> or <filename>/usr/lib/os-release</filename> (if the former is
97-
missing), or "Linux <replaceable>KERNEL-VERSION</replaceable>", if unset.</para></listitem>
100+
missing), or "Linux <replaceable>KERNEL-VERSION</replaceable>", if unset.</para>
101+
102+
<para>If the entry directory
103+
<filename>/boot/<replaceable>MACHINE-ID</replaceable>/<replaceable>KERNEL-VERSION</replaceable>/</filename>
104+
does not exist, this plugin does nothing.</para></listitem>
98105
</itemizedlist>
99106
</listitem>
100107
</varlistentry>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3+
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
5+
COMMAND="$1"
6+
KERNEL_VERSION="$2"
7+
ENTRY_DIR_ABS="$3"
8+
KERNEL_IMAGE="$4"
9+
INITRD_OPTIONS_START="5"
10+
11+
if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
12+
exit 0
13+
fi
14+
15+
if [[ $COMMAND != add ]]; then
16+
exit 0
17+
fi
18+
19+
# If the boot dir exists (e.g. $ESP/<machine-id>),
20+
# create the entry directory ($ESP/<machine-id>/<kernel-version>).
21+
# This is the only function of this plugin.
22+
MACHINE_ID_DIR="${ENTRY_DIR_ABS%/*}"
23+
if ! [ -d "$MACHINE_ID_DIR" ]; then
24+
exit 0
25+
fi
26+
27+
if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
28+
echo "+mkdir -v -p $ENTRY_DIR_ABS"
29+
exec mkdir -v -p "$ENTRY_DIR_ABS"
30+
else
31+
exec mkdir -p "$ENTRY_DIR_ABS"
32+
fi

src/kernel-install/kernel-install

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ case $COMMAND in
125125
exit 1
126126
fi
127127

128-
mkdir -p "$ENTRY_DIR_ABS" || {
129-
echo "Could not create boot directory '$ENTRY_DIR_ABS'." >&2
130-
exit 1
131-
}
132-
133128
for f in "${PLUGINS[@]}"; do
134129
if [[ -x $f ]]; then
135130
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \

src/kernel-install/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ install_data('kernel-install',
44
install_mode : 'rwxr-xr-x',
55
install_dir : bindir)
66

7-
install_data('50-depmod.install',
7+
install_data('00-entry-directory.install',
8+
'50-depmod.install',
89
'90-loaderentry.install',
910
install_mode : 'rwxr-xr-x',
1011
install_dir : kernelinstalldir)

0 commit comments

Comments
 (0)
X Tutup