summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/create-spdx.bbclass13
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)