mirror of
https://github.com/systemd/systemd.git
synced 2025-02-03 17:47:28 +03:00
kernel-install/60-ukify: also support the convention with 'devicetree' file
Requested in https://github.com/systemd/systemd/pull/28582#issuecomment-1673300596. The is the last requested changed, so fixes #28771. 90-loaderentry.install is modified to also check $KERNEL_INSTALL_CONF_ROOT when looking for the devicetree file. For normal use this is probably not needed, but it's nice to be consistent and it also makes it much easier to write the tests. In tests, also do 'ukify inspect' now that we have it.
This commit is contained in:
parent
e3696e6f63
commit
02d8d787f3
@ -147,6 +147,31 @@ def uki_conf_location() -> Optional[Path]:
|
|||||||
'/etc/kernel')
|
'/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]:
|
def kernel_cmdline_base() -> list[str]:
|
||||||
path = input_file_location('cmdline')
|
path = input_file_location('cmdline')
|
||||||
if path:
|
if path:
|
||||||
@ -208,6 +233,9 @@ def call_ukify(opts):
|
|||||||
# Note that 'uki.efi' is the name required by 90-uki-copy.install.
|
# Note that 'uki.efi' is the name required by 90-uki-copy.install.
|
||||||
opts2.output = opts.staging_area / 'uki.efi'
|
opts2.output = opts.staging_area / 'uki.efi'
|
||||||
|
|
||||||
|
if devicetree := devicetree_file_location(opts):
|
||||||
|
opts2.devicetree = devicetree
|
||||||
|
|
||||||
opts2.cmdline = kernel_cmdline(opts)
|
opts2.cmdline = kernel_cmdline(opts)
|
||||||
if BOOT_STUB:
|
if BOOT_STUB:
|
||||||
opts2.stub = BOOT_STUB
|
opts2.stub = BOOT_STUB
|
||||||
|
@ -126,10 +126,12 @@ elif [ -f /usr/lib/kernel/devicetree ]; then
|
|||||||
fi
|
fi
|
||||||
if [ -n "$DEVICETREE" ]; then
|
if [ -n "$DEVICETREE" ]; then
|
||||||
for prefix in \
|
for prefix in \
|
||||||
|
"$KERNEL_INSTALL_CONF_ROOT" \
|
||||||
"/usr/lib/firmware/$KERNEL_VERSION/device-tree" \
|
"/usr/lib/firmware/$KERNEL_VERSION/device-tree" \
|
||||||
"/usr/lib/linux-image-$KERNEL_VERSION" \
|
"/usr/lib/linux-image-$KERNEL_VERSION" \
|
||||||
"/usr/lib/modules/$KERNEL_VERSION/dtb"
|
"/usr/lib/modules/$KERNEL_VERSION/dtb"
|
||||||
do
|
do
|
||||||
|
[ -n "$prefix" ] || continue
|
||||||
[ -f "$prefix/$DEVICETREE" ] || continue
|
[ -f "$prefix/$DEVICETREE" ] || continue
|
||||||
DEVICETREE_SRC="$prefix/$DEVICETREE"
|
DEVICETREE_SRC="$prefix/$DEVICETREE"
|
||||||
break
|
break
|
||||||
|
@ -39,6 +39,11 @@ BOOT_ROOT="$D/badboot"
|
|||||||
MACHINE_ID=badbadbadbadbadbad6abadbadbadbad
|
MACHINE_ID=badbadbadbadbadbad6abadbadbadbad
|
||||||
EOF
|
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"
|
export KERNEL_INSTALL_CONF_ROOT="$D/sources"
|
||||||
# We "install" multiple plugins, but control which ones will be active via install.conf.
|
# 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}"
|
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 '^options +opt1 opt2' "$entry"
|
||||||
grep -qE '^linux .*/the-token/1.1.1/linux' "$entry"
|
grep -qE '^linux .*/the-token/1.1.1/linux' "$entry"
|
||||||
grep -qE '^initrd .*/the-token/1.1.1/initrd' "$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 'image' "$BOOT_ROOT/the-token/1.1.1/linux"
|
||||||
grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
|
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
|
||||||
"$kernel_install" inspect "$D/sources/linux"
|
"$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 '^options +opt1 opt2' "$entry"
|
||||||
grep -qE '^linux .*/the-token/1.1.2/linux' "$entry"
|
grep -qE '^linux .*/the-token/1.1.2/linux' "$entry"
|
||||||
( ! grep -qE '^initrd' "$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"
|
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.2/linux"
|
||||||
test ! -e "$BOOT_ROOT/the-token/1.1.2/initrd"
|
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
|
# Check installation with boot counting
|
||||||
echo '56' >"$D/sources/tries"
|
echo '56' >"$D/sources/tries"
|
||||||
@ -120,6 +129,7 @@ if [ -f "$ukify" ]; then
|
|||||||
layout=uki
|
layout=uki
|
||||||
uki_generator=ukify
|
uki_generator=ukify
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
"$kernel_install" -v add 1.1.3 "$D/sources/linux" "$D/sources/initrd"
|
"$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"
|
uki="${BOOT_ROOT}/EFI/Linux/the-token-1.1.3+56.efi"
|
||||||
test -f "$uki"
|
test -f "$uki"
|
||||||
@ -129,6 +139,13 @@ EOF
|
|||||||
"$bootctl" kernel-inspect "$uki" | grep -qE 'Version: +1\.1\.3$'
|
"$bootctl" kernel-inspect "$uki" | grep -qE 'Version: +1\.1\.3$'
|
||||||
"$bootctl" kernel-inspect "$uki" | grep -qE 'Cmdline: +opt1 opt2$'
|
"$bootctl" kernel-inspect "$uki" | grep -qE 'Cmdline: +opt1 opt2$'
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
# Test bootctl
|
# Test bootctl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user