From patchwork Fri Oct 16 10:56:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Turull X-Patchwork-Id: 101071 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 6FB6CCC6B38 for ; Fri, 16 Oct 2026 10:56:27 +0000 (UTC) Received: from AS8PR04CU009.outbound.protection.outlook.com (AS8PR04CU009.outbound.protection.outlook.com [52.101.70.55]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.19192.1792148183785411592 for ; Fri, 16 Oct 2026 03:56:24 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@ericsson.com header.s=selector2 header.b=hzooRZLK; spf=pass (domain: ericsson.com, ip: 52.101.70.55, mailfrom: edaturu@ericsson.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SN7tRscKTIA/GN5vKP4Qk/al/hnacHwZ1XS6j4vTRPeHb0dQLPg07bTAmE9RlN53502qHy90y3Svi9XvndfAA3eVKYo7/yqNth14Q7t11rQmM1Rs7TqZVNqCaJBfdcYpCvTInVU49dXS/UeCEUo8tkO8Yfc09r1UOnu7GdAm5Na29ylKY5+Ecn1Wkt0Lw75pwaMQzcZisvIfD6rau/QnLMzmeLSbe9xE7XFzCAXNeyMS6vmgdYqIke4d1/MAb/frcSK31rvrTNHyJAjw+4M3IfJODIfCF37M0r5PCKaDcOXyFso1ngHqkWxsTIpMLOnKOw5afuGiT7AaA8YCMHWtxw== 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=KetlgGdBKmizLcp9QHbJLZLDlXTDGdb8IA67do7WU1s=; b=SHv1jliS7BrJl1Ey3w9bo2VzHu7Zt7pY4mQPEv4lL+PFvwACkORTXZeJfDnq5uf0t2TwCp9JafsytroaN/rlXjfP5rvYQfiI2im6Z9TS5WbeSxF3CVYl+j0DyzbFfIU8ASxEMqXEa7KxfncHX88+CGybNIa/ixLzodKRCbHWVmcxF/vD/nC/+JwG+JWY3xEbAGSnVD3XzC8hnUpBnyRuGl3EZVBp2e2ZdykRByCVUyenzFp2GdHFAaTISk+vke8KEqh9+ACSHRrRWAoueVeWg0yF9GRcaS+ys+c2Ut2efd7lQ+AYD5i6mPEaEE9szaz4Eds30ka29vNnHoB1yufkwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=bootlin.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KetlgGdBKmizLcp9QHbJLZLDlXTDGdb8IA67do7WU1s=; b=hzooRZLK3XHbcPlijE3hiTDbUg5OgLaY1fZ+/RGQTF+kTbBADlRSlZvfR3+x50XhDXM9/tgHA6o+mcMhW9PwRiKC/fDAOi+64K+Fk+CZ88B1Fuz3his40CL/7EnLdMi+INqbNb/LnYeKW4JM9vt/ICqPn/UGVnfi0ajo8MDkH7ulNDJq7fOy5ATP2we8VJPYEyXinPvwUIdNPewfT0ov6octiwkPsoxUX3+gUCGcM/IBuTKVPKiifr8Us4xC6fErWrilkLPMOezDvxqYFrEeE5idbDMlO/ttTlkv+VMiMyj+Cr15aMgQeEMcPT5jFTeVoESF5t/eFjgaYLDNYoAG/w== Received: from AS4P192CA0020.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5e1::6) by AS2PR07MB9279.eurprd07.prod.outlook.com (2603:10a6:20b:60d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.15; Fri, 16 Oct 2026 10:56:17 +0000 Received: from CPH1EPF00000530.eurprd05.prod.outlook.com (2603:10a6:20b:5e1:cafe::87) by AS4P192CA0020.outlook.office365.com (2603:10a6:20b:5e1::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Fri, 16 Oct 2026 10:56:17 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by CPH1EPF00000530.mail.protection.outlook.com (10.167.241.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.6 via Frontend Transport; Fri, 16 Oct 2026 10:56:17 +0000 Received: from seroius18814.sero.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 16 Oct 2026 12:56:16 +0200 Received: from seroius08462.sero.gic.ericsson.se (seroius08462.sero.gic.ericsson.se [10.63.237.245]) by seroius18814.sero.gic.ericsson.se (Postfix) with ESMTP id 3DB0C4020B46; Fri, 16 Oct 2026 12:56:16 +0200 (CEST) Received: by seroius08462.sero.gic.ericsson.se (Postfix, from userid 160155) id 12EB0700E7CC; Fri, 16 Oct 2026 12:56:16 +0200 (CEST) From: To: CC: , , Daniel Turull Subject: [PATCH v6 1/3] oe/reproducible: exclude __CACHED_SOURCE_DATE_EPOCH from task hash Date: Fri, 16 Oct 2026 12:56:09 +0200 Message-ID: <20261016105611.330514-2-daniel.turull@ericsson.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261016105611.330514-1-daniel.turull@ericsson.com> References: <20261016105611.330514-1-daniel.turull@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CPH1EPF00000530:EE_|AS2PR07MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: 71bdef30-e934-4321-d361-08df2b741a90 X-SMTP-Server: smtp-central.internal.ericsson.com X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|376014|1800799024|36860700016|82310400026|56012099006|11063799006|261009223027099003|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: QyK3lTNVHskogVnMFlE29VQp2hJxr0bjmesYsFGsC+WmFaEw6TJYFSLdUx1kheCt3l5AtudLwKhEmzKcBRne7qpzJPhbnbaKWuO/Wjx396+waGcyiVqW0wdzOnO31wf+J258teNqsuikNmOx1LgcZ4tzDmat34swcpswJAWDezGl/LLuyveowUnQ929T0g58PN/6SzoEsz0ZD1wR17f/aypnMm3E+EsXXpLx+7j2IQcd5BMaY+cHSDvv8Ll5ZkEg1MqkzHPsxh5jGSsuZYRZfZs4gvbVp8t0OoAPZjzx2ecG2V0ngEv0lk7PgdhwKR30jYS3zubv8ajtZ/dplHQI0QO/UY3VVZDTrnxloXRc0sGnQMOeJt3PiZt3cJqd5apX7wn9tchVTmF8cI+Hku5QxN9VpRF4w9wHVKGdKywMA0FKKojoEQWD4X4kZB0W6FpQR9xL6Pp6dRXwwIzrQLc55BsURUjrcPBKUb/Mlam4ctLEnEMoFMLt8CtQLX4xFz0Wz81XjJW5kqrT7ifIl8AsDbclqRL7Z4b77XgyhEdBsy9ozDSj6HlU1c60xfOCbmye+ntTIer7H0x+C7z6+xGjv5voYZHgUQ5Ku38oPWiv3Mhp4hdjPEhYjB5bqpFCL+918p0xIeN0rFVA7PuowWkOPI2FiTDKpJ7rDGNCQY9jThBGGOPdg0W9k+YSY/JGHWMGu+idYYsZGZQQtAaUWKLX+g== X-Forefront-Antispam-Report: CIP:192.176.1.74;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:oa.msg.ericsson.com;PTR:office365.se.ericsson.net;CAT:NONE;SFS:(13230040)(23010399003)(376014)(1800799024)(36860700016)(82310400026)(56012099006)(11063799006)(261009223027099003)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ljGK83pMlN50aFa5l/BP0/w1tz328FA5O3Fm177MgwzCrXqkle8WnbUa9LXKChwLKBQzoxeuXi5gJTEM7XlNqZaja6NdvSmXSs+WJDILhj/gvxxEf8d1NhrOZ9po42GzCrYSM2GnUsQmrRI5LrzbpiSKS3Qjqq7qw8UciZgGSvuAU8m8sVcodD7Kn9ioO936OSR4b1kqrHHhbi9VQ67ATAOlqZBHMBq/9wh/YfexoVyuOcbFgT20Mo37Y2w3nYfoWAYBn1HzgUvQd1pDmvIJRLKvl0ep8tu45xINFvFRxsdoj2tF1DiHGlci/Zd+uqUbRzyG8td13T2rKgZApitn/L80M9Jpxpx3IzDghTJsporM9D2wrRteBncrryy48dYLVtSx9taeg65mqN45tJvQVfuutzvjsFZ43Hwmq6kGa71KhoXxmVqYBbXja4NUWOXN X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2026 10:56:17.1340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71bdef30-e934-4321-d361-08df2b741a90 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f;Ip=[192.176.1.74];Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: CPH1EPF00000530.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR07MB9279 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 16 Oct 2026 10:56:27 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/248009 From: Daniel Turull epochfile_read() memoizes its result into __CACHED_SOURCE_DATE_EPOCH via d.setVar(), so its runtime value leaks into the basehash of any task that calls it, causing a "metadata is not deterministic" error once SDE_FILE is populated. Exclude it, since it is not meaningful build metadata, using the bb.parse.vardepsexclude decorator on the function itself. AI-Generated: Uses Kiro with Claude Sonnet 5 Signed-off-by: Daniel Turull --- This should fix the selftest errors reported by Mathieu v6: use bb.parse.vardepsexclude as requested by Richard --- meta/lib/oe/reproducible.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py index a80376010a..d8e1dc825f 100644 --- a/meta/lib/oe/reproducible.py +++ b/meta/lib/oe/reproducible.py @@ -156,6 +156,9 @@ def get_source_date_epoch(d, sourcedir): fixed_source_date_epoch(d) # Last resort ) +# epochfile_read() memoizes into __CACHED_SOURCE_DATE_EPOCH via d.setVar(), so +# its runtime value must not leak into any task's hash. +@bb.parse.vardepsexclude("__CACHED_SOURCE_DATE_EPOCH") def epochfile_read(epochfile, d): cached, efile = d.getVar('__CACHED_SOURCE_DATE_EPOCH') or (None, None) if cached and efile == epochfile: From patchwork Fri Oct 16 10:56:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Turull X-Patchwork-Id: 101072 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 7F32DCCA464 for ; Fri, 16 Oct 2026 10:56:27 +0000 (UTC) Received: from MRWPR03CU001.outbound.protection.outlook.com (MRWPR03CU001.outbound.protection.outlook.com [40.107.130.30]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.19191.1792148183745458024 for ; Fri, 16 Oct 2026 03:56:24 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@ericsson.com header.s=selector2 header.b=UzqneQfS; spf=pass (domain: ericsson.com, ip: 40.107.130.30, mailfrom: edaturu@ericsson.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ndsA2Vz/X8p873YVVjKEz4qyhZ0zXgkUPW0fb+ROhEl0G04rszYJiGC7XcvGn+V/bV5W0BP4QfrzL2qbYKYq7bo/XSZRwJNHMVlmkLjNCkiljkpcJDedfki4fKPX0OL2MfFI3jysjzzjf1voD/xppzxeuOFReyL0VsaU+RD4dP3aTuqLSaRMtpEMRr+9mcaQvCq59SMYsEmsGokSIcgwpLmrvT2f8q/vknrBUt/DtXUSAvlIb17pFSt2xNa18oZ7UQbIL0xQNo6FVfPOSHtvGtNfgfd48uB6mr0gwk3hfX0q3cxoQ9NCbKsn8XwelKUFypk11zrFMKgxO1zCqX7lVw== 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=wREE2g1P4uzfVjWIIT65ojGfwAbwVeclf7w1jNkjytg=; b=RBQPzGvJkjO0K0MjlJ2cTHc6ZKKWPtstZhW7WRLTwBGwwNHdkagLTunEeU3Ni0vBGR2DNy+HZlvvB+r2WC1qiOTKd4kswsR6MAjbC0k5Q5S54SfcrPh80PsfQ9vDweVfRx/9s81rw3hRqVjDeAEriLXNu/m2i/Oo9ch1vTsz6VTem1Qa7E1czvneRmWbmzHywj+1vYAOXTBkFXcv3MAjJKnm35d3EDYmFODQpU3vi89gIZEfsSERVddVweDLxs33phYMN80lmYEAUzcYfoBOZIZZDy+9UCoQ4kvd/xRX9d/OixaDksBFhfe6pxpFZy1Y+kgGm8yoawODCqWOJOENWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=bootlin.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wREE2g1P4uzfVjWIIT65ojGfwAbwVeclf7w1jNkjytg=; b=UzqneQfSocCqtaQUS080c2owdVkoIW71zXsOu2fYHc5luc+QrfG9ReRf4nsx/QDOywt8L0CozF44YOpK3EsLq5WD+9kk7qghcHR+4mIysVzEtxDhx/e7+53IkCxvDhWw8SwyJt0oePsGEThTP/tt2eQd1cvr0jCTkAoLipAN7rp/m/Ql/5pvaxVhKC54eqh0eCGbczMOf6+yaO5IqD9hH5e0lT2Cl4gU/eLpAVWZ50+RWAYx8lFExJriq1UNARmnyAAerZY2G/xUIrv18nhQCepfLR9X+RrlDL9vMjPIV8N5MxmTkaDhQJXb0giOChfDDsi7ar7fvgohKWy+tSFn0w== Received: from PA7P264CA0384.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:399::9) by AMBPR07MB196320.eurprd07.prod.outlook.com (2603:10a6:20b:7b1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.14; Fri, 16 Oct 2026 10:56:17 +0000 Received: from ZR1PEPF0000E6AF.eurprd05.prod.outlook.com (2603:10a6:102:399:cafe::7d) by PA7P264CA0384.outlook.office365.com (2603:10a6:102:399::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Fri, 16 Oct 2026 10:56:17 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by ZR1PEPF0000E6AF.mail.protection.outlook.com (10.167.241.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.6 via Frontend Transport; Fri, 16 Oct 2026 10:56:17 +0000 Received: from seroius18813.sero.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 16 Oct 2026 12:56:17 +0200 Received: from seroius08462.sero.gic.ericsson.se (seroius08462.sero.gic.ericsson.se [10.63.237.245]) by seroius18813.sero.gic.ericsson.se (Postfix) with ESMTP id 43ED99581C; Fri, 16 Oct 2026 12:56:16 +0200 (CEST) Received: by seroius08462.sero.gic.ericsson.se (Postfix, from userid 160155) id 16CD87003EA9; Fri, 16 Oct 2026 12:56:16 +0200 (CEST) From: To: CC: , , Daniel Turull Subject: [PATCH v6 2/3] create-spdx-3.0: record component release date in SPDX output Date: Fri, 16 Oct 2026 12:56:10 +0200 Message-ID: <20261016105611.330514-3-daniel.turull@ericsson.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261016105611.330514-1-daniel.turull@ericsson.com> References: <20261016105611.330514-1-daniel.turull@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZR1PEPF0000E6AF:EE_|AMBPR07MB196320:EE_ X-MS-Office365-Filtering-Correlation-Id: 184e3ff5-7edd-486d-ce7c-08df2b741ac8 X-SMTP-Server: smtp-central.internal.ericsson.com X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|23010399003|1800799024|82310400026|56012099006|11063799006|261009223027099003|260925021911599003|10067099003|18002099003|22082099003|260925022911599003|260925021311599003|3023799007; X-Microsoft-Antispam-Message-Info: c9I2Uz3feDIMK0RKAljo3UyUmv6M2ycYZHCiV/+hzxyfmaK5k/KaLj3w+OoOzeWWPIkTzio9GW9vORsuCI0MxYAfQp5JrL2cfjcTtWY9iDiUHdsis/dvc89W23lkR1q3hpZXYQ7qH0bXWtpVyxvzFTEvLuBw6A9ziwZP1u5oUuTiRJ3owgdrA0Jfxr1/s3bJ8nbzSyfEf/bl5LOvf6TBLBNLfk63bR/4k6rhytOLB4j4XOoszlmWN1oQh/vCJCvBZGqf6uzJqzvBRJQ1ok4WN4YYaATPTB0ixkjHr6dSD3q+rIlsWIQKD8ggUPlw2KIrsaocT3dhQeIhlczY9xAxeXIYLGMik1cc+1+CCIHTjnQcuLeEVgMrMlN6Q+OFhjreM0xmqP3cxZ+MzZf5KTqObSY22+Vy+l1SPspjT4MF5EKfvg5aZ7tqmcPw9ttRqqzGVUenYOZ+4cSeZTosW9sowTTaBkff2ljSUaQVkDct7S8jmEvz38gv1NsBDUUZbfc6XAbZv2zLCbxKpHEC2d94kE4GHLypmZczUU10HuHmVEbucb6kVE9auLM8ffRztwj+ydegRQMVnCctGZXarti+oKoEXIEnAJP6WNkXIN6qXRhYkrkSr2S+qqoTyOHcR9t/7QJyMvs1fO5iXlIYLEZmtE6emydFIwz08f8560Uzp9Vaxfzyv6Dn9ojr7qrawzSSUTJUIrUYD+oqxqzuGo+6cw== X-Forefront-Antispam-Report: CIP:192.176.1.74;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:oa.msg.ericsson.com;PTR:office365.se.ericsson.net;CAT:NONE;SFS:(13230040)(36860700016)(376014)(23010399003)(1800799024)(82310400026)(56012099006)(11063799006)(261009223027099003)(260925021911599003)(10067099003)(18002099003)(22082099003)(260925022911599003)(260925021311599003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f3FAZkBMVJLcI+cqWwT5UGe25useclmjBI6Q2XM3qCrexFfGdO+zyySWF0SaTAtEFJ6SSVIWYzzSWULHpWvPSj0zhri2YDESW7997H+fU0f7S97biSM4x48Lq13nG/XwruURaasDoFd+C1IPYFBN48fwzhAbqLh8uJlW8+H3FkWusrJeNfDeHd9D0N5wDW0I4PNc3LJOr45Vgh+ohf+SNsZ9c619/tTUlGQaTssrHQtRLj1DC4me/WdDxjx351u4cfcN4AB7UEl5NPUG+0JjogHuXpS+sG7JrKsI1atUidz7q/BCiqC1A9c4YfSItcLybcPBU++VT3gbdU8zOMuTp7RsFey41l2X+GxFI56SJptDrXkGkWX7K9FMA5c3cxPhVsB26e6TjNC65lVulcL8+8KTeh3yBjQDMdW0O71HGbfa5pDXj4L5KH+oC+UShFdq X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2026 10:56:17.4738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 184e3ff5-7edd-486d-ce7c-08df2b741ac8 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f;Ip=[192.176.1.74];Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: ZR1PEPF0000E6AF.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMBPR07MB196320 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 16 Oct 2026 10:56:27 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/248010 From: Daniel Turull Record each package's release date in the releaseTime property of its software_Package object, using the source date epoch already computed for reproducible builds. Accuracy depends on how the source date epoch was derived: exact for git-tagged recipes, best-effort for tarball/http(s) sources. Some Python sdists (e.g. cryptography, hypothesis, maturin) normalize all file mtimes to a fixed placeholder, so their releaseTime reflects packaging-tool behavior, not the real release date. AI-Generated: Uses Kiro with Claude Sonnet 5 Signed-off-by: Daniel Turull --- v2: - Dropped all options per Joshua's feedback; read SDE_FILE directly. - Dropped the redundant else: delattr(recipe, "releaseTime") branch. - Selftest compares against SDE_FILE content directly instead of SOURCE_DATE_EPOCH, which can diverge from it. - Fixed a leak: recipes with no git checkout and no fetched source had SDE_FILE holding only SOURCE_DATE_EPOCH_FALLBACK, showing a bogus 2011-04-05T23:00:00Z releaseTime instead of none. v3: - Also run after do_unpack: do_deploy_source_date_epoch's setscene shortcut can skip it, leaving SOURCE_DATE_EPOCH unset. - get_release_date() reads SOURCE_DATE_EPOCH again instead of SDE_FILE, now that they're guaranteed equivalent. - test_release_date_source_date_epoch: switched to tar (base-files has S == UNPACKDIR and never gets a real SOURCE_DATE_EPOCH). - Added test_release_date_omitted_for_fallback_value. v4: - Per Richard's feedback, moved releaseTime from do_create_recipe_spdx to do_create_spdx to keep the recipe-only task fetch-free. - Per Joshua's suggestion added into each downloaded source software_Package - Updated selftests accordingly. v5: - test_release_date_source_date_epoch: force do_unpack before reading SOURCE_DATE_EPOCH. Mathieu hit this on the autobuilder: with all tasks restored from sstate do_unpack never runs, so SDE_FILE is missing and SOURCE_DATE_EPOCH falls back, making the test compare the correct releaseTime against the fallback date. v6: - Per Joshua's feedback, get_release_date() now reads SDE_FILE via oe.reproducible.epochfile_read() instead of SOURCE_DATE_EPOCH, since a recipe can set SOURCE_DATE_EPOCH itself to override the computed value, and that override is not a release date. - Added test_release_date_ignores_source_date_epoch_override. --- meta/lib/oe/spdx30_tasks.py | 25 +++++++++++++++++ meta/lib/oeqa/selftest/cases/spdx.py | 42 ++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py index b6456a214a..1d11d8d1d2 100644 --- a/meta/lib/oe/spdx30_tasks.py +++ b/meta/lib/oe/spdx30_tasks.py @@ -9,6 +9,7 @@ import oe.cve_check import oe.license import oe.packagedata import oe.patch +import oe.reproducible import oe.sbom30 import oe.sdk import oe.spdx30 @@ -36,6 +37,26 @@ def set_timestamp_now(d, o, prop): delattr(o, prop) +def get_release_date(d): + """Resolve the release date to record in a package's releaseTime property. + + Reads SDE_FILE via oe.reproducible.epochfile_read() directly, rather than + SOURCE_DATE_EPOCH, since a recipe may set SOURCE_DATE_EPOCH itself to + override the computed value, and that override is not a release date. + + Omits the fallback value since it is not a meaningful release date. + + Returns a datetime, or None if no release date should be recorded. + """ + source_date_epoch = oe.reproducible.epochfile_read(d.getVar("SDE_FILE"), d) + if not source_date_epoch or source_date_epoch == d.getVar( + "SOURCE_DATE_EPOCH_FALLBACK" + ): + return None + + return datetime.fromtimestamp(int(source_date_epoch), tz=timezone.utc) + + def add_license_expression( d, objset, license_expression, license_data, search_objsets=[] ): @@ -441,6 +462,7 @@ def _enrich_source_package(d, dl, fd, file_name, primary_purpose): def add_download_files(d, objset): inputs = set() + release_date = get_release_date(d) urls = d.getVar("SRC_URI").split() fetch = bb.fetch.Fetch(urls, d) @@ -504,6 +526,9 @@ def add_download_files(d, objset): _enrich_source_package(d, dl, fd, file_name, primary_purpose) + if release_date is not None: + dl.releaseTime = release_date + if fd.method.supports_checksum(fd): for checksum_id in bb.fetch.CHECKSUM_LIST: if checksum_id not in oe.spdx30.HashAlgorithm.NAMED_INDIVIDUALS: diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py index 8285189382..c900558b44 100644 --- a/meta/lib/oeqa/selftest/cases/spdx.py +++ b/meta/lib/oeqa/selftest/cases/spdx.py @@ -6,6 +6,7 @@ import textwrap import hashlib +from datetime import datetime, timezone from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars import oe.spdx30 @@ -443,3 +444,44 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase): r'\d', f"Version '{version}' for package '{name}' should contain digits" ) + + def test_release_date_source_date_epoch(self): + """releaseTime should be derived from SDE_FILE via epochfile_read(). + + This is recorded on the downloaded source software_Package objects + produced by do_create_spdx (not the recipe-only do_create_recipe_spdx + task), since the release date can only be known once sources are + available and SOURCE_DATE_EPOCH has been computed. + """ + objset = self.check_recipe_spdx( + "tar", + "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/builds/build-tar.spdx.json", + ) + + bitbake("tar -c unpack -f") + sde_file = get_bb_var("SDE_FILE", "tar") + with open(sde_file) as f: + source_date_epoch = f.read() + expected = datetime.fromtimestamp(int(source_date_epoch), tz=timezone.utc) + + pkg = None + for candidate in objset.foreach_type(oe.spdx30.software_Package): + if candidate.software_downloadLocation: + pkg = candidate + break + + self.assertIsNotNone(pkg, "Unable to find downloaded source software_Package") + self.assertEqual(pkg.releaseTime, expected) + + def test_release_date_omitted_without_downloaded_source(self): + """releaseTime only applies to downloaded source packages; recipes + with only local file:// sources have none, and get no releaseTime.""" + # base-files only has file:// sources, so it has no downloaded + # source software_Package and thus no releaseTime anywhere. + objset = self.check_recipe_spdx( + "base-files", + "{DEPLOY_DIR_SPDX}/{MACHINE_ARCH}/builds/build-base-files.spdx.json", + ) + + for candidate in objset.foreach_type(oe.spdx30.software_Package): + self.assertIsNone(candidate.releaseTime) From patchwork Fri Oct 16 10:56:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Turull X-Patchwork-Id: 101073 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 98B8BCCA48B for ; Fri, 16 Oct 2026 10:56:27 +0000 (UTC) Received: from MRWPR03CU001.outbound.protection.outlook.com (MRWPR03CU001.outbound.protection.outlook.com [40.107.130.66]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.19193.1792148185908075141 for ; Fri, 16 Oct 2026 03:56:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@ericsson.com header.s=selector2 header.b=YyI+s1SJ; spf=pass (domain: ericsson.com, ip: 40.107.130.66, mailfrom: edaturu@ericsson.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o7e3pFFdkGrv95xDrrpV/T3TMAZFZmjySk4WfE4ErmubA2y9zCL3q73IV1Yv0oCQtSxC/vq8E9rLDJAxqnlLiZxviE/N9EQSDpGSsES1N2FB3yz8JQ/n48cpEHYwxJ6d1N0G5/w4ICxtttASTg7kA1rmDTYunz4/mXQslBqmGvEvZtSUSrBYntUANyZ+2bqC257Z6IWBEmS7mRVakakBiudy9bBp+VJjYgNMyZ11oOunSaWG6HqoOsMkU0i8pjM+n9F83XYH6btXWFspWadpALiKQMViFVv9H33Z9d82SFV/EwJa9YpBWwmRyRcjO7FDa/J9s2b2CCzDPl6vBXhOyw== 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=Z0dRw32rwVf2K8zq99Lnbhy/OTsa5ckPlkxubwXZqHA=; b=HxjRBDW/VyjNqQ3XMGoW/vyUayauPzJ8c5cXMSNUS2YdrGRYe85qpRp7XgmKqoHpcPr8P819UETQ6XHdpednLMHXYPkTg8o5jX3XwVlJrehfqlU7LkaguSCqu+0qri8AriF6aqxiJnA+RXsqxo/X3s5ItxPdIJHe3RuaX1ifJPSyitWI1QO1tkoIUYm820Ktbt83R3OAHtacv/3Smz6SCNrOfr9XFhmfG0UxDWpy+87aGDqaeDwJVGgmiwBy4BlsFWJXkv5QL18st7PK2O+edT2r29Hha828B6JX81JAKyRqdSCLllZOPXJ/hWHWD3PT8tpyLr82KpQdnor2EuTO9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=bootlin.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z0dRw32rwVf2K8zq99Lnbhy/OTsa5ckPlkxubwXZqHA=; b=YyI+s1SJROT0TuI6bTeb/875ClUHzR8/O2sjiXXRqLwo6C27f7jAULk7Bz/F8AhrL+vbG0GO+mfOCRSWUGN3WnqAsh++GxSUdTvLDENVOszP4sXjU2FEVJbaZCvnmhldxg9WtBcGT62gEUkGFwi6e8HGh6+mnW3B6YJRlKraF+kEbsW1/L60MJNaTpzo+s1KKIfpMVh90te42NpeoraS6geFqQtmZUh/g8T9/XS6NH7s/eTtHu1hk/o7SS34DXzfYHBTb5CMarAs403PgzUCWo+jbHIyjGWlrKXV8KiqwypZ9SEeUA424af+11AjaiXCs+ivvQD+fYDUYC8kdxxssg== Received: from AS4P192CA0024.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5e1::16) by DB9PR07MB9342.eurprd07.prod.outlook.com (2603:10a6:10:454::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.14; Fri, 16 Oct 2026 10:56:17 +0000 Received: from CPH1EPF00000530.eurprd05.prod.outlook.com (2603:10a6:20b:5e1:cafe::a5) by AS4P192CA0024.outlook.office365.com (2603:10a6:20b:5e1::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Fri, 16 Oct 2026 10:56:17 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by CPH1EPF00000530.mail.protection.outlook.com (10.167.241.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.6 via Frontend Transport; Fri, 16 Oct 2026 10:56:17 +0000 Received: from seroius18815.sero.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 16 Oct 2026 12:56:16 +0200 Received: from seroius08462.sero.gic.ericsson.se (seroius08462.sero.gic.ericsson.se [10.63.237.245]) by seroius18815.sero.gic.ericsson.se (Postfix) with ESMTP id 43F584020B44; Fri, 16 Oct 2026 12:56:16 +0200 (CEST) Received: by seroius08462.sero.gic.ericsson.se (Postfix, from userid 160155) id 1AD71700396D; Fri, 16 Oct 2026 12:56:16 +0200 (CEST) From: To: CC: , , Daniel Turull Subject: [PATCH v6 3/3] scripts/contrib: add spdx-release-date-report.py Date: Fri, 16 Oct 2026 12:56:11 +0200 Message-ID: <20261016105611.330514-4-daniel.turull@ericsson.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261016105611.330514-1-daniel.turull@ericsson.com> References: <20261016105611.330514-1-daniel.turull@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CPH1EPF00000530:EE_|DB9PR07MB9342:EE_ X-MS-Office365-Filtering-Correlation-Id: 25c6de11-d3ed-493c-6c07-08df2b741ade X-SMTP-Server: smtp-central.internal.ericsson.com X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|23010399003|36860700016|82310400026|56012099006|260925021911599003|260925022911599003|260925021311599003|11063799006|261009223027099003|10067099003|22082099003|18002099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: QflSHq1PIcDqTpE2BYcwac+OgIebfVihcQlpBY7NBX/KaAp3dddHs57t/4lZIx4PkZSESIN548JE0kab6Nowxac/RSUFoOeYI6kycfUwZJgJuOx1v3+0qJJ3NDF7vwn2M/qXxkQpuP8NlT+8bJ380iGEc/bBwf76BJhwXP+pcmy+468eLgOo3mUmurB4TSP2ISCZDd/wrPI/45ccm0Py8CSZID50VgOeffRHOpMQCUfsZIFn7SeRsFzwevhlOeYH5OhUT/xrdB6lOVE5QGz2U5F9Sk+hEe3xQBnInzMFt06bdoa9qhddyuxhboyRzxXFhF+Az0F+dgfns6rZO5pyOqyjXfDCeJM8bpEAQ2HIJxwn3qtpKRW6PpjmRhqc/y4Si9p8PElkcDbu8r31SN0QHkiUROjkCCNVRSAhEumUXIRS6OBGC/3FCYlKpo1CFQ7As/CjQANsa6o25r98zt+ngrC/oaosk6eT0kivFePn1txTOLqGRpQ4I+kSL15qx8XgnClGNTC6DHafENwGR+5jHrs24y+uUPq/UI2ZHxDsMva/xcW/gJDD+A0xLh1oS8xndguuhsEAseDdrEm3Y3EsU9lfFjT4igJbxeIJz2rxElsGxChR7oP0tJ1LMFh5PrNPGbScHHbcIquvJnduHskl2w1t5OOnzOAVn4xQT8twR/2fyDdU7VbhMhE8Qczo2S/dZK8CMFUoO79KxkKmEwTJCg== X-Forefront-Antispam-Report: CIP:192.176.1.74;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:oa.msg.ericsson.com;PTR:office365.se.ericsson.net;CAT:NONE;SFS:(13230040)(1800799024)(376014)(23010399003)(36860700016)(82310400026)(56012099006)(260925021911599003)(260925022911599003)(260925021311599003)(11063799006)(261009223027099003)(10067099003)(22082099003)(18002099003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aVWizeDOdx6R/KTSuImopFbujSC48Pg3gQXhWf8bFI/BQD5aX/Ix0wagBFMpBGLe+/cbD1F9YVdBieSRWgc/PfkUaNeEcflTGA0mPX5yY1IKPbqFrwFZ+fde+VUSUQLra+hO73+ietm9AgnT2nhE9Akx8ymLOdBJIpbIh9uFBQ4lU1o/AFsc/R1RWKS5INxNVEc3l5tI5ot6MqPpCFAM/4VtjaCBTM2XWQk9tGb19D8SXBIrntva1hNtHtE2mOjKHyJILE7pWU7hdLk5ltt8zgz2f1W0abmlWGLT9Dok1/1dykgzHFptjBSCBthB7kfEtd5B/kLp3fRIVG/EOJJC6MWNcGtRCJzq3lfJEtiisTWKEEaBwXWTLybewSi+b+owdt6jb2Gou3uzJiX3o8ALKVuqO8CwDHl7wxASCItHTtr2D0Z++jXDtTtgZzj3kwA9 X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2026 10:56:17.6437 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25c6de11-d3ed-493c-6c07-08df2b741ade X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f;Ip=[192.176.1.74];Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: CPH1EPF00000530.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB9342 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 16 Oct 2026 10:56:27 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/248011 From: Daniel Turull Reports each recipe's releaseTime (added by the create-spdx-3.0 patch) from either a DEPLOY_DIR_SPDX tree or a single merged image SBOM. Used to spot-check release dates across a build and surface recipes missing one; helped find the SOURCE_DATE_EPOCH_FALLBACK leak fixed by the preceding patch. AI-Generated: Uses Kiro with Claude Sonnet 5 Signed-off-by: Daniel Turull --- v4: - Rework to match the new placement of the releaseTime. --- scripts/contrib/spdx-release-date-report.py | 191 ++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100755 scripts/contrib/spdx-release-date-report.py diff --git a/scripts/contrib/spdx-release-date-report.py b/scripts/contrib/spdx-release-date-report.py new file mode 100755 index 0000000000..71420d0e24 --- /dev/null +++ b/scripts/contrib/spdx-release-date-report.py @@ -0,0 +1,191 @@ +#! /usr/bin/env python3 +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: GPL-2.0-only +# +# Author: Daniel Turull +# +# Reports, per recipe, whether a valid releaseTime was recorded in SPDX +# 3.0.1 output. +# +# AI-Generated: Uses Kiro (Claude) + +import argparse +import csv +import glob +import json +import logging +import os +import re +import sys + + +# Each do_create_spdx software_Package's spdxId is +# "/-//...", so the recipe name +# can be recovered directly from the id without walking relationships. +RECIPE_FROM_SPDX_ID_RE = re.compile( + r"^.*/([^/]+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/" +) + + +def recipe_name_from_spdx_id(spdx_id): + """Extract the PN that generated an element, from its spdxId, or None.""" + match = RECIPE_FROM_SPDX_ID_RE.match(spdx_id or "") + return match.group(1) if match else None + + +def load_jsonld_graph(path): + """Return the @graph list of a SPDX 3.0.1 JSON-LD document, or [] on error.""" + try: + with open(path, "r", encoding="utf-8") as f: + data = json.load(f) + except (OSError, json.JSONDecodeError) as e: + logging.warning("Skipping %s: %s", path, e) + return [] + return data.get("@graph", []) + + +def extract_release_dates(elements): + """ + Map recipe name -> releaseTime (or None), for each downloaded source + software_Package found in elements. The recipe name is recovered from + each package's own spdxId (see recipe_name_from_spdx_id). For a given + name, the first package with a releaseTime wins; if none have one, the + name still appears, mapped to None. + """ + release_dates = {} + for element in elements: + if element.get("type") != "software_Package": + continue + if not element.get("software_downloadLocation"): + continue + name = recipe_name_from_spdx_id(element.get("spdxId")) + if not name: + continue + release_dates.setdefault(name, None) + release_time = element.get("releaseTime") + if release_time and not release_dates[name]: + release_dates[name] = release_time + return release_dates + + +def iter_spdx_elements(path): + """Yield @graph elements from path: every build-*.spdx.json under path + if it's a DEPLOY_DIR_SPDX tree, or path's own @graph if it's a single + SPDX JSON-LD file (e.g. a merged image SBOM). + + Only build-*.spdx.json is read for a DEPLOY_DIR_SPDX tree: it's the + output of do_create_spdx, the only recipe task that calls + add_download_files and so the only one that can carry + software_downloadLocation/releaseTime. The other per-recipe documents + (static-*.spdx.json from the fetch-free do_create_recipe_spdx, and + package-*.spdx.json for binary packages) never have that data. + """ + if os.path.isdir(path): + build_pattern = os.path.join(path, "**", "builds", "build-*.spdx.json") + for build_path in sorted(glob.glob(build_pattern, recursive=True)): + yield from load_jsonld_graph(build_path) + else: + yield from load_jsonld_graph(path) + + +def _to_row(name, release_date): + return { + "recipe": name, + "release_date": release_date or "", + } + + +def build_report(path): + """ + Build the report: [{"recipe": ..., "release_date": ...}], from either a + DEPLOY_DIR_SPDX tree or a single merged image SBOM file. + """ + release_dates = extract_release_dates(iter_spdx_elements(path)) + return [_to_row(name, release_dates[name]) for name in sorted(release_dates)] + + +def drop_redundant_native(report): + """Drop foo-native rows when foo is also present in the report.""" + names = {r["recipe"] for r in report} + return [ + r + for r in report + if not (r["recipe"].endswith("-native") and r["recipe"][:-len("-native")] in names) + ] + + +def filter_rows(report, sort_by_date=False): + rows = list(report) + if sort_by_date: + rows.sort(key=lambda r: (not r["release_date"], r["release_date"], r["recipe"])) + return rows + + +def print_table(rows): + if not rows: + print("No matching recipes found.") + return + + name_width = max(len("recipe"), *(len(r["recipe"]) for r in rows)) + print(f"{'recipe':<{name_width}} release_date") + for r in rows: + print(f"{r['recipe']:<{name_width}} {r['release_date']}") + + +def write_csv(rows, path): + with open(path, "w", newline="", encoding="utf-8") as f: + writer = csv.writer(f) + writer.writerow(["recipe", "release_date"]) + for r in rows: + writer.writerow([r["recipe"], r["release_date"]]) + + +def main(): + parser = argparse.ArgumentParser( + description="Report recipe release dates from SPDX 3.0.1 output" + ) + parser.add_argument( + "path", + help="Path to DEPLOY_DIR_SPDX (e.g. tmp/deploy/spdx/3.0.1) or to a " + "single merged image SBOM file (e.g. " + "tmp/deploy/images//.rootfs.spdx.json)", + ) + parser.add_argument( + "--csv", + help="Write the report to a CSV file instead of only printing a table", + ) + parser.add_argument( + "--sort-by-date", + action="store_true", + help="Sort output by release date instead of recipe name (missing dates last)", + ) + args = parser.parse_args() + + logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.INFO) + + if not os.path.isdir(args.path) and not os.path.isfile(args.path): + parser.error(f"{args.path} does not exist") + + report = build_report(args.path) + report = drop_redundant_native(report) + + total = len(report) + found = sum(1 for r in report if r["release_date"]) + logging.info("Recipes with SPDX package data: %d", total) + logging.info("Recipes with a release date: %d", found) + logging.info("Recipes missing a release date: %d", total - found) + + rows = filter_rows(report, args.sort_by_date) + print_table(rows) + + if args.csv: + write_csv(rows, args.csv) + logging.info("CSV report written to %s", args.csv) + + return 0 + + +if __name__ == "__main__": + sys.exit(main())