From 6af4cfe6059cdce1ff72db3c72e77097e1285cc0 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Sun, 15 Sep 2019 10:05:29 +0200
Subject: [PATCH 178/220] Set a devicetree var in a BLS config if
 GRUB_DEFAULT_DTB is present

The BootLoaderSpec mentions that a devicetree field can be used to pass a
Device Tree (DT) to the kernel, for the platforms that use it to describe
information about the hardware.

The blscfg module supports parsing the field from the BLS snippets but it
allows to set a DT for all the entries if a devicetree env var is defined.

Make the grub2-mkconfig tool to set this variable if GRUB_DEFAULT_DTB was
defined in the /etc/default/grub file.

Resolves: rhbz#1751307

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
 util/grub.d/10_linux.in | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 301594a..1520b7e 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -138,6 +138,10 @@ EOF
       if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then
           ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}"
       fi
+
+      if [ -n "${GRUB_DEFAULT_DTB}" ]; then
+          ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}"
+      fi
   fi
 
   exit 0
-- 
1.8.3.1

