* [ptxdist] [PATCH] image-rauc: pick up hook script if it exists
@ 2023-11-06 10:55 Roland Hieber
2023-11-10 8:03 ` Michael Olbrich
0 siblings, 1 reply; 4+ messages in thread
From: Roland Hieber @ 2023-11-06 10:55 UTC (permalink / raw)
To: ptxdist; +Cc: Enrico Jörns, Roland Hieber
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 <rhi@pengutronix.de>
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ptxdist] [PATCH] image-rauc: pick up hook script if it exists
2023-11-06 10:55 [ptxdist] [PATCH] image-rauc: pick up hook script if it exists Roland Hieber
@ 2023-11-10 8:03 ` Michael Olbrich
2023-11-14 22:07 ` [ptxdist] [PATCH v2] " Roland Hieber
0 siblings, 1 reply; 4+ messages in thread
From: Michael Olbrich @ 2023-11-10 8:03 UTC (permalink / raw)
To: Roland Hieber, ptxdist
On Mon, Nov 06, 2023 at 11:55:35AM +0100, Roland Hieber wrote:
> 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.
No. This must be explicit. Otherwise, accidentally placing the file in the
wrong location does not result in an error.
Please add an option for it and error out if no script is found.
Michael
> 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 <rhi@pengutronix.de>
> ---
> 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
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ptxdist] [PATCH v2] image-rauc: pick up hook script if it exists
2023-11-10 8:03 ` Michael Olbrich
@ 2023-11-14 22:07 ` Roland Hieber
2023-11-24 7:28 ` [ptxdist] [APPLIED] " Michael Olbrich
0 siblings, 1 reply; 4+ messages in thread
From: Roland Hieber @ 2023-11-14 22:07 UTC (permalink / raw)
To: ptxdist; +Cc: Roland Hieber
Introduce a new kconfig option to package a hook script into the RAUC
bundle and reference it in the manifest. Otherwise leave the [hooks]
section in the manifest empty. The hook script is searched
config/images/rauc-hooks.sh in the usual search locations. RAUC will
complain if a hook script is referenced but no hook script is found in
the image (i.e. IMAGE_RAUC_HOOK_SCRIPT is 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 <rhi@pengutronix.de>
---
PATCH v2:
- introduce an explicit kconfig option
PATCH v1: https://lore.ptxdist.org/ptxdist/20231106105534.3640846-1-rhi@pengutronix.de
---
config/images/rauc.config | 4 ++++
platforms/image-rauc.in | 9 +++++++++
rules/image-rauc.make | 15 +++++++++++++++
3 files changed, 28 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..2070cf0069c1 100644
--- a/platforms/image-rauc.in
+++ b/platforms/image-rauc.in
@@ -58,4 +58,13 @@ config IMAGE_RAUC_INTERMEDIATE
verification. The certificates must be stored in the CA of the
"update-intermediate" role of the code signing provider.
+config IMAGE_RAUC_HOOK
+ bool "include hook script"
+ help
+ If you enable this option and create a file named
+ 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.
+ Note that you still need to define the respective install or slot
+ hooks in the manifest so that RAUC calls them.
+
endif
diff --git a/rules/image-rauc.make b/rules/image-rauc.make
index 23d8d83b5251..e267e78c68f2 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_FILE := $(call ptx/in-path, PTXDIST_PATH, config/images/rauc-hooks.sh)
+
+$(call ptx/cfghash, IMAGE_RAUC, $(IMAGE_RAUC_HOOK_FILE))
+$(call ptx/cfghash-file, IMAGE_RAUC, $(IMAGE_RAUC_HOOK_FILE))
# ----------------------------------------------------------------------------
# Image
@@ -36,6 +40,16 @@ ifdef PTXCONF_IMAGE_RAUC_BUNDLE_FORMAT_CRYPT
IMAGE_RAUC_BUNDLE_FORMAT := "crypt"
endif
+ifdef PTXCONF_IMAGE_RAUC_HOOK
+IMAGE_RAUC_ENV_HOOK = \
+ RAUC_HOOK_FILE="file hooks.sh { image = \\"$(IMAGE_RAUC_HOOK_FILE)\\" }" \
+ 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ptxdist] [APPLIED] image-rauc: pick up hook script if it exists
2023-11-14 22:07 ` [ptxdist] [PATCH v2] " Roland Hieber
@ 2023-11-24 7:28 ` Michael Olbrich
0 siblings, 0 replies; 4+ messages in thread
From: Michael Olbrich @ 2023-11-24 7:28 UTC (permalink / raw)
To: ptxdist; +Cc: Roland Hieber
Thanks, applied as ae5c38009cceca58fb793c8de2c717f28dc31861.
Michael
[sent from post-receive hook]
On Fri, 24 Nov 2023 08:28:22 +0100, Roland Hieber <rhi@pengutronix.de> wrote:
> Introduce a new kconfig option to package a hook script into the RAUC
> bundle and reference it in the manifest. Otherwise leave the [hooks]
> section in the manifest empty. The hook script is searched
> config/images/rauc-hooks.sh in the usual search locations. RAUC will
> complain if a hook script is referenced but no hook script is found in
> the image (i.e. IMAGE_RAUC_HOOK_SCRIPT is 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 <rhi@pengutronix.de>
> Message-Id: <20231114220708.2816211-1-rhi@pengutronix.de>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
>
> 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..2070cf0069c1 100644
> --- a/platforms/image-rauc.in
> +++ b/platforms/image-rauc.in
> @@ -58,4 +58,13 @@ config IMAGE_RAUC_INTERMEDIATE
> verification. The certificates must be stored in the CA of the
> "update-intermediate" role of the code signing provider.
>
> +config IMAGE_RAUC_HOOK
> + bool "include hook script"
> + help
> + If you enable this option and create a file named
> + 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.
> + Note that you still need to define the respective install or slot
> + hooks in the manifest so that RAUC calls them.
> +
> endif
> diff --git a/rules/image-rauc.make b/rules/image-rauc.make
> index 23d8d83b5251..e267e78c68f2 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_FILE := $(call ptx/in-path, PTXDIST_PATH, config/images/rauc-hooks.sh)
> +
> +$(call ptx/cfghash, IMAGE_RAUC, $(IMAGE_RAUC_HOOK_FILE))
> +$(call ptx/cfghash-file, IMAGE_RAUC, $(IMAGE_RAUC_HOOK_FILE))
>
> # ----------------------------------------------------------------------------
> # Image
> @@ -36,6 +40,16 @@ ifdef PTXCONF_IMAGE_RAUC_BUNDLE_FORMAT_CRYPT
> IMAGE_RAUC_BUNDLE_FORMAT := "crypt"
> endif
>
> +ifdef PTXCONF_IMAGE_RAUC_HOOK
> +IMAGE_RAUC_ENV_HOOK = \
> + RAUC_HOOK_FILE="file hooks.sh { image = \\"$(IMAGE_RAUC_HOOK_FILE)\\" }" \
> + 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)" \
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-24 7:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-06 10:55 [ptxdist] [PATCH] image-rauc: pick up hook script if it exists Roland Hieber
2023-11-10 8:03 ` Michael Olbrich
2023-11-14 22:07 ` [ptxdist] [PATCH v2] " Roland Hieber
2023-11-24 7:28 ` [ptxdist] [APPLIED] " Michael Olbrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox