mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
Merge pull request #29523 from keszybz/kernel-install-dtb-files
Do not look for dtb files in /boot, add support in 60-ukify.install
This commit is contained in:
commit
9ff6876555
@ -471,64 +471,81 @@
|
||||
<title>Files</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/usr/lib/kernel/install.d/*.install</filename>
|
||||
<filename>/etc/kernel/install.d/*.install</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Drop-in files which are executed by kernel-install.</para>
|
||||
<term><filename>/etc/kernel/install.d/*.install</filename></term>
|
||||
<term><filename>/usr/lib/kernel/install.d/*.install</filename></term>
|
||||
<listitem>
|
||||
<para>Drop-in files which are executed by <command>kernel-install</command>.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v198"/>
|
||||
</listitem>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/usr/lib/kernel/cmdline</filename>
|
||||
<filename>/etc/kernel/cmdline</filename>
|
||||
<filename>/proc/cmdline</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Read by <filename>90-loaderentry.install</filename>. The content of the file
|
||||
<filename>/etc/kernel/cmdline</filename> specifies the kernel command line to use. If that file
|
||||
does not exist, <filename>/usr/lib/kernel/cmdline</filename> is used. If that also does not
|
||||
exist, <filename>/proc/cmdline</filename> is used. <varname>$KERNEL_INSTALL_CONF_ROOT</varname>
|
||||
may be used to override the path.</para>
|
||||
<term><filename>/etc/kernel/cmdline</filename></term>
|
||||
<term><filename>/usr/lib/kernel/cmdline</filename></term>
|
||||
<term><filename>/proc/cmdline</filename></term>
|
||||
<listitem>
|
||||
<para>Specifies the kernel command line to use. The first of the files that is found will be used.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the search path; see below for
|
||||
details.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v198"/>
|
||||
</listitem>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/kernel/tries</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Read by <filename>90-loaderentry.install</filename> and
|
||||
<filename>90-uki-copy.install</filename>. If this file exists a numeric value is read from it
|
||||
and the naming of the generated entry file or UKI is slightly altered to include it as
|
||||
<filename>$BOOT/loader/entries/<replaceable>ENTRY-TOKEN</replaceable>-<replaceable>KERNEL-VERSION</replaceable>+<replaceable>TRIES</replaceable>.conf</filename>
|
||||
or
|
||||
<filename>$BOOT/EFI/Linux/<replaceable>ENTRY-TOKEN</replaceable>-<replaceable>KERNEL-VERSION</replaceable>+<replaceable>TRIES</replaceable>.efi</filename>, respectively. This
|
||||
is useful for boot loaders such as
|
||||
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
||||
which implement boot attempt counting with a counter embedded in the entry file name.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the path.</para>
|
||||
<term><filename>/etc/kernel/devicetree</filename></term>
|
||||
<term><filename>/usr/lib/kernel/devicetree</filename></term>
|
||||
<listitem>
|
||||
<para>Specifies the partial path to the file containing the device tree blob to install with the
|
||||
kernel and use at boot. The first of the files that is found will be used.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the search path; see below for
|
||||
details.</para>
|
||||
|
||||
<para>The <filename>devicetree</filename> file contains a path, and this path specifies a location
|
||||
relative to the kernel install tree. A set of locations is checked, including in particular
|
||||
<filename>/usr/lib/modules/<replaceable>KERNEL_VERSION</replaceable>/dtb/</filename>, which is the
|
||||
recommended location to place the dtb files under. For example, with
|
||||
<literal>broadcom/bcm2711-rpi-4-b.dtb</literal> in the <filename>devicetree</filename> file, the
|
||||
device tree blob for the Raspberry Pi 4 Model B would be installed, and the actual file would be
|
||||
<filename index='false'>/usr/lib/modules/<replaceable>KERNEL_VERSION</replaceable>/dtb/broadcom/bcm2711-rpi-4-b.dtb</filename>.
|
||||
</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v255"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><filename>/etc/kernel/tries</filename></term>
|
||||
<listitem>
|
||||
<para>Read by <filename>90-loaderentry.install</filename> and
|
||||
<filename>90-uki-copy.install</filename>. If this file exists, a numeric value is read from it and
|
||||
the naming of the generated entry file or UKI is altered to include it as
|
||||
<filename>$BOOT/loader/entries/<replaceable>ENTRY-TOKEN</replaceable>-<replaceable>KERNEL-VERSION</replaceable>+<replaceable>TRIES</replaceable>.conf</filename>
|
||||
or
|
||||
<filename>$BOOT/EFI/Linux/<replaceable>ENTRY-TOKEN</replaceable>-<replaceable>KERNEL-VERSION</replaceable>+<replaceable>TRIES</replaceable>.efi</filename>,
|
||||
respectively. This is useful for boot loaders such as
|
||||
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
||||
which implement boot attempt counting with a counter embedded in the entry file name.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the search path; see below for
|
||||
details.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v240"/>
|
||||
</listitem>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/kernel/entry-token</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>If this file exists it is read and used as "entry token" for this system, i.e. is used for
|
||||
naming Boot Loader Specification entries, see <varname>$KERNEL_INSTALL_ENTRY_TOKEN</varname>
|
||||
above for details. <varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the
|
||||
path.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v251"/>
|
||||
</listitem>
|
||||
<varlistentry>
|
||||
<term><filename>/etc/kernel/entry-token</filename></term>
|
||||
<listitem>
|
||||
<para>If this file exists it is read and used as "entry token" for this system, i.e. is used for
|
||||
naming Boot Loader Specification entries. See <varname>$KERNEL_INSTALL_ENTRY_TOKEN</varname> above
|
||||
for details. <varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the search path; see
|
||||
below for details.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v251"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/machine-id</filename>
|
||||
@ -540,63 +557,62 @@
|
||||
<xi:include href="version-info.xml" xpointer="v198"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/os-release</filename>
|
||||
<filename>/usr/lib/os-release</filename>
|
||||
</term>
|
||||
<term><filename>/etc/os-release</filename></term>
|
||||
<term><filename>/usr/lib/os-release</filename></term>
|
||||
<listitem>
|
||||
<para>Read by <filename>90-loaderentry.install</filename>.
|
||||
If available, <varname>PRETTY_NAME=</varname> is read from these files and used as the title of the boot menu entry.
|
||||
Otherwise, <literal>Linux <replaceable>KERNEL-VERSION</replaceable></literal> will be used.</para>
|
||||
<para>Read by <filename>90-loaderentry.install</filename>. If available,
|
||||
<varname>PRETTY_NAME=</varname> is read from these files and used as the title of the boot menu
|
||||
entry. Otherwise, <literal>Linux <replaceable>KERNEL-VERSION</replaceable></literal> will be
|
||||
used.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v198"/>
|
||||
<xi:include href="version-info.xml" xpointer="v198"/>
|
||||
</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, following the same rules as described in
|
||||
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
<filename>/etc/kernel/install.conf</filename> will be read if present, and
|
||||
<filename>/usr/lib/kernel/install.conf</filename> otherwise. This file is optional.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the path.
|
||||
</para>
|
||||
<term><filename>/etc/kernel/install.conf</filename></term>
|
||||
<term><filename>/usr/lib/kernel/install.conf</filename></term>
|
||||
<listitem>
|
||||
<para>Configuration file with options for <command>kernel-install</command>, as a series of
|
||||
<varname>KEY=</varname><replaceable>VALUE</replaceable> assignments, compatible with shell syntax,
|
||||
following the same rules as described in
|
||||
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>. The
|
||||
first of the files that is found will be used. <varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be
|
||||
used to override the search path; see below for details.</para>
|
||||
|
||||
<para>Currently, the following keys are supported:
|
||||
<varname>MACHINE_ID=</varname>,
|
||||
<varname>BOOT_ROOT=</varname>,
|
||||
<varname>layout=</varname>,
|
||||
<varname>initrd_generator=</varname>,
|
||||
<varname>uki_generator=</varname>.
|
||||
See the Environment variables section above for details.</para>
|
||||
<para>Currently, the following keys are supported:
|
||||
<varname>MACHINE_ID=</varname>,
|
||||
<varname>BOOT_ROOT=</varname>,
|
||||
<varname>layout=</varname>,
|
||||
<varname>initrd_generator=</varname>,
|
||||
<varname>uki_generator=</varname>.
|
||||
See the Environment variables section above for details.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v250"/>
|
||||
</listitem>
|
||||
<xi:include href="version-info.xml" xpointer="v250"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/kernel/uki.conf</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Ini-style configuration file for
|
||||
<citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> which
|
||||
is only effective when <varname>$KERNEL_INSTALL_LAYOUT</varname> or <varname>layout=</varname> in
|
||||
<filename>install.conf</filename> is set to <option>uki</option> and
|
||||
<varname>$KERNEL_INSTALL_UKI_GENERATOR</varname> or <varname>uki_generator=</varname> in
|
||||
<filename>install.conf</filename> is set to <option>ukify</option>.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the path.
|
||||
</para>
|
||||
<term><filename>/etc/kernel/uki.conf</filename></term>
|
||||
<listitem>
|
||||
<para>Ini-style configuration file for
|
||||
<citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> which is
|
||||
only effective when <varname>$KERNEL_INSTALL_LAYOUT</varname> or <varname>layout=</varname> in
|
||||
<filename>install.conf</filename> is set to <option>uki</option> and
|
||||
<varname>$KERNEL_INSTALL_UKI_GENERATOR</varname> or <varname>uki_generator=</varname> in
|
||||
<filename>install.conf</filename> is set to <option>ukify</option>.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the search path; see below for
|
||||
details.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v255"/>
|
||||
</listitem>
|
||||
<xi:include href="version-info.xml" xpointer="v255"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>For various cases listed above, if the <varname>$KERNEL_INSTALL_CONF_ROOT</varname> environment
|
||||
variable is set, it will override the search path. The files will be loaded <emphasis>only</emphasis>
|
||||
from the directory specified by the environment variable. When the variable is not set, the listed paths
|
||||
are tried in turn, and the first file that exists is used.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -124,27 +124,60 @@ def we_are_wanted() -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def config_file_location() -> Optional[Path]:
|
||||
def input_file_location(
|
||||
filename: str,
|
||||
*search_directories: str) -> Optional[Path]:
|
||||
|
||||
if root := os.getenv('KERNEL_INSTALL_CONF_ROOT'):
|
||||
p = Path(root) / 'uki.conf'
|
||||
else:
|
||||
p = Path('/etc/kernel/uki.conf')
|
||||
if p.exists():
|
||||
return p
|
||||
search_directories = (root,)
|
||||
elif not search_directories:
|
||||
# This is the default search path.
|
||||
search_directories = ('/etc/kernel',
|
||||
'/usr/lib/kernel')
|
||||
|
||||
for dir in search_directories:
|
||||
p = Path(dir) / filename
|
||||
if p.exists():
|
||||
return p
|
||||
return None
|
||||
|
||||
|
||||
def uki_conf_location() -> Optional[Path]:
|
||||
return input_file_location('uki.conf',
|
||||
'/etc/kernel')
|
||||
|
||||
|
||||
def devicetree_config_location() -> Optional[Path]:
|
||||
return input_file_location('devicetree')
|
||||
|
||||
|
||||
def devicetree_file_location(opts) -> Optional[Path]:
|
||||
# This mirrors the logic in 90-loaderentry.install. Keep in sync.
|
||||
configfile = devicetree_config_location()
|
||||
if configfile is None:
|
||||
return None
|
||||
|
||||
devicetree = configfile.read_text().strip()
|
||||
if not devicetree:
|
||||
raise ValueError(f'{configfile!r} is empty')
|
||||
|
||||
path = input_file_location(
|
||||
devicetree,
|
||||
f'/usr/lib/firmware/{opts.kernel_version}/device-tree',
|
||||
f'/usr/lib/linux-image-{opts.kernel_version}',
|
||||
f'/usr/lib/modules/{opts.kernel_version}/dtb',
|
||||
)
|
||||
if path is None:
|
||||
raise FileNotFoundError(f'DeviceTree file {devicetree} not found')
|
||||
return path
|
||||
|
||||
|
||||
def kernel_cmdline_base() -> list[str]:
|
||||
if root := os.getenv('KERNEL_INSTALL_CONF_ROOT'):
|
||||
return Path(root).joinpath('cmdline').read_text().split()
|
||||
|
||||
for cmdline in ('/etc/kernel/cmdline',
|
||||
'/usr/lib/kernel/cmdline'):
|
||||
try:
|
||||
return Path(cmdline).read_text().split()
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
path = input_file_location('cmdline')
|
||||
if path:
|
||||
return path.read_text().split()
|
||||
|
||||
# If we read /proc/cmdline, we need to do some additional filtering.
|
||||
options = Path('/proc/cmdline').read_text().split()
|
||||
return [opt for opt in options
|
||||
if not opt.startswith(('BOOT_IMAGE=', 'initrd='))]
|
||||
@ -193,13 +226,16 @@ def call_ukify(opts):
|
||||
# argument set to prepopulate the namespace with the defaults.
|
||||
opts2 = ukify['create_parser']().parse_args(['build'])
|
||||
|
||||
opts2.config = config_file_location()
|
||||
opts2.config = uki_conf_location()
|
||||
opts2.uname = opts.kernel_version
|
||||
opts2.linux = opts.kernel_image
|
||||
opts2.initrd = initrd_list(opts)
|
||||
# Note that 'uki.efi' is the name required by 90-uki-copy.install.
|
||||
opts2.output = opts.staging_area / 'uki.efi'
|
||||
|
||||
if devicetree := devicetree_file_location(opts):
|
||||
opts2.devicetree = devicetree
|
||||
|
||||
opts2.cmdline = kernel_cmdline(opts)
|
||||
if BOOT_STUB:
|
||||
opts2.stub = BOOT_STUB
|
||||
|
@ -126,12 +126,12 @@ elif [ -f /usr/lib/kernel/devicetree ]; then
|
||||
fi
|
||||
if [ -n "$DEVICETREE" ]; then
|
||||
for prefix in \
|
||||
"/boot/dtb-$KERNEL_VERSION" \
|
||||
"/boot/dtbs/$KERNEL_VERSION" \
|
||||
"/lib/firmware/$KERNEL_VERSION/device-tree" \
|
||||
"/lib/linux-image-$KERNEL_VERSION" \
|
||||
"/lib/modules/$KERNEL_VERSION/dtb"
|
||||
"$KERNEL_INSTALL_CONF_ROOT" \
|
||||
"/usr/lib/firmware/$KERNEL_VERSION/device-tree" \
|
||||
"/usr/lib/linux-image-$KERNEL_VERSION" \
|
||||
"/usr/lib/modules/$KERNEL_VERSION/dtb"
|
||||
do
|
||||
[ -n "$prefix" ] || continue
|
||||
[ -f "$prefix/$DEVICETREE" ] || continue
|
||||
DEVICETREE_SRC="$prefix/$DEVICETREE"
|
||||
break
|
||||
|
@ -39,6 +39,11 @@ BOOT_ROOT="$D/badboot"
|
||||
MACHINE_ID=badbadbadbadbadbad6abadbadbadbad
|
||||
EOF
|
||||
|
||||
# Create a 'devicetree' config file that points to a fake dtb file
|
||||
echo 'subdir/whatever.dtb' >"$D/sources/devicetree"
|
||||
mkdir "$D/sources/subdir"
|
||||
echo 'DTBDTBDTBDTB' >"$D/sources/subdir/whatever.dtb"
|
||||
|
||||
export KERNEL_INSTALL_CONF_ROOT="$D/sources"
|
||||
# We "install" multiple plugins, but control which ones will be active via install.conf.
|
||||
export KERNEL_INSTALL_PLUGINS="${ukify_install} ${loaderentry_install} ${uki_copy_install}"
|
||||
@ -60,9 +65,11 @@ grep -qE '^version +1.1.1' "$entry"
|
||||
grep -qE '^options +opt1 opt2' "$entry"
|
||||
grep -qE '^linux .*/the-token/1.1.1/linux' "$entry"
|
||||
grep -qE '^initrd .*/the-token/1.1.1/initrd' "$entry"
|
||||
grep -qE '^devicetree .*/the-token/1.1.1/whatever.dtb' "$entry"
|
||||
|
||||
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.1/linux"
|
||||
grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
|
||||
grep -qE 'DTBDTB' "$BOOT_ROOT/the-token/1.1.1/whatever.dtb"
|
||||
|
||||
"$kernel_install" inspect
|
||||
"$kernel_install" inspect "$D/sources/linux"
|
||||
@ -95,9 +102,11 @@ grep -qE '^version +1.1.2' "$entry"
|
||||
grep -qE '^options +opt1 opt2' "$entry"
|
||||
grep -qE '^linux .*/the-token/1.1.2/linux' "$entry"
|
||||
( ! grep -qE '^initrd' "$entry" )
|
||||
grep -qE '^devicetree .*/the-token/1.1.2/whatever.dtb' "$entry"
|
||||
|
||||
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.2/linux"
|
||||
test ! -e "$BOOT_ROOT/the-token/1.1.2/initrd"
|
||||
grep -qE 'DTBDTB' "$BOOT_ROOT/the-token/1.1.2/whatever.dtb"
|
||||
|
||||
# Check installation with boot counting
|
||||
echo '56' >"$D/sources/tries"
|
||||
@ -120,6 +129,7 @@ if [ -f "$ukify" ]; then
|
||||
layout=uki
|
||||
uki_generator=ukify
|
||||
EOF
|
||||
|
||||
"$kernel_install" -v add 1.1.3 "$D/sources/linux" "$D/sources/initrd"
|
||||
uki="${BOOT_ROOT}/EFI/Linux/the-token-1.1.3+56.efi"
|
||||
test -f "$uki"
|
||||
@ -129,6 +139,13 @@ EOF
|
||||
"$bootctl" kernel-inspect "$uki" | grep -qE 'Version: +1\.1\.3$'
|
||||
"$bootctl" kernel-inspect "$uki" | grep -qE 'Cmdline: +opt1 opt2$'
|
||||
fi
|
||||
|
||||
"$ukify" inspect "$uki" | grep -qE '^.sbat'
|
||||
"$ukify" inspect "$uki" | grep -qE '^.cmdline'
|
||||
"$ukify" inspect "$uki" | grep -qE '^.uname'
|
||||
"$ukify" inspect "$uki" | grep -qE '^.initrd'
|
||||
"$ukify" inspect "$uki" | grep -qE '^.linux'
|
||||
"$ukify" inspect "$uki" | grep -qE '^.dtb'
|
||||
fi
|
||||
|
||||
# Test bootctl
|
||||
|
@ -250,7 +250,7 @@ DEFAULT_SECTIONS_TO_SHOW = {
|
||||
'.linux' : 'binary',
|
||||
'.initrd' : 'binary',
|
||||
'.splash' : 'binary',
|
||||
'.dt' : 'binary',
|
||||
'.dtb' : 'binary',
|
||||
'.cmdline' : 'text',
|
||||
'.osrel' : 'text',
|
||||
'.uname' : 'text',
|
||||
|
Loading…
Reference in New Issue
Block a user