Openembedded Core Discussions
 help / color / mirror / Atom feed
From: "Peter Kjellerstedt" <peter.kjellerstedt@axis.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH] create-spdx.bbclass: Search all license directories for licenses
Date: Tue, 14 Sep 2021 20:11:15 +0200	[thread overview]
Message-ID: <20210914181115.28873-1-pkj@axis.com> (raw)

Before, even if the code was seemingly written to search through all
licenses in ${COMMON_LICENSE_DIR} and ${LICENSE_PATH}, it would
actually bail out after only searching ${COMMON_LICENSE_DIR} due to
the exception handling.

Also refrain from using f-strings.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 meta/classes/create-spdx.bbclass | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass
index db85677d4c..3c73c21c04 100644
--- a/meta/classes/create-spdx.bbclass
+++ b/meta/classes/create-spdx.bbclass
@@ -67,6 +67,7 @@ def convert_license_to_spdx(lic, document, d, existing={}):
         extracted_info = oe.spdx.SPDXExtractedLicensingInfo()
         extracted_info.name = name
         extracted_info.licenseId = ident
+        extracted_info.extractedText = None
 
         if name == "PD":
             # Special-case this.
@@ -78,10 +79,12 @@ def convert_license_to_spdx(lic, document, d, existing={}):
                     with (Path(directory) / name).open(errors="replace") as f:
                         extracted_info.extractedText = f.read()
                         break
-                except Exception as e:
-                    # Error out, as the license was in available_licenses so
-                    # should be on disk somewhere.
-                    bb.error(f"Cannot find text for license {name}: {e}")
+                except FileNotFoundError:
+                    pass
+            if extracted_info.extractedText is None:
+                # Error out, as the license was in available_licenses so should
+                # be on disk somewhere.
+                bb.error("Cannot find text for license %s" % name)
         else:
             # If it's not SPDX, or PD, or in available licenses, then NO_GENERIC_LICENSE must be set
             filename = d.getVarFlag('NO_GENERIC_LICENSE', name)
@@ -90,7 +93,7 @@ def convert_license_to_spdx(lic, document, d, existing={}):
                 with open(filename, errors="replace") as f:
                     extracted_info.extractedText = f.read()
             else:
-                bb.error(f"Cannot find any text for license {name}")
+                bb.error("Cannot find any text for license %s" % name)
 
         extracted[name] = extracted_info
         document.hasExtractedLicensingInfos.append(extracted_info)

             reply	other threads:[~2021-09-14 18:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 18:11 Peter Kjellerstedt [this message]
2021-09-14 18:24 ` [OE-core] [PATCH] create-spdx.bbclass: Search all license directories for licenses Konrad Weihmann
2021-09-15 12:49   ` Peter Kjellerstedt
2021-09-15 18:45 ` Joshua Watt

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=20210914181115.28873-1-pkj@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --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