Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 01/15] fs: add genimage infra
Date: Wed, 13 Apr 2016 23:32:22 +0200	[thread overview]
Message-ID: <570EBAE6.1080000@mind.be> (raw)
In-Reply-To: <1460577820-32164-2-git-send-email-ezequiel@vanguardiasur.com.ar>

On 04/13/16 22:03, Ezequiel Garcia wrote:
> Currently, all the boards using genimage are using the same
> command incantation. Therefore, let's introduce a new filesystem
> infra to factorize them and allow easier genimage setup.
>
> This commit adds a new genimage infra, by calling genimage
> with a user-provided config file. The user is still responsible
> of enabling the apropriate rootfs filesystem images.

  And for enabling dosfstools/mtools (as observed by Thomas).

>
> Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> ---
>   fs/Config.in            |  1 +
>   fs/genimage/Config.in   | 20 ++++++++++++++++++++
>   fs/genimage/genimage.mk | 21 +++++++++++++++++++++
>   3 files changed, 42 insertions(+)
>   create mode 100644 fs/genimage/Config.in
>   create mode 100644 fs/genimage/genimage.mk
>
> diff --git a/fs/Config.in b/fs/Config.in
> index 51ccf28169ef..94fe1446047f 100644
> --- a/fs/Config.in
> +++ b/fs/Config.in
> @@ -5,6 +5,7 @@ source "fs/cloop/Config.in"
>   source "fs/cpio/Config.in"
>   source "fs/cramfs/Config.in"
>   source "fs/ext2/Config.in"
> +source "fs/genimage/Config.in"

  I think this shouldn't be done alphabetically, but really at the end.

>   source "fs/initramfs/Config.in"
>   source "fs/iso9660/Config.in"
>   source "fs/jffs2/Config.in"
> diff --git a/fs/genimage/Config.in b/fs/genimage/Config.in
> new file mode 100644
> index 000000000000..749494652464
> --- /dev/null
> +++ b/fs/genimage/Config.in
> @@ -0,0 +1,20 @@
> +config BR2_TARGET_ROOTFS_GENIMAGE
> +	bool "full system image using genimage"
> +	help
> +	  Generate a full system image using the genimage tool
> +	  and a user-provided configuration file. The image generated
> +	  will contain a partition table and will be ready to be copied
> +	  onto storage media, such as MMC, NAND or NOR devices.
> +
> +	  Keep in mind that you probably require to enable a rootfs
> +	  filesystem image, according to the genimage config file that you
> +	  provide.

  And to select mtools/dosfstools. Thomas proposed to add an option for that. 
For me, either an explicit genimage option or just adding the help text for it 
is OK.

> +
> +if BR2_TARGET_ROOTFS_GENIMAGE
> +
> +config BR2_TARGET_ROOTFS_GENIMAGE_CFG
> +	string "genimage config file"
> +	help
> +	  Genimage user configuration file.
> +
> +endif # BR2_TARGET_ROOTFS_GENIMAGE
> diff --git a/fs/genimage/genimage.mk b/fs/genimage/genimage.mk
> new file mode 100644
> index 000000000000..17c146b6b519
> --- /dev/null
> +++ b/fs/genimage/genimage.mk
> @@ -0,0 +1,21 @@
> +################################################################################
> +#
> +# Generate a system image using genimage
> +#
> +################################################################################
> +
> +ROOTFS_GENIMAGE_DEPENDENCIES = host-genimage
> +
> +GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"

  Variable name should be ROOTFS_GENIMAGE_TMP

> +
> +define ROOTFS_GENIMAGE_CMD
> +	$(RM) -rf ${GENIMAGE_TMP} &&		\

  && is not needed, treat it as two separate commands.
  -f is not needed, it is already in $(RM).
  All variables should use $(), not ${} (below as well).

> +	$(HOST_DIR)/usr/bin/genimage		\

  We don't generally align \ (annoying whitespace changes when you add a line).

> +		--rootpath ${TARGET_DIR}	\
> +		--tmppath ${GENIMAGE_TMP}	\
> +		--inputpath ${BINARIES_DIR}	\
> +		--outputpath ${BINARIES_DIR}	\
> +		--config ${BR2_TARGET_ROOTFS_GENIMAGE_CFG}
> +endef
> +
> +$(eval $(call ROOTFS_TARGET,genimage))

  I think that, like for initramfs, the infra has little to offer here. And it 
is in fact in the way, because (as observed by Thomas) you'll want to add

rootfs-genimage: $(TARGETS_ROOTFS)

which leads to a circular dependency.

  So to make sure that it happens in the right order, I think you need something 
like:

rootfs-genimage: $(TARGETS_ROOTFS) $(ROOTFS_GENIMAGE_DEPENDENCIES)
	$(RM) -r $(ROOTFS_GENIMAGE_TMP)
	$(HOST_DIR)/usr/bin/genimage \
		...

ifeq ($(BR2_TARGET_ROOTFS_GENIMAGE),y)

target-post-image: rootfs-genimage

# Make sure the genimage dependencies appear in graph-depends
show-targets:
	@echo $(ROOTFS_GENIMAGE_DEPENDENCIES)

ifeq ($(wildcard $(BR2_TARGET_ROOTFS_GENIMAGE_CFG),))
$(error $(BR2_TARGET_ROOTFS_GENIMAGE_CFG) does not exist)

endif




  However, I'm afraid that we're moving a bit too fast after all. There are 
several open issues still:

- Do post-image scripts come before or after genimage?
- What with the dosfstools/mtools dependency?
- Should we support genimage.cfg files that are generated from a post-image script?
- Should we support several genimage.cfg files, producing several images (e.g. a 
NAND and a SD image)?

  So, the current approach works well for the bundled defconfigs, but for real 
use cases I think it's a bit too limited to be practical after all.

  Therefore, at least as a first step, I guess it's better to just move the 
script to a common place, e.g. to package/genimage/post-image.sh. Let it take a 
single argument for the genimage.cfg file, and add some documentation to the manual.


  Regards,
  Arnout

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

  parent reply	other threads:[~2016-04-13 21:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 20:03 [Buildroot] [PATCH 00/15] Introduce a genimage infra Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 01/15] fs: add " Ezequiel Garcia
2016-04-13 20:24   ` Thomas Petazzoni
2016-04-13 21:32   ` Arnout Vandecappelle [this message]
2016-04-13 21:41     ` Thomas Petazzoni
2016-04-14  8:33       ` Peter Korsgaard
2016-04-14 21:31         ` Arnout Vandecappelle
2016-04-14 21:37           ` Peter Korsgaard
2016-04-14 21:42             ` Yann E. MORIN
2016-04-15  6:45               ` Peter Korsgaard
2016-04-13 21:45     ` Thomas Petazzoni
2016-04-13 22:01       ` Ezequiel Garcia
2016-04-14 21:16       ` Peter Korsgaard
2016-04-14 21:28         ` Arnout Vandecappelle
2016-04-13 20:03 ` [Buildroot] [PATCH 02/15] board/minnowboard-max: Leverage the new " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 03/15] board/olimex_a20_olinuxino: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 04/15] board/wandboard: " Ezequiel Garcia
2016-04-13 20:25   ` Thomas Petazzoni
2016-04-13 22:02     ` Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 05/15] board/firefly: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 06/15] board/cubieboard2: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 07/15] board/arietta-g25: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 08/15] board/imx6ulevk: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 09/15] board/galileo: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 10/15] board/pandaboard: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 11/15] board/boundarydevices: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 12/15] board/imx233_olinuxino: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 13/15] board/orangepipc: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 14/15] board/raspberry*: " Ezequiel Garcia
2016-04-13 20:03 ` [Buildroot] [PATCH 15/15] board/via_imx6_vab820: " Ezequiel Garcia

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=570EBAE6.1080000@mind.be \
    --to=arnout@mind.be \
    --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