diff mbox series

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

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

Commit Message

Jeremy Puhlman Dec. 18, 2023, 5:57 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))

Add stringify of value passed as spdx_workdir

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

Richard Purdie Dec. 19, 2023, 3:21 p.m. UTC | #1
On Mon, 2023-12-18 at 09:57 -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))
> 
> Add stringify of value passed as spdx_workdir
> 
> 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..47c2366c7a 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(str(spdx_workdir))
>      image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
>  
>      with image_spdx_path.open("wb") as f:

FWIW I put a str() call onto the bitbake side of this in case we run
into this anywhere else.

Cheers,

Richard
Jeremy Puhlman Dec. 19, 2023, 6:36 p.m. UTC | #2
> FWIW I put a str() call onto the bitbake side of this in case we run
> into this anywhere else.
>
> Cheers,
>
> Richard

Sounds good. Thanks.
diff mbox series

Patch

diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index b0aef80db1..47c2366c7a 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(str(spdx_workdir))
     image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
 
     with image_spdx_path.open("wb") as f: