diff options
Diffstat (limited to 'src/kernel-install')
-rwxr-xr-x | src/kernel-install/60-ukify.install.in | 28 | ||||
-rwxr-xr-x | src/kernel-install/90-loaderentry.install.in | 2 | ||||
-rwxr-xr-x | src/kernel-install/test-kernel-install.sh | 17 |
3 files changed, 47 insertions, 0 deletions
diff --git a/src/kernel-install/60-ukify.install.in b/src/kernel-install/60-ukify.install.in index 44a7750da5..21ef694ba1 100755 --- a/src/kernel-install/60-ukify.install.in +++ b/src/kernel-install/60-ukify.install.in @@ -147,6 +147,31 @@ def uki_conf_location() -> Optional[Path]: '/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]: path = input_file_location('cmdline') if path: @@ -208,6 +233,9 @@ def call_ukify(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 diff --git a/src/kernel-install/90-loaderentry.install.in b/src/kernel-install/90-loaderentry.install.in index 02497211b3..a52dd812e4 100755 --- a/src/kernel-install/90-loaderentry.install.in +++ b/src/kernel-install/90-loaderentry.install.in @@ -126,10 +126,12 @@ elif [ -f /usr/lib/kernel/devicetree ]; then fi if [ -n "$DEVICETREE" ]; then for prefix in \ + "$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 diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh index ad9462c7fb..30bee06b53 100755 --- a/src/kernel-install/test-kernel-install.sh +++ b/src/kernel-install/test-kernel-install.sh @@ -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 |