Skip to content

Commit 8e7ee19

Browse files
OsterlaDrossburton
authored andcommitted
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. 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>
1 parent 2513c75 commit 8e7ee19

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

meta/classes/create-spdx-2.2.bbclass

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,17 @@ def convert_license_to_spdx(lic, license_data, document, d, existing={}):
7575
pass
7676
if extracted_info.extractedText is None:
7777
# If it's not SPDX or PD, then NO_GENERIC_LICENSE must be set
78-
filename = d.getVarFlag('NO_GENERIC_LICENSE', name)
78+
entry = d.getVarFlag('NO_GENERIC_LICENSE', name).split(';')
79+
filename = entry[0]
80+
params = {i.split('=')[0]: i.split('=')[1] for i in entry[1:] if '=' in i}
81+
beginline = int(params.get('beginline', 1))
82+
endline = params.get('endline', None)
83+
if endline:
84+
endline = int(endline)
7985
if filename:
8086
filename = d.expand("${S}/" + filename)
8187
with open(filename, errors="replace") as f:
82-
extracted_info.extractedText = f.read()
88+
extracted_info.extractedText = "".join(line for idx, line in enumerate(f, 1) if beginline <= idx and idx <= (endline or idx))
8389
else:
8490
bb.fatal("Cannot find any text for license %s" % name)
8591

0 commit comments

Comments
 (0)