diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2021-09-14 20:11:15 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-16 09:50:34 +0100 |
commit | ba7f322a3e9dc2cd3a33bacb865c0e85010734af (patch) | |
tree | 059945f112f8a72c86c9c679c12af1ab6b9f25f9 /meta/classes | |
parent | 42b2fb8651f8e9cac3292dc8bdef8488eaf9283d (diff) | |
download | poky-ba7f322a3e9dc2cd3a33bacb865c0e85010734af.tar.gz |
create-spdx.bbclass: Search all license directories for licenses
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.
(From OE-Core rev: f58d54b31a1ddb4e60eb07365bfb7dfe78ed56af)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/create-spdx.bbclass | 13 |
1 files 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={}): | |||
67 | extracted_info = oe.spdx.SPDXExtractedLicensingInfo() | 67 | extracted_info = oe.spdx.SPDXExtractedLicensingInfo() |
68 | extracted_info.name = name | 68 | extracted_info.name = name |
69 | extracted_info.licenseId = ident | 69 | extracted_info.licenseId = ident |
70 | extracted_info.extractedText = None | ||
70 | 71 | ||
71 | if name == "PD": | 72 | if name == "PD": |
72 | # Special-case this. | 73 | # Special-case this. |
@@ -78,10 +79,12 @@ def convert_license_to_spdx(lic, document, d, existing={}): | |||
78 | with (Path(directory) / name).open(errors="replace") as f: | 79 | with (Path(directory) / name).open(errors="replace") as f: |
79 | extracted_info.extractedText = f.read() | 80 | extracted_info.extractedText = f.read() |
80 | break | 81 | break |
81 | except Exception as e: | 82 | except FileNotFoundError: |
82 | # Error out, as the license was in available_licenses so | 83 | pass |
83 | # should be on disk somewhere. | 84 | if extracted_info.extractedText is None: |
84 | bb.error(f"Cannot find text for license {name}: {e}") | 85 | # Error out, as the license was in available_licenses so should |
86 | # be on disk somewhere. | ||
87 | bb.error("Cannot find text for license %s" % name) | ||
85 | else: | 88 | else: |
86 | # If it's not SPDX, or PD, or in available licenses, then NO_GENERIC_LICENSE must be set | 89 | # If it's not SPDX, or PD, or in available licenses, then NO_GENERIC_LICENSE must be set |
87 | filename = d.getVarFlag('NO_GENERIC_LICENSE', name) | 90 | filename = d.getVarFlag('NO_GENERIC_LICENSE', name) |
@@ -90,7 +93,7 @@ def convert_license_to_spdx(lic, document, d, existing={}): | |||
90 | with open(filename, errors="replace") as f: | 93 | with open(filename, errors="replace") as f: |
91 | extracted_info.extractedText = f.read() | 94 | extracted_info.extractedText = f.read() |
92 | else: | 95 | else: |
93 | bb.error(f"Cannot find any text for license {name}") | 96 | bb.error("Cannot find any text for license %s" % name) |
94 | 97 | ||
95 | extracted[name] = extracted_info | 98 | extracted[name] = extracted_info |
96 | document.hasExtractedLicensingInfos.append(extracted_info) | 99 | document.hasExtractedLicensingInfos.append(extracted_info) |