From patchwork Tue Sep 2 14:06:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lindeberg X-Patchwork-Id: 69428 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 B3BE1CA1005 for ; Tue, 2 Sep 2025 14:07:08 +0000 (UTC) Received: from AM0PR83CU005.outbound.protection.outlook.com (AM0PR83CU005.outbound.protection.outlook.com [52.101.69.66]) by mx.groups.io with SMTP id smtpd.web10.78371.1756822019986472079 for ; Tue, 02 Sep 2025 07:07:00 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@axis.com header.s=selector1 header.b=IYPA9MPs; spf=pass (domain: axis.com, ip: 52.101.69.66, mailfrom: christian.lindeberg@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZiMRVd8Z+FFVolWzr5BEaba7byDE2thOZuUbKRCHJG9MOSFhyMpYCMBuw3HIITlwwXJmj7QPxe15oj72Nx4IDwu/QxKpkHt7fSzSXbugTMt95EHAv7Bv8nkWVDTaX33wLchGQ7KCgt/K+baORCIbB2aZhSmVUnbaZtj0qZG5VXp3Soddi2u2D6HihMQQXViXEVtSjKKVYA4miyZgEgMZQUQpulX5BV2VQmMktKSnstwJAl6X8c9vU93jfqUVpZN0MZ6xoyWwilwo4TGsE8ihYiIiarncxhuEFPZCiW4hgw4+2dIxSteAobpdJCxGfLBNRlA0OVoAnl5ugBPBfuI/hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=YttSK1SF7yNSj9YH90jMBnZ1H1ikX5ny1P2kv9kIlMw=; b=tdb28WPrOs2Il2HDO3/Ws6uIoTKK9cNPYdaCyXY7PSP7oIOHVacAOIkrkGekl8Z1abcTUv0eYsVJtGFtkRcwKxRpK2dqw6aL18YbBFNt7xYSIxcJZWlDlsAiltSZ115DzhjJXTeHfQZS6lICzjQBypSJDUL8gBPK/uxM4cKy51Oh+/iWIKeuc1y8nqHvSeE7EAzK4vlujJ3vQNV48mvc1Kk2sHFe6HFzDjjBaIQDmz4Cb6SviHGrPF3BHHm2qQysZWsIEVzGViDNi3hBG1lS8glFaUo/KfoCkKAEIm62fwB0/15w2x/AANAoKnL21DQWvx/fsfpkyRZV1GuOMWIZuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=lists.openembedded.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YttSK1SF7yNSj9YH90jMBnZ1H1ikX5ny1P2kv9kIlMw=; b=IYPA9MPsIb1RnBbRTBj0lfOqkzq/a2UAfgtwRZDKBOaaObm++d2SksetBDD1hYmN9dQ6BNIe9mHm/Y2evupFqV19/FIaBrbCTcfeJNazcCuJuXPcofl0y/PGYzjFY1wTA/KlKMAEAA5lVWxanXQDhZGa5YlTy9p5V+gpVTRsiOo= Received: from AM0PR02CA0184.eurprd02.prod.outlook.com (2603:10a6:20b:28e::21) by AS2PR02MB8863.eurprd02.prod.outlook.com (2603:10a6:20b:556::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9094.17; Tue, 2 Sep 2025 14:06:52 +0000 Received: from AMS0EPF000001A6.eurprd05.prod.outlook.com (2603:10a6:20b:28e:cafe::e0) by AM0PR02CA0184.outlook.office365.com (2603:10a6:20b:28e::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9073.26 via Frontend Transport; Tue, 2 Sep 2025 14:06:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A6.mail.protection.outlook.com (10.167.16.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9073.11 via Frontend Transport; Tue, 2 Sep 2025 14:06:52 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Tue, 2 Sep 2025 16:06:47 +0200 Received: from se-intmail01x.se.axis.com (10.4.0.28) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Tue, 2 Sep 2025 16:06:47 +0200 Received: from pc50740-2234.se.axis.com (pc50740-2234.se.axis.com [10.94.131.4]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id A72F3EE9 for ; Tue, 2 Sep 2025 16:06:47 +0200 (CEST) Received: by pc50740-2234.se.axis.com (Postfix, from userid 21184) id A066D2426D0B; Tue, 2 Sep 2025 16:06:47 +0200 (CEST) From: Christian Lindeberg To: Subject: [PATCH 1/3] oe/license_finder: Add find_licenses_up function Date: Tue, 2 Sep 2025 16:06:45 +0200 Message-ID: <20250902140647.126140-2-christli@axis.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250902140647.126140-1-christli@axis.com> References: <20250902140647.126140-1-christli@axis.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A6:EE_|AS2PR02MB8863:EE_ X-MS-Office365-Filtering-Correlation-Id: 30b0fe55-ba03-4a87-d78d-08ddea29f78b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: aQz/cJUy4IqY+OmHBmHUsl+n3Iy7PAJzb4SlIn+rqGbQkPqikvhPbxqEB0hLvMHlQsq9FJLH0uIr8Fpcv1pWwVxqIYATNb2Gop3QoUNF8Ki06bDdqKrzOmP7QEVULUyGVhY4Aai+m+Ok/wbfJzkUJ7P8JBhBMHs+SuG3NL5SxQCdkytShLUqX05hjF4l30fz+0Ts1UpC1Wc771K9EP2sL4tFd+gSGP+OBWR8WiBOd4EHBohpFNu+QL/AL54kg7zbLA6epks1ow0SjcIYtBIAkHU9lsV6AYB8nIZT4a0qe6HEN8G8aD23k3B6bPGjbnKD++j9MS0MKd4uek/oKyxSZ3OIurXf222lBNPwYOifxeerc88s3tyU0ZYCyPC94j1Cs9MxR57WCKuVZZmb0ELwFq5jecx79nzZ87BGJwZ2Wam35vtILUYxeb7ZZLy6L/zr00F8AM6bhqTTQ01XSrmr9zKmt+ZWN4YepivRtCYmkH8FUpE053lxPEqzksKXokO0JAMLx9IuIPIA3wSg6jnCH7sBkxp2jcIiWmeqQLB2FNcT1LnBT1a9PjEAERYb37DAIdyMMIxkqEfNVP3D2LUvdODWxOVNfC55lq0K8C03Iqxev6mTPJLUCQFjfIRoZI/wDYc2feG5IE3B7sR9EEsdLe5Q5+lxEAqeWtGpBcdF5GkvfScf9S2xZLSl3xdduwU9F9bxROrNOaGswBlPUJEDU2l/o9u7ihUcKlxskBggMlo08kevFEMeDpFtgQXEfLDGZkcxqI1yNFpTvvpk1c31sqSCX2FttVMPxaW02DBcuubM6X2HxxLATX6WkaCQOoJZp21hvhOvSLL49IlOtslPS+ltpu5Fq91uvxNZVS6nBtiuHp/nl68Jw2K47wY0PSiXUYWf6vN7sU5c0a+Bcfgpb51dsLpcHN2xQvnYijf6s/k5KmW2scjf+Au0HWmzI/DyV+9mJZSJr0Nbq8UpecGyFOQAd6JIBsSEvgElf6la9F8FK363NjhMmUNvVyJwW4rUOCB5K5yIDDYuhdZxftsbs+y9ftX074gPxWPrYtlI/48lczWxeEJgNwtVs2xt2/Q+u3hmf7JXz2Cooq5adhifHI1t64Y7cJd6B+MPuCS0kg+O1KCqHCDQPY2RgsmppFmpHZoA9HGFviHdkXy62qqcXGlcGbgFV0hXfTDdIesvLO7SqjdO674tPcuM9mYf3BX6UXTxgllcT1g3NjtlOwvH0DRDkjc/SmZ2c0ylBzOjafVnB9MmYplHYPNDnw4+vRVOKzp9LdKfgkCeaqM6SzHLCiaHnygudVfJDKIiT0Vq9KqeLtLANr1ktvo3fRpexU8828n8BkOB4oz/hnpPCGe8HzvTTcgM7AkJjC9TsJUOxNV7qQ7xlRP8Wwg/TOxmo76nkxJqD1wFp/tE72CDFKJ9qHIfjlIFXHGuTkdkMwkTDpOPVLmKkWv0wIX4ajE156TZFGP8I5Mqas9VEJB6ZZF/75/oDf7vqhUwag9zfbC6yc+njiQfNyFKVrwqzvz5Yr6U X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2025 14:06:52.3756 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30b0fe55-ba03-4a87-d78d-08ddea29f78b X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A6.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR02MB8863 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 ; Tue, 02 Sep 2025 14:07:08 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222729 From: Christian Lindeberg Add a function for finding licenses in a directory or upwards but not above a top directory. Signed-off-by: Christian Lindeberg --- meta/lib/oe/license_finder.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/meta/lib/oe/license_finder.py b/meta/lib/oe/license_finder.py index 16f5d7c94c..4f2bb661fd 100644 --- a/meta/lib/oe/license_finder.py +++ b/meta/lib/oe/license_finder.py @@ -120,14 +120,34 @@ def _crunch_license(licfile): return md5val -def find_license_files(srctree, first_only=False): +def find_license_files(srctree, first_only=False, bottom=""): """ Search srctree for files that look like they could be licenses. If first_only is True, only return the first file found. + If bottom is not empty, start at bottom and continue upwards to the top. """ licspecs = ['*LICEN[CS]E*', 'COPYING*', '*[Ll]icense*', 'LEGAL*', '[Ll]egal*', '*GPL*', 'README.lic*', 'COPYRIGHT*', '[Cc]opyright*', 'e[dp]l-v10'] skip_extensions = (".html", ".js", ".json", ".svg", ".ts", ".go", ".sh") licfiles = [] + if bottom: + srcdir = bottom + while srcdir.startswith(srctree): + files = [] + with os.scandir(srcdir) as it: + for entry in it: + if entry.is_file(): + files.append(entry.name) + for name in sorted(files): + if name.endswith(skip_extensions): + continue + for spec in licspecs: + if fnmatch.fnmatch(name, spec): + licfiles.append(os.path.join(srcdir, name)) + if first_only: + return licfiles + srcdir = os.path.dirname(srcdir) + return licfiles + for root, dirs, files in os.walk(srctree): # Sort files so that LICENSE is before LICENSE.subcomponent, which is # meaningful if first_only is set. @@ -177,3 +197,8 @@ def find_licenses(srctree, d, first_only=False, extra_hashes={}): # FIXME should we grab at least one source file with a license header and add that too? return licenses + + +def find_licenses_up(srcdir, topdir, d, first_only=False, extra_hashes={}): + licfiles = find_license_files(topdir, first_only, srcdir) + return match_licenses(licfiles, topdir, d, extra_hashes) From patchwork Tue Sep 2 14:06:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lindeberg X-Patchwork-Id: 69427 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 D0278CA1009 for ; Tue, 2 Sep 2025 14:06:58 +0000 (UTC) Received: from PA4PR04CU001.outbound.protection.outlook.com (PA4PR04CU001.outbound.protection.outlook.com [40.107.162.25]) by mx.groups.io with SMTP id smtpd.web11.78254.1756822017251074820 for ; Tue, 02 Sep 2025 07:06:57 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@axis.com header.s=selector1 header.b=QDWuXYuA; spf=pass (domain: axis.com, ip: 40.107.162.25, mailfrom: christian.lindeberg@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TEeJbHc7xnoJBQeBGKrwSQ011++wEu/f5OhmC3SZP6ktZwOEs0ylb+LG+MLXAEo1zDXURcELsztLCCp6r3mWv2wdPRrdF+CfIxKY4Ci7Nv3WoayGzSsjTR08YN2JvvFSDm2zaJod24mP+E1zckY3Z0gcLbivwWAJ1/qnvRpQc9yiG1sl5AKvbYyXT7WjlVa0wwNCzgzd1SmrS8HJgQwFZ0mrFdnVTEAj/O87YgU+44zidJPe/VM1mAtDj3HaJbjpKTgmrBiRsRlW0gK78uH1GKIZJUQrH2IZj6F6/ByA2/i5URKG9XRvmejp+YXvu4anmrWWO1h4cMFuxsYg545u7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=oXATFyfgy525gxdO87j9U57Bo+qFdGzNHjXOMZ9FY6A=; b=Jv7XbEmuUUc+EDvMg5zpY6AuvvFbCHE9mL0giHTJ9iWfY3ntYiqxEFNzkcVmjfBhAcWKNkm+2cL/GDIdLc8jBCLFD9bcCm/xIqStVDE8NAEfQ/tUmyqfD8gakLHtuS5kFZWo9fJRI9Gzj3MBeU/0Op6KHeEKQOvxxD/EBfwnD/Cl72Gn7rHhqx8kKXT20xOFJtTClagXa8AQVzGoh2LitQOBIJakXyqKB0dJRE3cnVTV2W6kbDDU6CaEyu0Q59Xxlwqm3sSu78k/f8Fs2QzZqiWI7NneUdbt6rjf71s+5z1uvDTrYDwQ3ocxUlfmFc3S/4n88FFRforb4kWbDVQSSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=lists.openembedded.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oXATFyfgy525gxdO87j9U57Bo+qFdGzNHjXOMZ9FY6A=; b=QDWuXYuAwwNgRQ1K2g3YBoFRe5SHbEynfucKvbGHMgJmCQEjOccWfyDutC+j7B/keU2cuq31qDtsoFFo+IMbbsgjky83DqUsSAWFo6jsrP1wKQnGYnQQ+YtOQjVxuy4KoHrjCePbmpqollFRIBdkoyUU7jKo26lhcVSLThlo66k= Received: from AM0PR02CA0172.eurprd02.prod.outlook.com (2603:10a6:20b:28e::9) by PR3PR02MB6188.eurprd02.prod.outlook.com (2603:10a6:102:6f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9073.26; Tue, 2 Sep 2025 14:06:52 +0000 Received: from AMS0EPF000001A6.eurprd05.prod.outlook.com (2603:10a6:20b:28e:cafe::f9) by AM0PR02CA0172.outlook.office365.com (2603:10a6:20b:28e::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9073.27 via Frontend Transport; Tue, 2 Sep 2025 14:06:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A6.mail.protection.outlook.com (10.167.16.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9073.11 via Frontend Transport; Tue, 2 Sep 2025 14:06:51 +0000 Received: from se-mail02w.axis.com (10.20.40.8) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Tue, 2 Sep 2025 16:06:47 +0200 Received: from se-intmail01x.se.axis.com (10.4.0.28) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Tue, 2 Sep 2025 16:06:47 +0200 Received: from pc50740-2234.se.axis.com (pc50740-2234.se.axis.com [10.94.131.4]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id A8E70F74 for ; Tue, 2 Sep 2025 16:06:47 +0200 (CEST) Received: by pc50740-2234.se.axis.com (Postfix, from userid 21184) id A1E322426D0D; Tue, 2 Sep 2025 16:06:47 +0200 (CEST) From: Christian Lindeberg To: Subject: [PATCH 2/3] go-mod-update-modules.bbclass: Update license finding Date: Tue, 2 Sep 2025 16:06:46 +0200 Message-ID: <20250902140647.126140-3-christli@axis.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250902140647.126140-1-christli@axis.com> References: <20250902140647.126140-1-christli@axis.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A6:EE_|PR3PR02MB6188:EE_ X-MS-Office365-Filtering-Correlation-Id: b961cfdf-3cd4-4e19-e949-08ddea29f6f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: cFoSu2RxbktAPwim0o4LDwgkc/3OjqhIdiu6O5q5QQlGIa2JI6UWPB3CFRHxZqHy49t0+T2UhAX0VNGMoSwPiq/Z+d+bDHpMOjv5qDFPqToYJoaBi+zgC4k6MCfOkL2XVag/qVftiEnOUlXIJaXB/LAekj0T4j8Sempp7Ims0dYJaGK4HCjqs4vwtdRp22YkNC7Ze0iLB6BZnGLwnGj3K6+2n7cNfz1nCMbO4wX9KtPNcrdap4boqx45XcZFi5561EMfNHvZKgzI33nK/j8eGrnZyNGri7QHH9F30GorRSJ5Dcq9ZibXVjcapqVEzacVow62cwnsIBX1/uuRhEoIi5+xJAgm/JgHJC5OnysAjttnDshqTrF2U0jIwM4rofLfCwVYif8bNihGJEXDhHQhkukbVOE6OMKNNgfc43LVV9kgVQUo4UMP9MbFdBwg2d8a+Fjso0rd2PjvVAkN9EPL+SsFqbAWIPURQohx7ccfDzuGNAsmSmAMc8jJ/2OpqmmaWgHct4SX1Xoy7nwCb7qmengFICBgzDEpY0dkYmWJSDtrOMgG/tpjWc7nOubpIDTut+ny3iIFzF9ptykoGE0NRHQMe6Pec/gqLZLVE9B+7w22XX4dF8u9vRSvWjVbJTWJSJm3++kTirOEXkUnij9n7VsK4/NZg51hUpkGlDbHUh8ol0vacXkr+XkCMDrd2o6mZiy/j488L8jzuTuO2m20GCINT6iDmkIx+rwAxWE5aSTXslEXLymvfjROs5kHEqogDeL5S2QVpiZq91ZesiByKY+cJkcxCZ25YA9YYFa15zRfKlGQzX5wlbdkW43s8BDecmxDiLW2pUcvl0eSsOcuWEdJjdZ60UGgBjyIGmRpV7JePgS/Wdm4JBF0sTyBzjuysaRL8c44B16AyvRfAqPRCSrugZt45zqcVGhAF0VaymhgOncw0P+vsGJwb6/c9TShmP3EYAfe247Zfnp9SqNfpklTtifqQV2zGp8k1wGkteEuc3uXxOSiCpR4STkJEsgHdUSQvDP70W+ZRLGsn7qsfu2DPGoT85fi9nn21vXPVesGVcSg8Rt0L2ln48qpRmdWksWHshqbp0PRZNeTFhJUl5XIyfpdpQYznrbVc313ifn4krv58ThuwugzZLVpbadWuEDvdJYbTM5e3kGKVJDwUULyJKUqz8y3v/SXUdjf3c668b8ditvqJX4iOwj6w5JkwLHWKSnhbZ8dxUI5vAWxxxidY9NFX1GGwgPA3K8sb3EjGNytPNWo0tHkN1vsA3gR/NUtZSks6kuGgNSRG2++ed5c7al0m4iJmO518/k9ZRi4+68nb/XEC3BxlTCywksJWclS/l4+/yHU+CfPcAN7oDzmtX914Mh4lxoedLZZXYUyreqsXIYl3A8PAC7Mwt+cJ2U+wNDnJumJei6L5vEZFqaoN1NWp06/QiomK/GG1GWj18Oec8ebpQgLGM3UDxNvKS9oZOAvz0rE9klKVgiwbyMBv48TI8yGwdoKDjCU/BshYdq/oeuiw9nd64ofRuST X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2025 14:06:51.3932 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b961cfdf-3cd4-4e19-e949-08ddea29f6f5 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A6.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR02MB6188 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 ; Tue, 02 Sep 2025 14:06:58 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222728 From: Christian Lindeberg Use ${GO_INSTALL} when listing package dependencies. Look for licenses for each package dependency continuing upwards, but not above the module root, until some license is found. Signed-off-by: Christian Lindeberg --- .../go-mod-update-modules.bbclass | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/meta/classes-recipe/go-mod-update-modules.bbclass b/meta/classes-recipe/go-mod-update-modules.bbclass index 5fccd0bb0d..0083588a25 100644 --- a/meta/classes-recipe/go-mod-update-modules.bbclass +++ b/meta/classes-recipe/go-mod-update-modules.bbclass @@ -15,7 +15,7 @@ do_update_modules[network] = "1" python do_update_modules() { import subprocess, tempfile, json, re, urllib.parse from oe.license import tidy_licenses - from oe.license_finder import find_licenses + from oe.license_finder import find_licenses_up def unescape_path(path): """Unescape capital letters using exclamation points.""" @@ -47,12 +47,10 @@ python do_update_modules() { """ env = dict(os.environ, GOMODCACHE=mod_cache_dir) - source = d.expand("${UNPACKDIR}/${GO_SRCURI_DESTSUFFIX}") - output = subprocess.check_output(("go", "mod", "edit", "-json"), cwd=source, env=env, text=True) - go_mod = json.loads(output) - - output = subprocess.check_output(("go", "list", "-json=Dir,Module", "-deps", f"{go_mod['Module']['Path']}/..."), cwd=source, env=env, text=True) + go_install = d.getVar("GO_INSTALL").split() + output = subprocess.check_output(("go", "list", "-json=Dir,Module", "-deps", *go_install), + cwd=source, env=env, text=True) # # Licenses @@ -66,26 +64,22 @@ python do_update_modules() { # Very frustrating that the json parser in python can't repeatedly # parse from a stream. pkgs = json.loads('[' + output.replace('}\n{', '},\n{') + ']') + # Collect licenses for the dependencies. - licenses = set() - lic_files_chksum = [] lic_files = {} - for pkg in pkgs: - mod = pkg.get('Module', None) - if not mod or mod.get('Main', False): - continue - - mod_dir = mod['Dir'] - - if not mod_dir.startswith(mod_cache_dir): + pkg_dir = pkg['Dir'] + if not pkg_dir.startswith(mod_cache_dir): continue + mod_dir = pkg['Module']['Dir'] path = os.path.relpath(mod_dir, mod_cache_dir) - for license_name, license_file, license_md5 in find_licenses(mod['Dir'], d, first_only=True, extra_hashes=extra_hashes): - lic_files[os.path.join(path, license_file)] = (license_name, license_md5) + for name, file, md5 in find_licenses_up(pkg_dir, mod_dir, d, first_only=True, extra_hashes=extra_hashes): + lic_files[os.path.join(path, file)] = (name, md5) + licenses = set() + lic_files_chksum = [] for lic_file in lic_files: license_name, license_md5 = lic_files[lic_file] if license_name == "Unknown": From patchwork Tue Sep 2 14:06:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lindeberg X-Patchwork-Id: 69426 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 D0F9DCA100B for ; Tue, 2 Sep 2025 14:06:58 +0000 (UTC) Received: from DU2PR03CU002.outbound.protection.outlook.com (DU2PR03CU002.outbound.protection.outlook.com [52.101.65.42]) by mx.groups.io with SMTP id smtpd.web11.78253.1756822014666545738 for ; Tue, 02 Sep 2025 07:06:54 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@axis.com header.s=selector1 header.b=eFTzQFDG; spf=pass (domain: axis.com, ip: 52.101.65.42, mailfrom: christian.lindeberg@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hHt9ons8yVGCpPreLzjGYr+TOoDr7HJN7mTWm6CMm6Fe712VnQvFfAuLATKGhB3xSeNeBb6UyZH+8/WU4YhWcEBrvmihKqvP3YOiWRm1zktX5KcBX923XWtxou5As4CzMQzfq/6044jloeBau/G4bUlJ/5oXwy6cbRs5YLkgPxJP8GYAt0x9asMkn3CH+UvSz6y2gsSdJUgtXgyRnq07HzJtNOmNVUJw2JcB0+bvutidfyvr6YY/nZBauvz6rXDIo0xW720bsCuH8Qs3RWfN4UUUQi92uYdZwk/jimyLtp8br2WkI1tTWwg8zEPK6r3X46rc8w4tvfV5WKfFHiJjdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2Q4GGcK9ZQl7RNDMv0WW1h/yBqltxTHrUpYa5tKPcWs=; b=S0rkuLk5+GjEcZ3ZWokh4onvtMYkRQpfx0+7tkumlZ2lgauPovJWkJsRA2xrbWbfJ9HG2l5UVQZPqmwd7RYEYceW69WED6I4oOwTeta0Ej3tJiBzkfYe932ve5D9zPE8tTCPmbhtefnkOUuxL+G5W82+6O6uGNTLVQPKfpCKWiWhO2zTot9d+36ZGj0sMzSpOvY5wRztODlR95C5fs7BsF/H6pJksXkDzbT4fBaNU158YwS0xE+V0WL08TGXynUqrpAR59g95LF/YIuxlKrn1W1PQYY3gG2oegwtILaJUOTK6RCZAZKXtDj5SOzcPGsYnCZ/eYXYtb2RtBh4Xg/hYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=lists.openembedded.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2Q4GGcK9ZQl7RNDMv0WW1h/yBqltxTHrUpYa5tKPcWs=; b=eFTzQFDGcRZcmWzELSmtJZlTqgoEy1pY1naFtm9oJ9tH+zBrvkfgw6GlxcDnkP5cZaPoFr/aOorDVQRjPsmX2Iy8LVicf6jmDsFuYDbSi62kg3kxjVY1NAPeOIh4BsOkH3a60f7LXDStrO+LIYjImtdsd0tcan1CNL/B0sANPsk= Received: from AM0PR02CA0183.eurprd02.prod.outlook.com (2603:10a6:20b:28e::20) by AS4PR02MB7976.eurprd02.prod.outlook.com (2603:10a6:20b:4bb::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9073.27; Tue, 2 Sep 2025 14:06:48 +0000 Received: from AMS0EPF000001A6.eurprd05.prod.outlook.com (2603:10a6:20b:28e:cafe::7b) by AM0PR02CA0183.outlook.office365.com (2603:10a6:20b:28e::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9094.17 via Frontend Transport; Tue, 2 Sep 2025 14:06:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A6.mail.protection.outlook.com (10.167.16.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9073.11 via Frontend Transport; Tue, 2 Sep 2025 14:06:48 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Tue, 2 Sep 2025 16:06:47 +0200 Received: from se-intmail02x.se.axis.com (10.4.0.28) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Tue, 2 Sep 2025 16:06:47 +0200 Received: from pc50740-2234.se.axis.com (pc50740-2234.se.axis.com [10.94.131.4]) by se-intmail02x.se.axis.com (Postfix) with ESMTP id A9CB42D18 for ; Tue, 2 Sep 2025 16:06:47 +0200 (CEST) Received: by pc50740-2234.se.axis.com (Postfix, from userid 21184) id A40292426D0A; Tue, 2 Sep 2025 16:06:47 +0200 (CEST) From: Christian Lindeberg To: Subject: [PATCH 3/3] recipetool/create_go: Tidy up a bit Date: Tue, 2 Sep 2025 16:06:47 +0200 Message-ID: <20250902140647.126140-4-christli@axis.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250902140647.126140-1-christli@axis.com> References: <20250902140647.126140-1-christli@axis.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A6:EE_|AS4PR02MB7976:EE_ X-MS-Office365-Filtering-Correlation-Id: 45c693d4-6b2a-40ed-0522-08ddea29f561 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: ZxRlHmmMWFFqvcDB+ard0B5VY/QVf9TByexcI6uBFrMZ2rTo8T9VYKjXFkzFN5IFBSffkUj+lX3CY29lVLlGYz0gxQ86t6qPxEQMNo5clfLbgEGygaFfgGq8+1V8J6hMOecwFA4bQwVzf12Bvifr9FdGDP6fn6mEefldTYMls27xvH63TVGQj/tnJ/ydta6tIrRCGtaITw2JVSlWVBHbSDg+tpJFERL4D+G0IPHZX0Rerjva4kJopj+xbA55DShhSPN5I1PkNiBm+UGvaRx1dl2Jf5OBp2GwJOEfBRYt+CDyPyiABW26vIh0lsos5tdWsZ7v6O3xAl+pvkH2kCXutxonJN8ZCV9A0ElYokdsm8O1vDNAJcotvSHQuz3lMHkwgl5/Wf8bft02kJyeyAVKz1Wnej2eUhTHa5wxaUeHiOwamC0NajjomhWYGjKA1XqAUB51j8qHlga/dqm2ljYZk8LLBTI4bY0uDbjklpb6HmSTSI8vKxkTk8riZYLJYChDGE+caSv9x53Fz7EJb7SnnQ09v/NTwusoUk3i/uBYOL4aFkQu6XWXrNEoFEF+CSsv42tkGByQds8MeZ5+ZRJb9Kd1j33KRRs7WiADAq7ZCOLwCclZPaU5xpco6WZeMNG5ISug7wSh1CIXzOBHu7TEqRU7tMO+2hmPUTQwp0PTp3uAfehCbKu+CD5SZ2tnJDuVYRM0KYwUI6jQkw1xfE8ElItOIeSlgWsw/y1GWkvSOgNnKwFv25K3+woZgBBSZ3ckv0nCvPC9RW41R1/HEbeWn3SYFQEND4cRzjzRnDc0gDU1AXiQHn7NfB64C0WTuLCkJyZ4jK71lslm4l34+j21uXYpe5oiffjMqLpT/V+0vrmVgzyIIabZScP89gqicM0vOeJ+9oKDSVdyXoVulLJNqGte2mEUhADHMOCn04FSxz8C2ns5iVJL9xbQ/rMjZEcUPx3UfxJyLrZB3KlnNgjKakAQgPlX2Kud7M9QlWTtiKSoIArTfwCN1HK/oAshbIXvYNN4Hz2ExcgFtjWDHFmUjL/ly6tpp8X6Bv74hWQSnGshaf4qL5IMfa8JJO9/qfdY9EtAy/ByGqm1r7BYU0jzyn7nHfpLesD9TqFs4nE2ljYACaLVY3lwx+Re97RDtkNh0E8tmeBdB7zngkLXFvkZVGngbFFpM91GtBgCPvZB3VJs1ZNlqtgilnCVYcfHxjHjc1WR6KzoOTmlJKBY/7fUm4c7/WpfH5Y+kh8xyGOBtG+ExxsI0yjRmYN0jnFw/pHO2nfGcf9Rt0QXmbrNCkXq0wuKVangNF9nZt2SuJmos6C+fChmnW2pHyyfD+vwseFdNv+vHVL+0h2P2VlHVWFJiSwmZEDCkC5GQRdnK8vwuSWHRlQgst71BF4mVcOpqDgPRE6BWmVTiz/uFnqj5zYvSmOcaGM/hFkvO/PY6d0k3l7r8knZ2FSkz3rytYHiQ2U8WZgLJXGtTWjjxxSZ2JQFulI/0jiuTBX5G8rnbPtwSZiQWfVBQGM8fC8F9Bh3EdFR X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2025 14:06:48.7407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45c693d4-6b2a-40ed-0522-08ddea29f561 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A6.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR02MB7976 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 ; Tue, 02 Sep 2025 14:06:58 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222727 From: Christian Lindeberg There is no need for a temporary Go module cache after moving generation of module dependency include files to go-mod-update-modules.bbclass. Signed-off-by: Christian Lindeberg --- scripts/lib/recipetool/create_go.py | 70 ++++++++++++++--------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py index 4b1fa39d13..1b2e5a03d5 100644 --- a/scripts/lib/recipetool/create_go.py +++ b/scripts/lib/recipetool/create_go.py @@ -32,7 +32,6 @@ def tinfoil_init(instance): tinfoil = instance - class GoRecipeHandler(RecipeHandler): """Class to handle the go recipe creation""" @@ -85,41 +84,40 @@ class GoRecipeHandler(RecipeHandler): classes.append("go-mod-update-modules") extravalues["run_tasks"] = "update_modules" - with tempfile.TemporaryDirectory(prefix="go-mod-") as tmp_mod_dir: - env = dict(os.environ) - env["PATH"] += f":{go_bindir}" - env['GOMODCACHE'] = tmp_mod_dir - - stdout = subprocess.check_output(["go", "mod", "edit", "-json"], cwd=srctree, env=env, text=True) - go_mod = json.loads(stdout) - go_import = re.sub(r'/v([0-9]+)$', '', go_mod['Module']['Path']) - - localfilesdir = tempfile.mkdtemp(prefix='recipetool-go-') - extravalues.setdefault('extrafiles', {}) - - # Write the stub ${BPN}-licenses.inc and ${BPN}-go-mods.inc files - basename = "{pn}-licenses.inc" - filename = os.path.join(localfilesdir, basename) - with open(filename, "w") as f: - f.write("# FROM RECIPETOOL\n") - extravalues['extrafiles'][f"../{basename}"] = filename - - basename = "{pn}-go-mods.inc" - filename = os.path.join(localfilesdir, basename) - with open(filename, "w") as f: - f.write("# FROM RECIPETOOL\n") - extravalues['extrafiles'][f"../{basename}"] = filename - - # Do generic license handling - d = bb.data.createCopy(tinfoil.config_data) - handle_license_vars(srctree, lines_before, handled, extravalues, d) - self.__rewrite_lic_vars(lines_before) - - self.__rewrite_src_uri(lines_before) - - lines_before.append('require ${BPN}-licenses.inc') - lines_before.append('require ${BPN}-go-mods.inc') - lines_before.append(f'GO_IMPORT = "{go_import}"') + env = dict(os.environ) + env["PATH"] += f":{go_bindir}" + + stdout = subprocess.check_output(("go", "mod", "edit", "-json"), + cwd=srctree, env=env, text=True) + go_mod = json.loads(stdout) + go_import = re.sub(r'/v([0-9]+)$', '', go_mod['Module']['Path']) + + localfilesdir = tempfile.mkdtemp(prefix='recipetool-go-') + extravalues.setdefault('extrafiles', {}) + + # Write the stub ${BPN}-licenses.inc and ${BPN}-go-mods.inc files + basename = "{pn}-licenses.inc" + filename = os.path.join(localfilesdir, basename) + with open(filename, "w") as f: + f.write("# FROM RECIPETOOL\n") + extravalues['extrafiles'][f"../{basename}"] = filename + + basename = "{pn}-go-mods.inc" + filename = os.path.join(localfilesdir, basename) + with open(filename, "w") as f: + f.write("# FROM RECIPETOOL\n") + extravalues['extrafiles'][f"../{basename}"] = filename + + # Do generic license handling + d = bb.data.createCopy(tinfoil.config_data) + handle_license_vars(srctree, lines_before, handled, extravalues, d) + self.__rewrite_lic_vars(lines_before) + + self.__rewrite_src_uri(lines_before) + + lines_before.append('require ${BPN}-licenses.inc') + lines_before.append('require ${BPN}-go-mods.inc') + lines_before.append(f'GO_IMPORT = "{go_import}"') def __update_lines_before(self, updated, newlines, lines_before): if updated: