Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Bruce Ashfield <bruce.ashfield@gmail.com>
To: adrian.freihofer@siemens.com
Cc: openembedded-core@lists.openembedded.org, marex@denx.de,
	a.fatoum@pengutronix.de
Subject: Re: [OE-core] [PATCH v6 01/21] devicetree: minor improvements
Date: Mon, 2 Jun 2025 14:31:17 -0400	[thread overview]
Message-ID: <aD3t9YToWyRP9JDH@gmail.com> (raw)
In-Reply-To: <20250602075714.32122-2-adrian.freihofer@siemens.com>

In message: [OE-core] [PATCH v6 01/21] devicetree: minor improvements
on 02/06/2025 Adrian Freihofer via lists.openembedded.org wrote:

> From: Adrian Freihofer <adrian.freihofer@siemens.com>
> 
> - Do not use the ${} bitbake syntax for shell internal variables
> - Fix shellcheck SC2045 warning:
>   Iterating over ls output is fragile. Use globs.
> - Improve error handling for dtc. Print the output, not only the exit
>   value.
> 
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>  meta/classes-recipe/devicetree.bbclass | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/classes-recipe/devicetree.bbclass b/meta/classes-recipe/devicetree.bbclass
> index 1806cb62cbf..0d0583c13a0 100644
> --- a/meta/classes-recipe/devicetree.bbclass
> +++ b/meta/classes-recipe/devicetree.bbclass
> @@ -109,7 +109,11 @@ def devicetree_compile(dtspath, includes, d):
>          ppargs.append("-I{0}".format(i))
>      ppargs += ["-o", "{0}.pp".format(dts), dtspath]
>      bb.note("Running {0}".format(" ".join(ppargs)))
> -    subprocess.run(ppargs, check = True)
> +    try:
> +        subprocess.run(ppargs, check=True, capture_output=True)
> +    except subprocess.CalledProcessError as e:
> +        bb.fatal(f"Command '{' '.join(ppargs)}' failed with return code {e.returncode}\nstdout: {e.stdout.decode()}\nstderr: {e.stderr.decode()}\ndtspath: {os.path.abspath(dtspath)}")
> +
>  
>      # determine if the file is an overlay or not (using the preprocessed file)
>      isoverlay = devicetree_source_is_overlay("{0}.pp".format(dts))
> @@ -125,7 +129,11 @@ def devicetree_compile(dtspath, includes, d):
>      dtcargs += ["-o", "{0}.{1}".format(dtname, "dtbo" if isoverlay else "dtb")]
>      dtcargs += ["-I", "dts", "-O", "dtb", "{0}.pp".format(dts)]
>      bb.note("Running {0}".format(" ".join(dtcargs)))
> -    subprocess.run(dtcargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
> +    try:
> +        subprocess.run(dtcargs, check=True, capture_output=True)
> +    except subprocess.CalledProcessError as e:
> +        bb.fatal(f"Command '{' '.join(dtcargs)}' failed with return code {e.returncode}\nstdout: {e.stdout.decode()}\nstderr: {e.stderr.decode()}\ndtname: {dtname}")
> +
>  
>  python devicetree_do_compile() {
>      import re
> @@ -144,14 +152,14 @@ python devicetree_do_compile() {
>  }
>  
>  devicetree_do_install() {
> -    for DTB_FILE in `ls *.dtb *.dtbo`; do
> -        install -Dm 0644 ${B}/${DTB_FILE} ${D}/boot/devicetree/${DTB_FILE}
> +    for dtb_file in *.dtb *.dtbo; do
> +        install -Dm 0644 "${B}/$dtb_file" "${D}/boot/devicetree/$dtb_file"
>      done
>  }
>  
>  devicetree_do_deploy() {
> -    for DTB_FILE in `ls *.dtb *.dtbo`; do
> -        install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/devicetree/${DTB_FILE}
> +    for dtb_file in *.dtb *.dtbo; do

The behaviour on no dtb and dtbo files is different between
the two.

Is that a situation we should detect and throw a useful error
message ? It may end up not being possible to happen, but since
this patch is about improving the handling of the other commands,
I thought it might be relevant.

Bruce

> +        install -Dm 0644 "${B}/$dtb_file" "${DEPLOYDIR}/devicetree/$dtb_file"
>      done
>  }
>  addtask deploy before do_build after do_install
> -- 
> 2.49.0
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#217689): https://lists.openembedded.org/g/openembedded-core/message/217689
> Mute This Topic: https://lists.openembedded.org/mt/113424423/1050810
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



  reply	other threads:[~2025-06-02 18:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-02  7:56 [PATCH v6 00/21] FIT image improvements AdrianF
2025-06-02  7:56 ` [PATCH v6 01/21] devicetree: minor improvements AdrianF
2025-06-02 18:31   ` Bruce Ashfield [this message]
2025-06-02  7:56 ` [PATCH v6 02/21] oe-selftest: add new ext dtb recipe AdrianF
2025-06-02  7:56 ` [PATCH v6 03/21] oe-selftest: fitimage: test external dtb AdrianF
2025-06-02  7:56 ` [PATCH v6 04/21] oe-selftest: fitimage: test FIT_CONF_PREFIX AdrianF
2025-06-02  7:56 ` [PATCH v6 05/21] oe-selftest: fitimage: test FIT_CONF_DEFAULT_DTB AdrianF
2025-06-02  7:56 ` [PATCH v6 06/21] kernel-signing-keys-native: refactor key generation into a new recipe AdrianF
2025-06-02  7:56 ` [PATCH v6 07/21] maintainers: add myself for kernel-signing-keys-native AdrianF
2025-06-02  7:56 ` [PATCH v6 08/21] oe-selftest: fitimage: cleanup FIT_GENERATE_KEYS AdrianF
2025-06-02  7:56 ` [PATCH v6 09/21] kernel-uboot.bbclass: do not require the kernel build folder AdrianF
2025-06-02  7:56 ` [PATCH v6 10/21] kernel-uboot.bbclass: deploy the vmlinux kernel binary AdrianF
2025-06-02 18:51   ` [OE-core] " Bruce Ashfield
2025-06-02 19:44     ` Freihofer, Adrian
2025-06-02 19:53       ` Bruce Ashfield
2025-06-02  7:56 ` [PATCH v6 11/21] kernel-fitimage: refactor order in its AdrianF
2025-06-02  7:56 ` [PATCH v6 12/21] kernel-fit-image.bbclass: add a new FIT image implementation AdrianF
2025-06-02 18:12   ` [OE-core] " Bruce Ashfield
2025-06-02  7:56 ` [PATCH v6 13/21] maintainers: add myself for linux-yocto-fitimage AdrianF
2025-06-02  7:56 ` [PATCH v6 14/21] oe-selftest: fitimage: add tests for fitimage.py AdrianF
2025-06-02  7:56 ` [PATCH v6 15/21] oe-selftest: fitimage: support new FIT recipe as well AdrianF
2025-06-02  7:56 ` [PATCH v6 16/21] oe-selftest: fitimage: run all tests for both FIT implementations AdrianF
2025-06-02  7:56 ` [PATCH v6 17/21] oe-selftest: fitimage refactor classes AdrianF
2025-06-02  7:56 ` [PATCH v6 18/21] kernel-fitimage: re-write its code in Python AdrianF
2025-06-02  7:56 ` [PATCH v6 19/21] oe-selftest: fitimage: remove kernel-fitimage tests AdrianF
2025-06-02  7:56 ` [PATCH v6 20/21] kernel.bbclass: remove support for type fitImage AdrianF
2025-06-02 18:59   ` [OE-core] " Bruce Ashfield
2025-06-02  7:56 ` [PATCH v6 21/21] kernel-fitimage.bbclass: remove it AdrianF

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=aD3t9YToWyRP9JDH@gmail.com \
    --to=bruce.ashfield@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=adrian.freihofer@siemens.com \
    --cc=marex@denx.de \
    --cc=openembedded-core@lists.openembedded.org \
    /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