From: Denis OSTERLAND-HEIM <denis.osterland@diehl.com>
To: "openembedded-core@lists.openembedded.org"
<openembedded-core@lists.openembedded.org>
Subject: [PATCH] create-spdx: support line numbers
Date: Thu, 16 Jan 2025 08:13:45 +0100 (CET) [thread overview]
Message-ID: <b50eb75f524c4bc8bf3dd1763dbfd24d@diehl.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1747 bytes --]
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>
---
meta/classes/create-spdx-2.2.bbclass | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index 27242ecf70..494bde117f 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -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)
--
2.45.2
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3908 bytes --]
next reply other threads:[~2025-01-16 7:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 7:13 Denis OSTERLAND-HEIM [this message]
2025-01-16 7:32 ` Patchtest results for [PATCH] create-spdx: support line numbers patchtest
-- strict thread matches above, loose matches on Subject: below --
2025-01-20 13:04 Denis OSTERLAND-HEIM
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b50eb75f524c4bc8bf3dd1763dbfd24d@diehl.com \
--to=denis.osterland@diehl.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox