All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Thiery <heiko.thiery@gmail.com>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Michael Walle <michael@walle.cc>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>,
	buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] Add BR2_ROOTFS_POST_{PRE_BUILD|POST_BUILD|FAKEROOT|IMAGE}_SCRIPT_ARGS
Date: Thu, 28 Mar 2024 14:24:34 +0100	[thread overview]
Message-ID: <CAEyMn7bE3sXSQwHPSovj0qWjcQTxSSNtVNShW2weJhFoxK3Sfg@mail.gmail.com> (raw)
In-Reply-To: <ZgVtJzC7VLCxua0H@landeda>

Hi Yann,

Am Do., 28. März 2024 um 14:14 Uhr schrieb Yann E. MORIN
<yann.morin.1998@free.fr>:
>
> Heiko, All,
>
> On 2024-03-28 13:28 +0100, Heiko Thiery spake thusly:
> > You only can specify one list of arguments that are passed to several
> > scripts (BR2_ROOTFS_PRE_BUILD_SCRIPT, BR2_ROOTFS_POST_BUILD_SCRIPT,
> > BR2_ROOTFS_POST_FAKEROOT_SCRIPT and BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS).
> >
> > So you have to be careful that the arguments for these scripts do not collide.
> >
> > To allow specifiying dedicated arguments to each of the script the new
> > config options are introduced. For backward compatibility the value of
> > BR2_ROOTFS_POST_SCRIPT_ARGS is passed to the scripts in case the
> > specific argument values are not present.
> >
> > Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
> > ---
> >  Makefile                              |  9 ++--
> >  docs/manual/customize-post-image.adoc |  5 +++
> >  docs/manual/customize-rootfs.adoc     |  6 +++
> >  fs/common.mk                          |  2 +-
> >  system/Config.in                      | 64 ++++++++++++++++++++++++---
> >  5 files changed, 76 insertions(+), 10 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 91973cca60..b2fd3e881b 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -584,7 +584,8 @@ $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
> >  prepare: $(BUILD_DIR)/buildroot-config/auto.conf
> >       @$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \
> >               $(call MESSAGE,"Executing pre-build script $(s)"); \
> > -             $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
> > +             $(EXTRA_ENV) $(s) $(TARGET_DIR) \
> > +             $(if $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS)),$(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS)),$(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)))$(sep))
>
> I think I would just have gone with a much simpler solution:
>
>     $(EXTRA_ENV) $(s) $(TARGET_DIR) \
>         $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS) \
>         -- \
>         $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS))
>
> I.e. always pass the generic arguments as they are passed today, add a
> separating marker (the usual --), and then the new arguments.
>
> The advantge is that it still allows to easily pass common arguments to
> all scripts, adds the possibility to pass custom args to the different
> types of scripts (post build, fakeroot, and post image).
>
> The drawback is that it could break existing scripts that do iterate
> over their arguments, in they are not prepared to cope with --. I have
> no idea how prevalent that usage is; I would think that scripts mostly
> expects a fixed number of arguments, and refer to them with explicit
> positional args (${1}, ${2}...), or that they are expecting standard
> getopt args, like our generic support/scripts/genimage.sh, which would
> then stop processing stuff when encountering '--'.
>
> Or even simpler yet, just pass both:
>
>     $(EXTRA_ENV) $(s) \
>         $(TARGET_DIR) \
>         $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS) \
>         $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS))

I think this is really a easier solution with the advantage of having
common args acroos all script types.

> The reasoning here is even simpler:
>
>  1. if people provide scripts that have a scommon set of args, and each
>     type of scripts have special args, that just works:
>     - if args are only positional, scripts have to hardcode that
>       knowledge, so they know how to interpret the positionl args,
>     - if scripts use option parsing, like with getopt, then that also
>       automagically works
>     In both cases, they can decide to pass the common args with the
>     existing BR2_ROOTFS_POST_SCRIPT_ARGS, and the specific args with the
>     new BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS, or they can decide to ignore
>     he former  and ionly use the latter;
>
>  2. if people provide scripts that have no common args, then they're
>     back to the situation above, where the set of common args is just
>     empty.
>
> So, I think this last, simpler option is the best soltuion.
>
> Thoughts?

I will rework the patch and provide an updated one.

-- 
Heiko
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2024-03-28 13:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 12:28 [Buildroot] [PATCH] Add BR2_ROOTFS_POST_{PRE_BUILD|POST_BUILD|FAKEROOT|IMAGE}_SCRIPT_ARGS Heiko Thiery
2024-03-28 13:14 ` Yann E. MORIN
2024-03-28 13:24   ` Heiko Thiery [this message]

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=CAEyMn7bE3sXSQwHPSovj0qWjcQTxSSNtVNShW2weJhFoxK3Sfg@mail.gmail.com \
    --to=heiko.thiery@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=michael@walle.cc \
    --cc=thomas.de_schampheleire@nokia.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=yann.morin.1998@free.fr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.