diff mbox series

systemd-bootconf: do not modify build directory in do_install

Message ID 20260318152436.27416-1-nora.schiffer@ew.tq-group.com
State Under Review
Headers show
Series systemd-bootconf: do not modify build directory in do_install | expand

Commit Message

Nora Schiffer March 18, 2026, 3:24 p.m. UTC
do_install should only modify ${D}, otherwise rerunning the task will
have inconsistent results. In the case of systemd-bootconf, a second run
of do_install without rerunning do_configure (for example after modifying
it in a bbappend) fails altogether, as loader.conf would be missing.

Rather than fixing this up by deleting loader.conf from ${D} instead of
${S} after copying *.conf, clean up systemd-boot-cfg.bbclass not to
store loader.conf at the same location as the individual entries in the
first place, so they can be copied separately. While we're at it, also
change the recipe to make use of the variables defined by the class.

Signed-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com>
---
 meta/classes-recipe/systemd-boot-cfg.bbclass       | 10 ++++++----
 meta/recipes-core/systemd/systemd-bootconf_1.00.bb |  5 ++---
 2 files changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/systemd-boot-cfg.bbclass b/meta/classes-recipe/systemd-boot-cfg.bbclass
index 12da41ebad7..66403ff5524 100644
--- a/meta/classes-recipe/systemd-boot-cfg.bbclass
+++ b/meta/classes-recipe/systemd-boot-cfg.bbclass
@@ -5,6 +5,7 @@ 
 #
 
 SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
+SYSTEMD_BOOT_ENTRIES_DIR ?= "${S}/entries"
 SYSTEMD_BOOT_ENTRIES ?= ""
 SYSTEMD_BOOT_TIMEOUT ?= "10"
 
@@ -15,7 +16,6 @@  PACKAGE_ARCH = "${MACHINE_ARCH}"
 inherit fs-uuid
 
 python build_efi_cfg() {
-    s = d.getVar("S")
     labels = d.getVar('LABELS')
     if not labels:
         bb.debug(1, "LABELS not defined, nothing to do")
@@ -43,12 +43,14 @@  python build_efi_cfg() {
         cfgfile.write('timeout 10\n')
     cfgfile.close()
 
+    entries_dir = d.getVar('SYSTEMD_BOOT_ENTRIES_DIR')
+    if not os.path.exists(entries_dir):
+        os.makedirs(entries_dir)
+
     for label in labels.split():
         localdata = d.createCopy()
 
-        entryfile = "%s/%s.conf" % (s, label)
-        if not os.path.exists(s):
-            os.makedirs(s)
+        entryfile = "%s/%s.conf" % (entries_dir, label)
         d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
         try:
             entrycfg = open(entryfile, "w")
diff --git a/meta/recipes-core/systemd/systemd-bootconf_1.00.bb b/meta/recipes-core/systemd/systemd-bootconf_1.00.bb
index 5efac3e4106..53b634ddc2f 100644
--- a/meta/recipes-core/systemd/systemd-bootconf_1.00.bb
+++ b/meta/recipes-core/systemd/systemd-bootconf_1.00.bb
@@ -24,9 +24,8 @@  do_install() {
 	install -d ${D}/boot
 	install -d ${D}/boot/loader
 	install -d ${D}/boot/loader/entries
-	install loader.conf ${D}/boot/loader/
-	rm loader.conf
-	install *.conf ${D}/boot/loader/entries/
+	install ${SYSTEMD_BOOT_CFG} ${D}/boot/loader/
+	install ${SYSTEMD_BOOT_ENTRIES_DIR}/*.conf ${D}/boot/loader/entries/
 }
 
 FILES:${PN} = "/boot/loader/* /boot/loader/entries/*"