From patchwork Mon Dec 13 15:05:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 912 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 C0F6CC433F5 for ; Mon, 13 Dec 2021 15:06:16 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.88]) by mx.groups.io with SMTP id smtpd.web08.12074.1639407970721331560 for ; Mon, 13 Dec 2021 07:06:15 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@weidmueller.onmicrosoft.com header.s=selector1-weidmueller-onmicrosoft-com header.b=LaxHbNg4; spf=pass (domain: weidmueller.com, ip: 40.107.14.88, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RnMMBBK5ZE63L+TvYNWi8FV90vLBfwAvxIQcTPqecP5gByKpdz1DChacwo4c6kvw2eK4RPAKawQku5DJ1PqB6WRIx1z+1Nre6OgKTjQNvXWTTgyTD7HHBYGHn7qvcTbqXDbqw8P7oMOAMdF6+x+nZwPmYdAN1nul/oXq/24lQDBxPSpEYyMo8y/H2QZHIPavVZMfr2CO7sRAch1U6/T67A6+MM8t+M3W24aIgB5C91zTAtvgmzzrgirXiO4AoRuoTuhsfOqoC2yDYq8HMVwtGD63vwXVb6vuBcJDwz+zcSQ1hXSYgcLaTi9a0x1sstSd8bL9YBJ1KjZ8gSQXVS8vJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xnZfylpRZ+c/xpG/FVuWL9yWggDhgKhXc9ryGeUk+ZM=; b=l9l3OWzbjvwX7wijwr3XP9MpXQDMGgy/75Y4f4a2zeAxZylB09cDyPCL3aTUPcElmTlejTO0K+g1QLBE+4UFV1+huYnKMw31ssCDCBtgelDjP5gTyQJIoKzbYxP3kvLa6gyucxrULviz6uB1caj976U9Z5wc8G8Fj16bWL8z+RuBdKdTVhCI+26tZRGmuZfrIuHM5/zUT6DqXKSqTqqqidnqxtqTRm4anYgy+4+Gu3gadE9npBAoGqepaM04GhKZF4exqMVgy2h2IkAGAQuFY3r+x1Bg7jxvqJBf487LcyFzW7ZjD6gsTGzB+ZMmu56e167t0N+YrJFRXlFaSsB2Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xnZfylpRZ+c/xpG/FVuWL9yWggDhgKhXc9ryGeUk+ZM=; b=LaxHbNg4KUJf3Oa0MuGWw9POLn+pb7cLt2T6gclwv2gu281X9SgoW2tjIE+xFlwyH6vS48XF05o1n1pU4eLJ9gnwUbde2wCGRTjTyAypL5lV49R3nkh0KrSCuuVdE0+LvzKJ3B9U/cWqt4QKcUB1tDmt4u8RZOVt+5Jz/KqAzgM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by PA4PR08MB6317.eurprd08.prod.outlook.com (2603:10a6:102:ec::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.17; Mon, 13 Dec 2021 15:06:07 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f:41c4:eb10:5010]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f:41c4:eb10:5010%8]) with mapi id 15.20.4734.032; Mon, 13 Dec 2021 15:06:07 +0000 From: Stefan Herbrechtsmeier To: openembedded-core@lists.openembedded.org CC: Stefan Herbrechtsmeier Subject: [RFC PATCH v2 1/3] recipetool: Separate licenses with & operator Date: Mon, 13 Dec 2021 16:05:44 +0100 Message-ID: <20211213150546.22196-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: AM6P192CA0059.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::36) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 Received: from DE10512.weidmueller.com (89.247.126.92) by AM6P192CA0059.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::36) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Mon, 13 Dec 2021 15:06:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9994aef2-4e03-4f34-f2c7-08d9be4a16e4 X-MS-TrafficTypeDiagnostic: PA4PR08MB6317:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WsagQVgpAmDyhPeEiISI6UdEqd7ipqZS0EeCjRm02CJDbf5FVuW0Jyw+kdjkNOciBitckfkPj6XZ5+IQnvcK049LZVO3QvqceuG+LMMZAY1q6wSaqVdfNx1nOWPv0gi04uq41OvpX14WS+MRchkFzBatZpn1jHgpVEnoITKek/loN7NJd4vI7MAZEMfWAFci9MUusmnQQHvdjn8t8RL7t+xd2SG4GmYW132H1SmPtKn44aaVfiv/i4YxFc+u9vbZHIaw8hlH3lJJtMThqu/tSL9d9L7UkfiUFf6kYzPiSWLx6AMqtQ40SQj3Lq5QV/bQOvAKBH5z4di8EmSvLFTEQ4/9bJGN3oLxxPcksxQ7EPU1bj4QRxuS3XQX9z1AeRvJLldzxKoCDwHR6hD7uMHsWMz93kMM3do+SLXv1YPGdGcmhEoy07JMxgNjDTnTLiAeb/3B0ncHvaTvIgO2I4sue1Uyq9ygY8VxNbVVokN7IHye5t/kryY3/RgAsD9dG72eUxlr4Yae3FjuSzOzaJavJFSTe91fd3GARFzmHmRRKsaBgWl9VDHz2RtR0n385gimQHVqLo+5GK2h3nHZEPodQu6LLys6+u4Fpzxoicusena7tFOAyB5WzhnYzHpoczuu7tTf1kATArYXbvCF7b0h6VvVqZeNyn4ZhDyF13KJf7Ve6iKDhxZD0yZwgST8H4vxQr98xW2oW9Q/YcoPeojFy2/qh6eCDumrqF+n03gSriUvwvyrRW8Oj4EawMFh25uzMxie6dR46NsBCaPRs6iIhg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(4326008)(316002)(7696005)(6916009)(36756003)(52116002)(66946007)(6666004)(2906002)(1076003)(66476007)(66556008)(8676002)(5660300002)(107886003)(508600001)(38350700002)(86362001)(26005)(8936002)(186003)(6486002)(38100700002)(956004)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zwEtOvhhqbdiTlSxjBbs5XyRjzaU5aWm58AY8kf53MFVQquw7hxxKqo62mpyxl5BBP+bXfbt1l4Bnvotp0iBppRoF1E7W3PJUo5ScLN37zmL63rLKAeqT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pMWCT7kBMS2O3Tcz6G5Zr4Y3SVOQLNEEplqQtK2UsVZnvwc4vgILVzWsTSYCNMdMYt03HhMoiPTrn7kj0exA+GRZJH3CpQlzLiok0cFz5SttaFUoZ0TqhcY4GnwMHa/Ihgs0kuTRjM79HoyEpeFdYOfhF10vOyuuSzWms0KpgSrYx/REjRCtiKm8W9wreoFZW96VkcsIZS0/3Rf0/2E3KGJLlBYROvr1JBNJpYSRaZkp8741FoGemW6atQpxUt5LsGtvA9Sjf16LsDi4GeFLd+NSl9Nwb5R6CSsMU+QzZI29DmR3qQnfS6ngqGRql/4wpfi0Z98AQjceVUQXUIc3x2tL3Dj6T/cGPMPWDTQ6+PiUPGlLC7QGk68nwSZZjNVh/1ULJI43+c1bieSdPhIQvBflbQViA5ifv4DjgjmNN4x22OYr+JNrhZHtmUXyqGeO1pk= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9994aef2-4e03-4f34-f2c7-08d9be4a16e4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:06:07.2926 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GivDArtNSfhA+5kVz5rp29OyqBMYRp+Rcl0VZyZ3CmaREX/6e3ABGE6EQ5pvOPGNx3mPWABQCw9GPVKu/Uwg3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6317 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 ; Mon, 13 Dec 2021 15:06:16 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159641 From: Stefan Herbrechtsmeier Separate licenses with & operator since it should be satisfied most use cases and it is a reasonable assumption that all the licenses apply. Furthermore flat, split and sort the licenses to minimize license string changes. Separate package licenses with & operator: -LICENSE:${PN} = "MIT ISC" +LICENSE:${PN} = "ISC & MIT" Respect | and brackets in LICENSE: -LICENSE = "BSD-3-Clause & (ISC & | & MIT)" +LICENSE = "BSD-3-Clause & (ISC | MIT)" Sort licenses: -LICENSE = "MIT & BSD-3-Clause & ISC" +LICENSE = "BSD-3-Clause & ISC & MIT" Remove duplicates: -LICENSE = "MIT & ISC & MIT" +LICENSE = "ISC & MIT" Signed-off-by: Stefan Herbrechtsmeier --- (no changes since v1) meta/lib/oeqa/selftest/cases/recipetool.py | 4 +-- scripts/lib/recipetool/create.py | 39 +++++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index 439e41597c..95e4753976 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py @@ -426,7 +426,7 @@ class RecipetoolCreateTests(RecipetoolBase): checkvars = {} checkvars['SUMMARY'] = 'Node Server Example' checkvars['HOMEPAGE'] = 'https://github.com/savoirfairelinux/node-server-example#readme' - checkvars['LICENSE'] = set(['MIT', 'ISC', 'Unknown']) + checkvars['LICENSE'] = 'BSD-3-Clause & ISC & MIT & Unknown' urls = [] urls.append('npm://registry.npmjs.org/;package=@savoirfairelinux/node-server-example;version=${PV}') urls.append('npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json') @@ -483,7 +483,7 @@ class RecipetoolCreateTests(RecipetoolBase): result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) self.assertTrue(os.path.isfile(recipefile)) checkvars = {} - checkvars['LICENSE'] = set(['PSF', '&', 'BSD-3-Clause', 'GPL']) + checkvars['LICENSE'] = 'BSD-3-Clause & GPL & PSF' checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6' checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz' checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de' diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 406c97f1c5..8e8a621b4f 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py @@ -919,6 +919,22 @@ def split_value(value): else: return value +def fixup_license(value): + # Ensure licenses with OR starts and ends with brackets + if '|' in value: + return '(' + value + ')' + return value + +def tidy_licenses(value): + """Flat, split and sort licenses""" + from oe.license import flattened_licenses + def _choose(a, b): + str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold) + return ["(%s | %s)" % (str_a, str_b)] + if not isinstance(value, str): + value = " & ".join(value) + return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold) + def handle_license_vars(srctree, lines_before, handled, extravalues, d): lichandled = [x for x in handled if x[0] == 'license'] if lichandled: @@ -932,10 +948,13 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d): lines = [] if licvalues: for licvalue in licvalues: - if not licvalue[0] in licenses: - licenses.append(licvalue[0]) + license = licvalue[0] + lics = tidy_licenses(fixup_license(license)) + lics = [lic for lic in lics if lic not in licenses] + if len(lics): + licenses.extend(lics) lic_files_chksum.append('file://%s;md5=%s' % (licvalue[1], licvalue[2])) - if licvalue[0] == 'Unknown': + if license == 'Unknown': lic_unknown.append(licvalue[1]) if lic_unknown: lines.append('#') @@ -944,9 +963,7 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d): for licfile in lic_unknown: lines.append('# %s' % licfile) - extra_license = split_value(extravalues.pop('LICENSE', [])) - if '&' in extra_license: - extra_license.remove('&') + extra_license = tidy_licenses(extravalues.pop('LICENSE', '')) if extra_license: if licenses == ['Unknown']: licenses = extra_license @@ -987,7 +1004,7 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d): lines.append('# instead of &. If there is any doubt, check the accompanying documentation') lines.append('# to determine which situation is applicable.') - lines.append('LICENSE = "%s"' % ' & '.join(licenses)) + lines.append('LICENSE = "%s"' % ' & '.join(sorted(licenses, key=str.casefold))) lines.append('LIC_FILES_CHKSUM = "%s"' % ' \\\n '.join(lic_files_chksum)) lines.append('') @@ -1226,6 +1243,7 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=[], pn=' """ pkglicenses = {pn: []} for license, licpath, _ in licvalues: + license = fixup_license(license) for pkgname, pkgpath in packages.items(): if licpath.startswith(pkgpath + '/'): if pkgname in pkglicenses: @@ -1238,11 +1256,14 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=[], pn=' pkglicenses[pn].append(license) outlicenses = {} for pkgname in packages: - license = ' '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown' + # Assume AND operator between license files + license = ' & '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown' if license == 'Unknown' and pkgname in fallback_licenses: license = fallback_licenses[pkgname] + licenses = tidy_licenses(license) + license = ' & '.join(licenses) outlines.append('LICENSE:%s = "%s"' % (pkgname, license)) - outlicenses[pkgname] = license.split() + outlicenses[pkgname] = licenses return outlicenses def read_pkgconfig_provides(d):