From 2bca841137833edeaf3779542d6475f0dc3aa5a7 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Sat, 29 Jul 2023 22:26:54 +0200 Subject: [PATCH] 90-loaderentry: support installing device trees Like the cmdline file we look for a devicetree file in $KERNEL_INSTALL_CONF_ROOT, /etc/kernel and /usr/lib/kernel. If it is present we look for the specified device tree that comes with the kernel we're adding and install it into $ENTRY_DIR_ABS and add a devicetree stanza to the loader entry. Unfortunately it seems there is no common consensus on where to install device tree blobs, so we have to look in a few different places for it. --- src/kernel-install/90-loaderentry.install.in | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/kernel-install/90-loaderentry.install.in b/src/kernel-install/90-loaderentry.install.in index bc4cad9e6f6..dc7c371e5a1 100755 --- a/src/kernel-install/90-loaderentry.install.in +++ b/src/kernel-install/90-loaderentry.install.in @@ -115,6 +115,43 @@ install -m 0644 "$KERNEL_IMAGE" "$KERNEL_DEST" || { } chown root:root "$KERNEL_DEST" || : +if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then + if [ -f "$KERNEL_INSTALL_CONF_ROOT/devicetree" ]; then + read -r DEVICETREE <"$KERNEL_INSTALL_CONF_ROOT/devicetree" + fi +elif [ -f /etc/kernel/devicetree ]; then + read -r DEVICETREE &2 + exit 1 + } + + DEVICETREE_DEST="$ENTRY_DIR_ABS/${DEVICETREE##*/}" + DEVICETREE_ENTRY="$ENTRY_DIR/${DEVICETREE##*/}" + + install -m 0644 "$DEVICETREE_SRC" "$DEVICETREE_DEST" || { + echo "Error: could not copy '$DEVICETREE_SRC' to '$DEVICETREE_DEST'." >&2 + exit 1 + } + chown root:root "$DEVICETREE_DEST" || : +fi + shift "$INITRD_OPTIONS_SHIFT" # All files listed as arguments, and staged files starting with "initrd" are installed as initrds. for initrd in "${KERNEL_INSTALL_STAGING_AREA}"/microcode* "${@}" "${KERNEL_INSTALL_STAGING_AREA}"/initrd*; do @@ -154,6 +191,7 @@ mkdir -p "${LOADER_ENTRY%/*}" || { [ -n "$SORT_KEY" ] && echo "sort-key $SORT_KEY" echo "options $BOOT_OPTIONS" echo "linux $KERNEL_ENTRY" + [ -n "$DEVICETREE_ENTRY" ] && echo "devicetree $DEVICETREE_ENTRY" have_initrd= for initrd in "${KERNEL_INSTALL_STAGING_AREA}"/microcode* "${@}" "${KERNEL_INSTALL_STAGING_AREA}"/initrd*; do -- 2.47.3