1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-09 05:29:32 +00:00

create-spdx: support line numbers

LIC_FILES_CHKSUM supports begin-/endline for licenses included in
for instance header files. This patch adds support for line numbers
to NO_GENERIC_LICENSE, too.

(From OE-Core rev: 8e7ee19fc9e74cf042880f4bc317782482ba6f66)

Signed-off-by: Denis Osterland-Heim <denis.osterland@diehl.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Ross Burton <ross.burton@arm.com>
This commit is contained in:
Denis OSTERLAND-HEIM
2025-01-20 13:04:58 +00:00
committed by Ross Burton
parent 9e54ce7eac
commit f0c5b10901
+8 -2
View File
@@ -75,11 +75,17 @@ def convert_license_to_spdx(lic, license_data, document, d, existing={}):
pass
if extracted_info.extractedText is None:
# If it's not SPDX or PD, then NO_GENERIC_LICENSE must be set
filename = d.getVarFlag('NO_GENERIC_LICENSE', name)
entry = d.getVarFlag('NO_GENERIC_LICENSE', name).split(';')
filename = entry[0]
params = {i.split('=')[0]: i.split('=')[1] for i in entry[1:] if '=' in i}
beginline = int(params.get('beginline', 1))
endline = params.get('endline', None)
if endline:
endline = int(endline)
if filename:
filename = d.expand("${S}/" + filename)
with open(filename, errors="replace") as f:
extracted_info.extractedText = f.read()
extracted_info.extractedText = "".join(line for idx, line in enumerate(f, 1) if beginline <= idx and idx <= (endline or idx))
else:
bb.fatal("Cannot find any text for license %s" % name)