[Buildroot] genimage.sh arguments [was: [PATCH v8 1/2] genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT]

Gaël PORTAY gael.portay at savoirfairelinux.com
Tue Apr 18 13:52:08 UTC 2017


Arnout,

On Tue, Apr 18, 2017 at 01:51:28PM +0200, Arnout Vandecappelle wrote:
>  [Adding Etienne to the Cc as the main contributor of genimage.sh]
> 
> On 17-04-17 16:20, Gaël PORTAY wrote:
> > Hello Abhimanyu,
> > 
> [snip]
> > Initially, genimage.sh script was NOT intend to be run either as or inside a
> > post-image. It was a Makefile target [1]. [2] and [3] are use cases.
> 
>  True, but since [1] isn't applied yet and is still under discussion, we really
> want to be able to call it as a post-image script directly.
> 

Okay.

The question is, do we "accept" to run genimage.sh inside a post-image script?

If yes, developpers have to call genimage.sh with a fake first argument (or the
binary directory).

If no, the shift is a fair solution alongside a comment.

A second solution consists in using this first argument in the script:

	# First argument is the binary directory
	bindir="$1"
	shift
	while getopts :c: OPT ; do
		case "${OPT}" in
		c) GENIMAGE_CFG="${OPTARG}";;
		:) die "option '${OPTARG}' expects a mandatory argument";;
		\?) die "unknown option '${OPTARG}'";;
		esac
	done

	# ...

	genimage \
	--rootpath "${TARGET_DIR}"     \
	--tmppath "${GENIMAGE_TMP}"    \
	--inputpath "${bindir}"  \
	--outputpath "${bindir}" \
	--config "${GENIMAGE_CFG}"

But, if we deprecated the first argument, it also impacts the genimage.sh.

> 
> > Maybe, a cleaner solution consists in updating the Makefile to remove this first
> > argument given to both post-build and post-image scripts. But it breaks the
> > existing.
> 
>  I don't think we can do that. Most "interesting" post-* scripts are out of
> tree, so we can't change them. Although updating Buildroot is expected to have
> some implications on the user integration layer (cfr. the change in br2-external
> handling), we try to avoid it.
> 

That is why I added Thomas and you in copy :)

>  It would indeed be good to remove that first argument, but then I think we have
> to go through a (long) deprecation period. That means right now: mark it as
> legacy in the manual and help text.
> 
> > Thomas, Arnout, do you have a better idea?
> > 
> > I had a quick look to scripts in-tree; they do not seem to use this parameter.
> > 
> > Instead, they access directly to $TARGET_DIR or $BINARIES_DIR values using the
> > environment variables.
> > 
> > For extra arguments, they use $2, $3; they need to be updated.
> 
>  ... which proves that deprecating it is not easy, because it's fairly difficult
> to make a script compatible with both the "new" and the "old" way - cfr. the
> special care taking in the genimage.sh script, and that's relatively easy
> because the argument has a -c added to it.

I agree.

> 
> [snip]
> > [1] http://patchwork.ozlabs.org/patch/744825/
> > [2] http://patchwork.ozlabs.org/patch/744826/
> > [3] http://patchwork.ozlabs.org/patch/744824/
> 

Something that would be nice is to allow to give extra arguments to genimage.
genimage.sh is acting as a wrapper.

	BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
	BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/boardname/genimage.cfg -- --loglevel 1"

Regards,
Gaël



More information about the buildroot mailing list