Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Adding post image hook
@ 2020-05-11 14:35 lpdev at cordier.org
  2020-05-11 15:50 ` Thomas Petazzoni
  0 siblings, 1 reply; 10+ messages in thread
From: lpdev at cordier.org @ 2020-05-11 14:35 UTC (permalink / raw)
  To: buildroot

Hello,

I'm currently trying to improve my custom buildroot tree (that makes use of BR2_EXTERNAL), especially the final steps. For instance my external tree adds an extra steps through the BR2_ROOTFS_POST_IMAGE_SCRIPT to generate the firmware file. This step also retrieve the version of different softwares present in the final image.

However the post image script comes with a big limitation: we cannot take the advantage of reading variables defined in the Makefile. As stated in the doc, only few environment variables are available. The only way to do so is to use the BR2_ROOTFS_POST_SCRIPT_ARGS, but it is also cumbersome to create a getopt parser in the .sh script.

I would like to know if adding a post image hook in the makefile could help to have a cleaner tree with less .sh files, less getopt parsing, etc.

This would be like:

define GENIMAGE_HOOK
 # Call genimage and other stuf here
endef 

define SWUPDATE_HOOK
 # Call genimage and other stuf here
endef 


BR2_POST_IMAGE_TARGET_HOOKS += GENIMAGE_HOOK
BR2_POST_IMAGE_TARGET_HOOKS += SWUPDATE_HOOK

Those could be defined in the external.mk for instance. I can do a PR if this feature makes sense.



This is how I decided to handle the firmware image generation currently. I'm not sure it's the best way for handling such case, because I'm overriding the default "world" target. I'm opened to any suggestions.

____________________________________________________
# Export some useful variable that can be used in other scripts
export BR2_CUSTOM_BOARDNAME := $(call qstrip,$(BR2_CUSTOM_BOARDNAME))
export BR2_CUSTOM_BOARDVERSION := $(shell git -C $(BR2_EXTERNAL_CUSTOM_PATH) describe --tags --dirty=-dev)

# Make an Firmware Update package.
ifeq ($(BR2_CUSTOM_GENERATE_FIRMWARE),y)
genfirmware: target-post-image
	@$(call MESSAGE,"Compressing the filesystem...")
	pigz -9 -c -n $(BINARIES_DIR)/rootfs.ext4 > $(BINARIES_DIR)/rootfs.ext4.gz

	@$(call MESSAGE,"Generating UEFI partition for the bootloader...")
	$(EXTRA_ENV) ./support/scripts/genimage.sh -c $(BR2_EXTERNAL_CUSTOM_PATH)/board/cstick/genimage_uefi.cfg

	@$(call MESSAGE,"Generating firmware version $(BR2_CUSTOM_BOARDVERSION) for board $(BR2_CUSTOM_BOARDNAME) ")
	(We can use bash script here with any makefile variables defined at this point, such as BR2_OPENCV_VERSION for instance)

# Override the default world target.
.PHONY: world
world: genfirmware
endif

...
____________________________________________________


Thank you for your time,

Louis-Paul CORDIER

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-13 23:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-11 14:35 [Buildroot] Adding post image hook lpdev at cordier.org
2020-05-11 15:50 ` Thomas Petazzoni
2020-05-13 20:05   ` lpdev at cordier.org
2020-05-13 20:16     ` Thomas Petazzoni
2020-05-13 20:35       ` Patrick Mochel
2020-05-13 21:09       ` Patrick Mochel
2020-05-13 21:29         ` Yann E. MORIN
2020-05-13 21:32           ` Yann E. MORIN
2020-05-13 21:46           ` Patrick Mochel
2020-05-13 23:27             ` LP C

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox