mirror of
https://github.com/systemd/systemd.git
synced 2026-08-10 17:14:31 +00:00
kernel-install(uki): filter comments from cmdline
This change aligns the behaviour of UKI generation with the behaviour of BLS. The latter filters out lines starting with a #, allowing users to add comments and/or temporarily remove some flags from the kernel command line. The kernel-install test have been adjusted to use a multiline cmdline with a comment in it. Without this patch, the test fails. (cherry picked from commit0c2747e789) (cherry picked from commit3c5046c43f)
This commit is contained in:
@@ -616,9 +616,9 @@
|
||||
<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.
|
||||
When running in a container, <filename>/proc/cmdline</filename> is ignored.
|
||||
<varname>$KERNEL_INSTALL_CONF_ROOT</varname> may be used to override the search path; see below for
|
||||
details.</para>
|
||||
Lines starting with the <literal>#</literal> character are ignored. When running in a container,
|
||||
<filename>/proc/cmdline</filename> is ignored. <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>
|
||||
|
||||
@@ -185,7 +185,12 @@ def devicetree_file_location(opts) -> Optional[Path]:
|
||||
def kernel_cmdline_base() -> list[str]:
|
||||
path = input_file_location('cmdline')
|
||||
if path:
|
||||
return path.read_text().split()
|
||||
# Filter out commented out lines from cmdline.
|
||||
lines = path.read_text().splitlines()
|
||||
return [opt
|
||||
for line in lines
|
||||
if not line.startswith('#')
|
||||
for opt in line.split()]
|
||||
|
||||
# If we read /proc/cmdline, we need to do some additional filtering.
|
||||
options = Path('/proc/cmdline').read_text().split()
|
||||
|
||||
@@ -29,7 +29,12 @@ mkdir -p "$D/sources"
|
||||
echo 'buzy image' >"$D/sources/linux"
|
||||
echo 'the initrd' >"$D/sources/initrd"
|
||||
echo 'the-token' >"$D/sources/entry-token"
|
||||
echo 'opt1 opt2' >"$D/sources/cmdline"
|
||||
|
||||
cat >"$D/sources/cmdline" <<EOF
|
||||
opt1
|
||||
# commented line
|
||||
opt2
|
||||
EOF
|
||||
|
||||
cat >"$D/sources/install.conf" <<EOF
|
||||
layout=bls
|
||||
|
||||
Reference in New Issue
Block a user