From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 06 Nov 2023 12:14:48 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qzxZA-0004GB-0u for lore@lore.pengutronix.de; Mon, 06 Nov 2023 12:14:48 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1qzxHH-0000UV-GX; Mon, 06 Nov 2023 11:56:19 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qzxH0-0000Td-EY; Mon, 06 Nov 2023 11:56:02 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qzxH0-0070PI-2Q; Mon, 06 Nov 2023 11:56:02 +0100 Received: from rhi by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qzxH0-00FHAM-05; Mon, 06 Nov 2023 11:56:02 +0100 From: Roland Hieber To: ptxdist@pengutronix.de Date: Mon, 6 Nov 2023 11:55:35 +0100 Message-Id: <20231106105534.3640846-1-rhi@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Mail-Followup-To: Roland Hieber , ptxdist@pengutronix.de Content-Transfer-Encoding: 8bit Subject: [ptxdist] [PATCH] image-rauc: pick up hook script if it exists X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: =?UTF-8?q?Enrico=20J=C3=B6rns?= , Roland Hieber Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false Look for a hook script in any config/images/rauc-hooks.sh in the usual search locations, and if one is found, package it into the RAUC bundle and reference it in the manifest. Otherwise leave the [hooks] section in the manifest empty. As hooks that should be called by RAUC need to be mentioned in the manifest too (in the relevant slot or the [bundle] section), the image config will still need to be forked by BSPs in order to adapt the manifest for that use case. However, the mechanism to find the hook script is then already in place, and can be used as-is. Signed-off-by: Roland Hieber --- config/images/rauc.config | 4 ++++ platforms/image-rauc.in | 4 ++++ rules/image-rauc.make | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/config/images/rauc.config b/config/images/rauc.config index e4169cc8cd95..4a6b34deee29 100644 --- a/config/images/rauc.config +++ b/config/images/rauc.config @@ -1,6 +1,7 @@ image @IMAGE@ { rauc { file root.tar.gz { image = "root.tgz" } + @RAUC_HOOK_FILE@ manifest = " [update] compatible=@RAUC_BUNDLE_COMPATIBLE@ @@ -11,6 +12,9 @@ image @IMAGE@ { [bundle] format=@RAUC_BUNDLE_FORMAT@ + [hooks] + @RAUC_HOOK_MANIFEST@ + [image.rootfs] filename=root.tar.gz " diff --git a/platforms/image-rauc.in b/platforms/image-rauc.in index 391956a42f81..2850045c313e 100644 --- a/platforms/image-rauc.in +++ b/platforms/image-rauc.in @@ -17,6 +17,10 @@ menuconfig IMAGE_RAUC To customize the bundle, copy and adapt the genimage configuration in configs/images/rauc.config. + If you create a file config/images/rauc-hooks.sh in any PTXDIST_PATH + component, it will be included in the bundle and declared as a hook + script in the manifest. + if IMAGE_RAUC config IMAGE_RAUC_DESCRIPTION diff --git a/rules/image-rauc.make b/rules/image-rauc.make index 23d8d83b5251..860f69834687 100644 --- a/rules/image-rauc.make +++ b/rules/image-rauc.make @@ -19,6 +19,10 @@ IMAGE_RAUC := image-rauc IMAGE_RAUC_DIR := $(BUILDDIR)/$(IMAGE_RAUC) IMAGE_RAUC_IMAGE := $(IMAGEDIR)/update.raucb IMAGE_RAUC_CONFIG := rauc.config +IMAGE_RAUC_HOOK_SCRIPT := $(call ptx/in-path, PTXDIST_PATH, config/images/rauc-hooks.sh) + +$(call ptx/cfghash, IMAGE_RAUC, $(IMAGE_RAUC_HOOK_SCRIPT)) +$(call ptx/cfghash-file, IMAGE_RAUC, $(IMAGE_RAUC_HOOK_SCRIPT)) # ---------------------------------------------------------------------------- # Image @@ -36,6 +40,16 @@ ifdef PTXCONF_IMAGE_RAUC_BUNDLE_FORMAT_CRYPT IMAGE_RAUC_BUNDLE_FORMAT := "crypt" endif +ifneq ($(IMAGE_RAUC_HOOK_SCRIPT),) +IMAGE_RAUC_ENV_HOOK = \ + RAUC_HOOK_FILE="file hooks.sh { image = \\"$(IMAGE_RAUC_HOOK_SCRIPT)\\" }" \ + RAUC_HOOK_MANIFEST="filename=hooks.sh" +else +IMAGE_RAUC_ENV_HOOK = \ + RAUC_HOOK_FILE="" \ + RAUC_HOOK_MANIFEST="" +endif + IMAGE_RAUC_ENV = \ $(CODE_SIGNING_ENV) \ RAUC_BUNDLE_COMPATIBLE="$(call remove_quotes,$(PTXCONF_RAUC_COMPATIBLE))" \ @@ -43,6 +57,7 @@ IMAGE_RAUC_ENV = \ RAUC_BUNDLE_VERSION="$(call remove_quotes, $(PTXCONF_RAUC_BUNDLE_VERSION))" \ RAUC_BUNDLE_BUILD=$(call ptx/sh, date +%FT%T%z) \ RAUC_BUNDLE_DESCRIPTION=$(PTXCONF_IMAGE_RAUC_DESCRIPTION) \ + $(IMAGE_RAUC_ENV_HOOK) \ RAUC_KEY="$(shell cs_get_uri update)" \ RAUC_CERT="$(shell cs_get_uri update)" \ RAUC_KEYRING="$(shell cs_get_ca update)" \ -- 2.39.2