* [Buildroot] [PATCH] package/uboot: detect missing user-supplied environment source files
@ 2017-12-06 22:25 Yann E. MORIN
2017-12-06 22:37 ` Thomas Petazzoni
0 siblings, 1 reply; 2+ messages in thread
From: Yann E. MORIN @ 2017-12-06 22:25 UTC (permalink / raw)
To: buildroot
Since 0542bb79e8 (uboot: Support multiple environment source files),
a missing user-supplied environment source files is no longer detected.
This is because we cat them all, and feed the concatenation to the stdin
of mkenvimage. So, if one source file is missing, the cat exits in error,
but the compound command exits with the exit code of the last command,
which is that of mkenvimage, which happens to be happy with whatever it
is fed on its stdin, even is empty.
We fix that by creating a temporary file, that we even leave afterward
for the user to inspect.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Cam Hutchison <camh@xdna.net>
---
boot/uboot/uboot.mk | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index a1fac7dcae..518433796f 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -250,11 +250,13 @@ define UBOOT_INSTALL_IMAGES_CMDS
)
)
$(if $(BR2_TARGET_UBOOT_ENVIMAGE),
- cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) | \
- $(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
- $(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
- $(if $(filter BIG,$(BR2_ENDIAN)),-b) \
- -o $(BINARIES_DIR)/uboot-env.bin -)
+ cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) \
+ >$(BINARIES_DIR)/uboot-env.txt && \
+ $(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
+ $(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
+ $(if $(filter BIG,$(BR2_ENDIAN)),-b) \
+ -o $(BINARIES_DIR)/uboot-env.bin \
+ $(BINARIES_DIR)/uboot-env.txt)
$(if $(BR2_TARGET_UBOOT_BOOT_SCRIPT),
$(HOST_DIR)/bin/mkimage -C none -A $(MKIMAGE_ARCH) -T script \
-d $(call qstrip,$(BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE)) \
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Buildroot] [PATCH] package/uboot: detect missing user-supplied environment source files
2017-12-06 22:25 [Buildroot] [PATCH] package/uboot: detect missing user-supplied environment source files Yann E. MORIN
@ 2017-12-06 22:37 ` Thomas Petazzoni
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni @ 2017-12-06 22:37 UTC (permalink / raw)
To: buildroot
Hello,
On Wed, 6 Dec 2017 23:25:58 +0100, Yann E. MORIN wrote:
> Since 0542bb79e8 (uboot: Support multiple environment source files),
> a missing user-supplied environment source files is no longer detected.
>
> This is because we cat them all, and feed the concatenation to the stdin
> of mkenvimage. So, if one source file is missing, the cat exits in error,
> but the compound command exits with the exit code of the last command,
> which is that of mkenvimage, which happens to be happy with whatever it
> is fed on its stdin, even is empty.
>
> We fix that by creating a temporary file, that we even leave afterward
> for the user to inspect.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Cam Hutchison <camh@xdna.net>
Thanks for this.
> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
> index a1fac7dcae..518433796f 100644
> --- a/boot/uboot/uboot.mk
> +++ b/boot/uboot/uboot.mk
> @@ -250,11 +250,13 @@ define UBOOT_INSTALL_IMAGES_CMDS
> )
> )
> $(if $(BR2_TARGET_UBOOT_ENVIMAGE),
> - cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) | \
> - $(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
> - $(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
> - $(if $(filter BIG,$(BR2_ENDIAN)),-b) \
> - -o $(BINARIES_DIR)/uboot-env.bin -)
> + cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) \
> + >$(BINARIES_DIR)/uboot-env.txt && \
> + $(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
> + $(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
> + $(if $(filter BIG,$(BR2_ENDIAN)),-b) \
> + -o $(BINARIES_DIR)/uboot-env.bin \
> + $(BINARIES_DIR)/uboot-env.txt)
I'm not a big fan of the && here. Perhaps it's time to move to:
ifeq ($(BR2_TARGET_UBOOT_ENVIMAGE),y)
define UBOOT_GENERATE_ENVIMAGE
cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) \
>$(BINARIES_DIR)/uboot-env.txt
$(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
$(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
$(if $(filter BIG,$(BR2_ENDIAN)),-b) \
-o $(BINARIES_DIR)/uboot-env.bin \
$(BINARIES_DIR)/uboot-env.txt
endef
endif
define UBOOT_INSTALL_IMAGES_CMDS
...
$(UBOOT_GENERATE_ENVIMAGE)
...
endef
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-06 22:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-06 22:25 [Buildroot] [PATCH] package/uboot: detect missing user-supplied environment source files Yann E. MORIN
2017-12-06 22:37 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox