<br><br><blockquote type="cite" style="margin:0 0 0 0.5em;border-left:1px #00f solid;padding-left:1em;">De : Thomas Petazzoni <thomas.petazzoni@bootlin.com><br>
À : lpdev@cordier.org<br>
Sujet : Re: [Buildroot] Adding post image hook<br>
Date : 11/05/2020 17:50:27 Europe/Paris<br>
Copie à : buildroot@buildroot.org<br>
<br>
Hello,<br>
<br>
On Mon, 11 May 2020 16:35:10 +0200 (CEST)<br>
lpdev@cordier.org wrote:<br>
<br>
> I'm currently trying to improve my custom buildroot tree (that makes<br>
> use of BR2_EXTERNAL), especially the final steps. For instance my<br>
> external tree adds an extra steps through the<br>
> BR2_ROOTFS_POST_IMAGE_SCRIPT to generate the firmware file. This step<br>
> also retrieve the version of different softwares present in the final<br>
> image.<br>
> <br>
> However the post image script comes with a big limitation: we cannot<br>
> take the advantage of reading variables defined in the Makefile.<br>
<br>
You can actually do that, by running:<br>
<br>
        make VARS=<some-variable-name> printvars<br>
<br>
from your post-image script.<br>
<br>
If what you need to retrieve is the version of the different packages,<br>
you can also run:<br>
<br>
        make show-info<br>
<br>
from your post-image script, and parse the JSON output.<br><br></blockquote><div><br></div><div>Thank you for the tip. However this method seems to be very slow because of the makefile parsing (takes between 5 to 10sec on my PC). I would not recommend that for retrieving values of a lot of variables.<br></div><div><br></div><blockquote type="cite" style="margin:0 0 0 0.5em;border-left:1px #00f solid;padding-left:1em;">
<p><br></p>
> # Export some useful variable that can be used in other scripts<br>
> export BR2_CUSTOM_BOARDNAME := $(call qstrip,$(BR2_CUSTOM_BOARDNAME))<br>
> export BR2_CUSTOM_BOARDVERSION := $(shell git -C $(BR2_EXTERNAL_CUSTOM_PATH) describe --tags --dirty=-dev)<br>
> <br>
> # Make an Firmware Update package.<br>
> ifeq ($(BR2_CUSTOM_GENERATE_FIRMWARE),y)<br>
> genfirmware: target-post-image<br>
>    @$(call MESSAGE,"Compressing the filesystem...")<br>
>    pigz -9 -c -n $(BINARIES_DIR)/rootfs.ext4 > $(BINARIES_DIR)/rootfs.ext4.gz<br>
> <br>
>    @$(call MESSAGE,"Generating UEFI partition for the bootloader...")<br>
>    $(EXTRA_ENV) ./support/scripts/genimage.sh -c $(BR2_EXTERNAL_CUSTOM_PATH)/board/cstick/genimage_uefi.cfg<br>
> <br>
>    @$(call MESSAGE,"Generating firmware version $(BR2_CUSTOM_BOARDVERSION) for board $(BR2_CUSTOM_BOARDNAME) ")<br>
>    (We can use bash script here with any makefile variables defined at this point, such as BR2_OPENCV_VERSION for instance)<br>
> <br>
> # Override the default world target.<br>
> .PHONY: world<br>
> world: genfirmware<br>
> endif<br>
<br>
Otherwise, what you did here looks OK to me. It is a hack of course,<br>
but BR2_EXTERNAL is designed to allow hacks :-)<br>
<br></blockquote><div><br></div><div>Soooo cool, I just became an hacker then! :D Thank you for your time Thomas<br></div><div><br></div><blockquote type="cite" style="margin:0 0 0 0.5em;border-left:1px #00f solid;padding-left:1em;"><br>
Thomas<br>
-- <br>
Thomas Petazzoni, CTO, Bootlin<br>
Embedded Linux and Kernel engineering<br>
<a href="https://bootlin.com" rel="noreferrer">https://bootlin.com</a><br></blockquote>