mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
42b2fb8651
commit
ba7f322a3e
@@ -67,6 +67,7 @@ def convert_license_to_spdx(lic, document, d, existing={}):
|
|||||||
extracted_info = oe.spdx.SPDXExtractedLicensingInfo()
|
extracted_info = oe.spdx.SPDXExtractedLicensingInfo()
|
||||||
extracted_info.name = name
|
extracted_info.name = name
|
||||||
extracted_info.licenseId = ident
|
extracted_info.licenseId = ident
|
||||||
|
extracted_info.extractedText = None
|
||||||
|
|
||||||
if name == "PD":
|
if name == "PD":
|
||||||
# Special-case this.
|
# 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:
|
with (Path(directory) / name).open(errors="replace") as f:
|
||||||
extracted_info.extractedText = f.read()
|
extracted_info.extractedText = f.read()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except FileNotFoundError:
|
||||||
# Error out, as the license was in available_licenses so
|
pass
|
||||||
# should be on disk somewhere.
|
if extracted_info.extractedText is None:
|
||||||
bb.error(f"Cannot find text for license {name}: {e}")
|
# 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:
|
else:
|
||||||
# If it's not SPDX, or PD, or in available licenses, then NO_GENERIC_LICENSE must be set
|
# 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)
|
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:
|
with open(filename, errors="replace") as f:
|
||||||
extracted_info.extractedText = f.read()
|
extracted_info.extractedText = f.read()
|
||||||
else:
|
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
|
extracted[name] = extracted_info
|
||||||
document.hasExtractedLicensingInfos.append(extracted_info)
|
document.hasExtractedLicensingInfos.append(extracted_info)
|
||||||
|
|||||||
Reference in New Issue
Block a user