From patchwork Thu Jan 16 07:13:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis OSTERLAND-HEIM X-Patchwork-Id: 55652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF188E77188 for ; Thu, 16 Jan 2025 07:13:58 +0000 (UTC) Received: from enterprise02.smtp.diehl.com (enterprise02.smtp.diehl.com [193.201.238.220]) by mx.groups.io with SMTP id smtpd.web10.43196.1737011628917266644 for ; Wed, 15 Jan 2025 23:13:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@diehl.com header.s=default header.b=We/muu3K; spf=pass (domain: diehl.com, ip: 193.201.238.220, mailfrom: prvs=104ee42bf=denis.osterland@diehl.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=diehl.com; i=@diehl.com; q=dns/txt; s=default; t=1737011629; x=1768547629; h=from:to:subject:date:message-id:mime-version; bh=IbBGWfX5oq1YJVdiPhrGaHq4E21BU5quqdWDE2no170=; b=We/muu3Kv7u/wd0mzAIP8rU4QLV7aJI3Vw7Y0e1hsibpDmiDAXH397BB qfE7aCidY7OhS6fxYUMaX6ymqYdq0SatXVct5kjd35PpI+f7OgjEPgjyC T8c77Aj+xOejMKcYS4s3NGgHGG6LjGCM1X5cZ1iTWvMArYbvHN1RC90iW TDfYeP9dntlb7m0UN+xOuTm2xrzHzxUaqTB2zPFczep/srSL7Mi73iz0K doDfmESlCzVI6aejgY6Q7E50sf2hmZWwzu39AWHj2xjKeDNkXsnUsphYl CUr4C8U93P4FmBDZriaWme8erluD1D5NDmFdwjjQUd9dYi+azs0CtLN2k g==; X-CSE-ConnectionGUID: n/6ET6vLQaOACtsYjisOSw== X-CSE-MsgGUID: 3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2ayITZOmK0ZaVYK1GBO7VRAKSs5V+9H 8xkH8ySxhNSVefzbiXa/csYKkoHBXw6Hozt7ctPe+iOJwBrFG0sB7nW27xJRmB+t/0N0LeSu CjtHBYDkjITmEH6FOlDUVg7AJuHYHq1hStT0fAEVbpw50UeXA== IronPort-HdrOrdr: A9a23:gnCn+6i80V0kkE+3NJ+Mirl/8HBQXvYji2hC6mlwRA09TyX+rb HIoB17726RtN91YhsdcL+7V5VoLUmzyXZaibNhRYtKdjOWw1dAVbsSi7cKmgeQYhEWlNQttp uIApIObeEYZGIS5arHCW+DcurIqOPtzEnCv5a9854Cd2FXgu5bnn1E41agf3FLeA== X-Talos-CUID: 9a23:nGropGusi8R7VbQSbSoKfX9x6IsjNSPw8CnOB3axLk9CVKakS16L35h7xp8= X-Talos-MUID: 9a23:W9bUrwZZeF8Yz+BT7ATsjg44OJdR3r2QTx4RsLkU5tKOOnkl X-IronPort-AV: E=Sophos;i="6.13,208,1732575600"; d="p7s'346?scan'346,208,346";a="103913833" From: Denis OSTERLAND-HEIM To: "openembedded-core@lists.openembedded.org" Subject: [PATCH] create-spdx: support line numbers Date: Thu, 16 Jan 2025 08:13:45 +0100 (CET) Message-ID: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 16 Jan 2025 07:13:58 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/209935 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 --- 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)