public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
From: Thomas Perale via buildroot <buildroot@buildroot.org>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Perale <thomas.perale@mind.be>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/3 v4] support/br2-external: remove leftover trap
Date: Fri, 20 Mar 2026 16:55:03 +0100	[thread overview]
Message-ID: <20260320155503.176524-1-thomas.perale@mind.be> (raw)
In-Reply-To: <7afd223643ad94c36adc4ff486197aba5f073d0d.1770155657.git.yann.morin.1998@free.fr>

In reply of:
> The trap was initially introduced in c5fa9308ea4e (core/br2-external:
> properly report unexpected errors), in 2017, to catch all unexpected
> errors, back when a single file was generated, and errors emitted to
> stderr.
> 
> Since commit d027cd75d098 (core: generate all br2-external files in
> one go), in 2019 the single output file 'ofile' is no longer created,
> as multiple output files were then introduced, while messages for
> *expected errors* were redirected to a Makefile variable assignment
> emitted on stdout, at which point the script just exits (in error);
> expected failures only occur in do_validate().
> 
> Unexpected errors can only occur on failure to create, or write to,
> output files, either '.br2-external.mk' in do_validate() or do_mk(),
> or any of the kconfig fragments in do_kconfig(). Cause for failure to
> create those can only be a no-space-left-on-device condition, as they
> are created in a directory that was just created by the script earlier
> in main(), and thus has the necessary mode; failure to create that
> directory is now caught explicitly.
> 
> A trap on ERR is not called when the shell exits explicitly with a call
> to 'exit', thus, only failures to create or write to output file would
> be caught. In that case, we are better off not trying to write to those
> files anyway: failure to create the file would already be reported by
> the shell on stderr, while disk-full would not allow to store the output
> anyway...
> 
> In any case, the script exits in error, which is going to be caught by
> the caller, which will terminate.
> 
> So, drop the trap altogether.
> 
> As a side effect, that squelches a shellcheck error.
> 
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> 

Applied to 2025.02.x & 2026.02.x. Thanks

> ---
> Note: remaining shellcheck errors will be addressed separately in the
> following patch.
> ---
>  support/scripts/br2-external | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/support/scripts/br2-external b/support/scripts/br2-external
> index 8aea479d20..6d4fc1a791 100755
> --- a/support/scripts/br2-external
> +++ b/support/scripts/br2-external
> @@ -30,10 +30,10 @@ main() {
>          error "no output directory specified (-d)\n"
>      fi
>  
> -    # Trap any unexpected error to generate a meaningful error message
> -    trap "error 'unexpected error while generating ${ofile}\n'" ERR
> +    if ! mkdir -p "${outputdir}"; then
> +        error "Cannot create output directory '%s'\n" "${outputdir}"
> +    fi
>  
> -    mkdir -p "${outputdir}"
>      do_validate "${outputdir}" ${@//:/ }
>      do_mk "${outputdir}"
>      do_kconfig "${outputdir}"
> -- 
> 2.52.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2026-03-20 15:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 21:54 [Buildroot] [PATCH 0/3 v4] support/br2-external: fix shellcheck and better document BR2_EXTERNAL (branch yem/misc) Yann E. MORIN via buildroot
2026-02-03 21:54 ` [Buildroot] [PATCH 1/3 v4] support/br2-external: remove leftover trap Yann E. MORIN via buildroot
2026-03-13 21:25   ` Romain Naour via buildroot
2026-03-20 15:55   ` Thomas Perale via buildroot [this message]
2026-02-03 21:54 ` [Buildroot] [PATCH 2/3 v4] support/br2-external: fix remaining shellcheck errors Yann E. MORIN via buildroot
2026-03-20 15:55   ` Thomas Perale via buildroot
2026-02-03 21:54 ` [Buildroot] [PATCH 3/3 v4] docs/manual: use space-separated list for BR2_EXTERNAL Yann E. MORIN via buildroot
2026-03-20 15:55   ` Thomas Perale via buildroot

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=20260320155503.176524-1-thomas.perale@mind.be \
    --to=buildroot@buildroot.org \
    --cc=thomas.perale@mind.be \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox