diff mbox series

create-spdx-2.2: combine spdx can try to write before dir creation

Message ID 20231215171046.2926492-1-jpuhlman@mvista.com
State Accepted, archived
Commit bb9f2a9c0ff5dcdeaf1a0beb6a614d0d022a2481
Headers show
Series create-spdx-2.2: combine spdx can try to write before dir creation | expand

Commit Message

Jeremy Puhlman Dec. 15, 2023, 5:10 p.m. UTC
From: "Jeremy A. Puhlman" <jpuhlman@mvista.com>

On occasion a file is attmpeded to be opened prior to the
creation of the spdx_workdir. Create the directory before
the open, just in case.

File: '/build/layers/poky/meta/classes/create-spdx-2.2.bbclass', lineno: 1081, function: combine_spdx
     1077:        )
     1078:
     1079:    image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
     1080:
 *** 1081:    with image_spdx_path.open("wb") as f:
     1082:        doc.to_json(f, sort_keys=True, indent=get_json_indent(d))

Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com>
---
 meta/classes/create-spdx-2.2.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joshua Watt Dec. 15, 2023, 5:19 p.m. UTC | #1
LGTM, Thanks

Reviewed-By: Joshua Watt <JPEWhacker@gmail.com>

On Fri, Dec 15, 2023 at 10:11 AM Jeremy Puhlman via
lists.openembedded.org <jpuhlman=mvista.com@lists.openembedded.org>
wrote:
>
> From: "Jeremy A. Puhlman" <jpuhlman@mvista.com>
>
> On occasion a file is attmpeded to be opened prior to the
> creation of the spdx_workdir. Create the directory before
> the open, just in case.
>
> File: '/build/layers/poky/meta/classes/create-spdx-2.2.bbclass', lineno: 1081, function: combine_spdx
>      1077:        )
>      1078:
>      1079:    image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
>      1080:
>  *** 1081:    with image_spdx_path.open("wb") as f:
>      1082:        doc.to_json(f, sort_keys=True, indent=get_json_indent(d))
>
> Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com>
> ---
>  meta/classes/create-spdx-2.2.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
> index b0aef80db1..486efadba9 100644
> --- a/meta/classes/create-spdx-2.2.bbclass
> +++ b/meta/classes/create-spdx-2.2.bbclass
> @@ -1075,7 +1075,7 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx
>              "%s:%s" % (runtime_ref.externalDocumentId, runtime_doc.SPDXID),
>              comment="Runtime dependencies for %s" % name
>          )
> -
> +    bb.utils.mkdirhier(spdx_workdir)
>      image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
>
>      with image_spdx_path.open("wb") as f:
> --
> 2.35.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#192536): https://lists.openembedded.org/g/openembedded-core/message/192536
> Mute This Topic: https://lists.openembedded.org/mt/103194653/3616693
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexandre Belloni Dec. 16, 2023, 10:18 p.m. UTC | #2
Hello,

Most of the builds failed do_rootfs with:

ERROR: core-image-sato-1.0-r0 do_rootfs: Error executing a python function in exec_func_python() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:image_combine_spdx(d)
     0003:
File: '/home/pokybuild/yocto-worker/qemuarm64-ltp/build/meta/classes/create-spdx-2.2.bbclass', lineno: 964, function: image_combine_spdx
     0960:    imgdeploydir = Path(d.getVar("IMGDEPLOYDIR"))
     0961:    img_spdxid = oe.sbom.get_image_spdxid(image_name)
     0962:    packages = image_list_installed_packages(d)
     0963:
 *** 0964:    combine_spdx(d, image_name, imgdeploydir, img_spdxid, packages, Path(d.getVar("SPDXIMAGEWORK")))
     0965:
     0966:    def make_image_link(target_path, suffix):
     0967:        if image_link_name:
     0968:            link = imgdeploydir / (image_link_name + suffix)
File: '/home/pokybuild/yocto-worker/qemuarm64-ltp/build/meta/classes/create-spdx-2.2.bbclass', lineno: 1078, function: combine_spdx
     1074:            "OTHER",
     1075:            "%s:%s" % (runtime_ref.externalDocumentId, runtime_doc.SPDXID),
     1076:            comment="Runtime dependencies for %s" % name
     1077:        )
 *** 1078:    bb.utils.mkdirhier(spdx_workdir)
     1079:    image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
     1080:
     1081:    with image_spdx_path.open("wb") as f:
     1082:        doc.to_json(f, sort_keys=True, indent=get_json_indent(d))
File: '/home/pokybuild/yocto-worker/qemuarm64-ltp/build/bitbake/lib/bb/utils.py', lineno: 764, function: mkdirhier
     0760:def mkdirhier(directory):
     0761:    """Create a directory like 'mkdir -p', but does not complain if
     0762:    directory already exists like os.makedirs
     0763:    """
 *** 0764:    if directory.find('${') != -1:
     0765:        bb.fatal("Directory name {} contains unexpanded bitbake variable. This may cause build failures and WORKDIR polution.".format(directory))
     0766:    try:
     0767:        os.makedirs(directory)
     0768:    except OSError as e:
Exception: AttributeError: 'PosixPath' object has no attribute 'find'

On 15/12/2023 09:10:46-0800, Jeremy Puhlman via lists.openembedded.org wrote:
> From: "Jeremy A. Puhlman" <jpuhlman@mvista.com>
> 
> On occasion a file is attmpeded to be opened prior to the
> creation of the spdx_workdir. Create the directory before
> the open, just in case.
> 
> File: '/build/layers/poky/meta/classes/create-spdx-2.2.bbclass', lineno: 1081, function: combine_spdx
>      1077:        )
>      1078:
>      1079:    image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
>      1080:
>  *** 1081:    with image_spdx_path.open("wb") as f:
>      1082:        doc.to_json(f, sort_keys=True, indent=get_json_indent(d))
> 
> Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com>
> ---
>  meta/classes/create-spdx-2.2.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
> index b0aef80db1..486efadba9 100644
> --- a/meta/classes/create-spdx-2.2.bbclass
> +++ b/meta/classes/create-spdx-2.2.bbclass
> @@ -1075,7 +1075,7 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx
>              "%s:%s" % (runtime_ref.externalDocumentId, runtime_doc.SPDXID),
>              comment="Runtime dependencies for %s" % name
>          )
> -
> +    bb.utils.mkdirhier(spdx_workdir)
>      image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
>  
>      with image_spdx_path.open("wb") as f:
> -- 
> 2.35.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#192536): https://lists.openembedded.org/g/openembedded-core/message/192536
> Mute This Topic: https://lists.openembedded.org/mt/103194653/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index b0aef80db1..486efadba9 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -1075,7 +1075,7 @@  def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx
             "%s:%s" % (runtime_ref.externalDocumentId, runtime_doc.SPDXID),
             comment="Runtime dependencies for %s" % name
         )
-
+    bb.utils.mkdirhier(spdx_workdir)
     image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
 
     with image_spdx_path.open("wb") as f: