public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'Quirin Gylstorff' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Subject: [PATCH 2/2] wic/plugins/bootimg-efi-isar: Add option to sign systemd bootloader and kernel
Date: Thu, 20 Nov 2025 11:12:46 +0100	[thread overview]
Message-ID: <20251120101510.2530415-2-Quirin.Gylstorff@siemens.com> (raw)
In-Reply-To: <20251120101510.2530415-1-Quirin.Gylstorff@siemens.com>

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

This allows to generate a signed installer image.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 .../lib/wic/plugins/source/bootimg-efi-isar.py  | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
index 661dcbb4..fd4d6017 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
@@ -310,6 +310,20 @@ class BootimgEFIPlugin(SourcePlugin):
             logger.debug("Payload directory: %s", payload_dir)
             shutil.copytree(payload_dir, iso_dir, symlinks=True, dirs_exist_ok=True)
 
+    @classmethod
+    def _sign_file(cls, signee, source_params):
+        sign_script = source_params.get("signwith")
+        if sign_script and os.path.exists(sign_script):
+            logger.info("sign with script %s", sign_script)
+            orig_signee = signee + ".unsigned"
+            os.rename(signee, orig_signee)
+            sign_cmd = "{sign_script} {orig_signee} {signee}"\
+                .format(sign_script=sign_script, orig_signee=orig_signee,
+                        signee=signee)
+            exec_cmd(sign_cmd)
+        elif sign_script and not os.path.exists(sign_script):
+            logger.error("Could not find script %s", sign_script)
+            exit(1)
 
     @classmethod
     def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
@@ -406,6 +420,8 @@ class BootimgEFIPlugin(SourcePlugin):
 
             install_cmd = isar_populate_boot_cmd(rootfs_dir['ROOTFS_DIR'], hdddir)
             exec_cmd(install_cmd)
+            for mod in [x for x in os.listdir(hdddir) if x.startswith("vmlinu")]:
+                cls._sign_file(f"{hdddir}/{mod}", source_params)
 
         cls._install_payload(source_params, hdddir)
 
@@ -488,6 +504,7 @@ class BootimgEFIPlugin(SourcePlugin):
                         target = target[:-7]
                     cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, target)
                     exec_cmd(cp_cmd, True)
+                    cls._sign_file(f"{hdddir}/EFI/BOOT/{mod[8:]}", source_params)
 
                 kernel_dir = kernel_dir_orig
             else:
-- 
2.51.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20251120101510.2530415-2-Quirin.Gylstorff%40siemens.com.

  reply	other threads:[~2025-11-20 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 10:12 [PATCH 1/2] bootimg-efi-isar: Add payload source_params 'Quirin Gylstorff' via isar-users
2025-11-20 10:12 ` 'Quirin Gylstorff' via isar-users [this message]
2025-11-26  9:47 ` Zhihang Wei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251120101510.2530415-2-Quirin.Gylstorff@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=Quirin.Gylstorff@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox