From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] Adding post image hook
Date: Mon, 11 May 2020 17:50:27 +0200 [thread overview]
Message-ID: <20200511175027.71ed1d22@windsurf.home> (raw)
In-Reply-To: <ea-mime-5eb9629e-6492-6239a409@www-1.mailo.com>
Hello,
On Mon, 11 May 2020 16:35:10 +0200 (CEST)
lpdev at cordier.org wrote:
> 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.
You can actually do that, by running:
make VARS=<some-variable-name> printvars
from your post-image script.
If what you need to retrieve is the version of the different packages,
you can also run:
make show-info
from your post-image script, and parse the JSON output.
> # 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
Otherwise, what you did here looks OK to me. It is a hack of course,
but BR2_EXTERNAL is designed to allow hacks :-)
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2020-05-11 15:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 14:35 [Buildroot] Adding post image hook lpdev at cordier.org
2020-05-11 15:50 ` Thomas Petazzoni [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200511175027.71ed1d22@windsurf.home \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox