From patchwork Mon Oct 12 11:53:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Turull X-Patchwork-Id: 100444 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 255AECA9ED0 for ; Mon, 12 Oct 2026 11:53:53 +0000 (UTC) Received: from MRWPR03CU001.outbound.protection.outlook.com (MRWPR03CU001.outbound.protection.outlook.com [40.107.130.50]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11542.1791806028360669853 for ; Mon, 12 Oct 2026 04:53:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@ericsson.com header.s=selector2 header.b=lpZaEYIV; spf=pass (domain: ericsson.com, ip: 40.107.130.50, mailfrom: edaturu@ericsson.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ySuAPs05rnh6xZep5Yjo+GojLVHFUpvBpgS4+NUB3s2Tbi7U3ANgU5LBm3Te7QKOucjO2TH9i9aYExBlBu4m+UGcg3tErycamu5UvxSxwyeanhhogB9i+PWBwARmGG3IU3tmsLBmr440y3Q+gBg7iSYFTSeXKLQWgqB0MtsdDj5GIu94trT2knI3K1zZ46U2oUBVJTun+H3MfdraVnd6ZwNlS4Cz0PcvIlN5G6ZMJ5kCxcHHKHxOrhe7VLu1Srtc7vISag3z1CZLLfmRFqw79/sEdC1Lcg6HgBx1RRBscVQJCyRsRWvCfIXJJZz/VrohCzpANuxF4frKWaRL/yYuKA== 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=b7EfrB5X37dWayq88Eqa9sWYIr4qXtfB/GbQvvDZmaU=; b=rSljUR5vEaVPbTWZ/4tYdAXpq28UhJX290e0vez6TQCjGcTwFGE+gOc2gV8bWbPyMJ/XS8sk/NS6ZJwsgHFKAN6AY8G08p5MenVGQ7sdxQ5/xqW+JrTdZJ5Hrsm7cgM5DDUhXYsqfhPsnB8djguvR81xljDcMXFwklSrw8oRFb92/o7TovbEZR++IfYaWPLJ7jStX61vVlww5risI2366iRC/g4NKVl1guD6eXvJ1FAXMnwb73mwwTWtdtIU3w5DnpHXepjnHjiLf6hQKvraJXoBY6kOi8ymmEPN2pG09A5R4M7STRLruVwvqAzWjRwbieD32PuPVEBYujm0XnhKTw== 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=b7EfrB5X37dWayq88Eqa9sWYIr4qXtfB/GbQvvDZmaU=; b=lpZaEYIVc2gJjpwA8Ul+IDzVkFgldXcTPaXzurpgeIMlv9Ih+IvtlYwr7Z0WG5w+M9xw2u+qaaVPzeYkzoIeTjIOT3IQt3Wq+kzjrBDVDthzy5uG5a09d2RStbbtsFHAlzF0vUeSNn64NWrH9qUC4r4grJ1j89av47ygxH/7lDvDzEY568StPdPQb/n25kr3DPSHiIom6iOu0/e+aouUYzVFaBGQlj4qGv6Kq45hNahrjIyU86V3wSlgj30ivAxKzoThCds5sFlrSQpZG0lG83qNPAU+MlPAC//95wmnI6Sex1MP05O+II8H/nNNl52vse9WyPUb4VZaLiAOhhx3ow== Received: from AS9PR06CA0752.eurprd06.prod.outlook.com (2603:10a6:20b:484::7) by DBBPR07MB7675.eurprd07.prod.outlook.com (2603:10a6:10:1e8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.496.21; Mon, 12 Oct 2026 11:53:42 +0000 Received: from DB3PEPF0000885D.eurprd02.prod.outlook.com (2603:10a6:20b:484:cafe::a3) by AS9PR06CA0752.outlook.office365.com (2603:10a6:20b:484::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Mon, 12 Oct 2026 11:53:42 +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 DB3PEPF0000885D.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.6 via Frontend Transport; Mon, 12 Oct 2026 11:53:41 +0000 Received: from seroius18815.sero.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Mon, 12 Oct 2026 13:53:41 +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 4809C4020E5F; Mon, 12 Oct 2026 13:53:24 +0200 (CEST) Received: by seroius08462.sero.gic.ericsson.se (Postfix, from userid 160155) id 17C46700E7CC; Mon, 12 Oct 2026 13:53:24 +0200 (CEST) From: To: CC: , , Daniel Turull Subject: [PATCH v5 1/3] classes/base: exclude __CACHED_SOURCE_DATE_EPOCH from task hash Date: Mon, 12 Oct 2026 13:53:17 +0200 Message-ID: <20261012115319.1704048-2-daniel.turull@ericsson.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261012115319.1704048-1-daniel.turull@ericsson.com> References: <20261012115319.1704048-1-daniel.turull@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB3PEPF0000885D:EE_|DBBPR07MB7675:EE_ X-MS-Office365-Filtering-Correlation-Id: d2398daa-4a93-4c5f-d352-08df28577639 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|376014|1800799024|23010399003|82310400026|36860700016|56012099006|11063799006|261009223027099003|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: zeCfVdWDtd3FXFIEhDsdqljxyW3C23UxHev5laAJGUUxxNoXE3pWVqKxMb2197SQ10T57VPfiOdyvnikJNuF0xMtBJ7Sl7MgnR1qyxQcgpAPlfpz3ZwcIaDZUE/ntNEBUdfEhRVhMq4eJzB5bMYxLrUgYcBSTqCfaUYROi++JEgPjT5O0gtQK7AmrekJ7HIgoMujrHtfprWKjo6EOBwCPpQTQzvWjMspmU+BXDAywrJ9xEI2NFh6aeiXVppk/YiAGjAN9qm9GblgjMF086bvtk0AbsGFGDPnjS4wFe0vcDC1lnYsR0Ak8P3DaY59tIEiLq1/pKIsihgBoJ12Oa/ConA02GcM6BSzpTTyvKszJHFXJWp0no5mSdXYqm7hxiJC5iCZrMzsquXWjhyjn0kz4e4rK2XlalrWXv6EYnEf/A6RVi3kkbXpMND7n1fZPfZwTwfFadppOXodz9cXdU8chKCOxrK64Qt1lmsmTMktvr/t/eRlrZQg3QO4zJKOS8J0yk6HURH1r9fhkf3KFvB4DMs1jPGQzgW9D6yfUsPuy9x30v/OO2FeejqWEE+Xl/17qcSQdDWxvzsVat9/003oABtA1/ugt/H8/Io+Gv/crJClJZWtxZU8FAIsuCb6oS0kKUUpARlV1I17m/TCzFKmXX3p4oVDecjxiPiu+HOtURego1St0MQELVbx9ZQa3CAggaVWkwlh5Sb2FJSRuPK6RA== 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)(376014)(1800799024)(23010399003)(82310400026)(36860700016)(56012099006)(11063799006)(261009223027099003)(10067099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2lB8K/fAg2eLX9kYBUKE2x/FTphjxAd+WiqwmhlS2l+uBZauVBK66q3IJNWuqxj5Dc7blVQU8QiktGILkGzcJJRMAYkFuMWH8YZvZoLDMcCK482/lhM7MGt63jXnIxDzS6XhJauMLXZ/0Dx+/jTgPnbdzXBm/MRF33+O/PCWRWFEGeEF5dek3xF5mwA2Z+qt2IcViOnDleD8UH68OwVQLyyY5KZI9em6N/nWTVy6e9Mk2EBhIeTIAh7c4tHQG/tLmcIsJOP2bwXVkRy0Sq66rI1kiLrDUZWHSqiwNY/a2Bd6zdL5jOcicVGJeSmR3Kx2jByiVSRKiGmEl4//Z+161C+KJ3d+HY5GseURnNpVBcSGe/T3rLCL8C8cIBJiWj1mZfqWdH43oZWTZNa2JS0jytYvHlo2oGqcnu0pEEVnBl10kD/AC5m3eaaSDstkCpXh X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2026 11:53:41.9839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2398daa-4a93-4c5f-d352-08df28577639 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: DB3PEPF0000885D.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7675 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 ; Mon, 12 Oct 2026 11:53:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/247642 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. AI-Generated: Uses Kiro with Claude Sonnet 5 Signed-off-by: Daniel Turull --- This should fix the selftest errors reported by Mathieu --- meta/classes-global/base.bbclass | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index 9553f00432..01a030399e 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass @@ -249,6 +249,10 @@ do_unpack[postfuncs] += "create_source_date_epoch_stamp" def get_source_date_epoch_value(d): return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d) +# epochfile_read() memoizes into this variable via d.setVar(), so its +# runtime value must not leak into any task's hash. +oe.reproducible.epochfile_read[vardepsexclude] = "__CACHED_SOURCE_DATE_EPOCH" + def get_layers_branch_rev(d): revisions = oe.buildcfg.get_layer_revisions(d) layers_branch_rev = ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions] From patchwork Mon Oct 12 11:53:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Turull X-Patchwork-Id: 100443 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 2A741CA9EC5 for ; Mon, 12 Oct 2026 11:53:43 +0000 (UTC) Received: from DU2PR03CU002.outbound.protection.outlook.com (DU2PR03CU002.outbound.protection.outlook.com [52.101.65.49]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.11390.1791806015376689585 for ; Mon, 12 Oct 2026 04:53:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@ericsson.com header.s=selector2 header.b=YiioSMOm; spf=pass (domain: ericsson.com, ip: 52.101.65.49, mailfrom: edaturu@ericsson.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gOC02f37a1yrA5PQ7OeBLNXEDX8HOssEcQXRyzWqIH6SSlaNOZapIF8+BTkhYkcDvTaD3DIMl/eGzGUn7QY8PTEqmLRI1XtbAaWQSvXVva5ShsOPn5rldE/0VNzQ//ESzJzI0VlIJD2l7KJtCSNNma6omfLgg6/6aDWieC8EST91FEAiHMt6RDMxqKgUFN2kTOBIvYr6H0veZ8BUan7s+2VwPwjj9QGcMXbzRkdbyQTXpLmWqsdBx4eV5Ye9PWEo51Ejnk/h+nndh5me0YvXN9XlDr7tyRU5jQLixwB4f0Sn+/dlIlRbkm8ACMWcmOzk3j7cNAUqsFjgyXCd0VN/wA== 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=rgGr3sE/EbwLWVvrRfehVlTsRBpiC4pkm7uYxNlTp9o=; b=n5rX1FaTOpS03B5Dml5ZpfCVjNLXYd/92zPUA3dUX406lhrbJDGAZ7F3Cu9HqlBywI91UqWnHvZBxR5FhGlR3SMyRFR9mxjD6S2JCrgMVBC4ohUSvBR21+3gEB0TaU+a5DhfcPDYof2LwyrfjpIvNZnq5Th9aONK/DID66cxtZhITg3i9mDWZuDJ9CThZO4TaZK347dnBIePcKCH9rwLl9P2Y8XDXnbE8gm5Bq/ALfEy8xDu33ZOGHWZHVqGU9GJCrAZo+u91VP4SBrgDtjh1Y8BXP8X/DVrNlPPGSgiNZm/3WOr962520n59McJ2OMHfFGii+u29r91GyZUfB/9rQ== 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=rgGr3sE/EbwLWVvrRfehVlTsRBpiC4pkm7uYxNlTp9o=; b=YiioSMOmfl3FnpHpx1ONsZ+CXqVvVLmLl5O2NzwBKGyHH+ELWXthVHiXuVLPcCKVArpbnZOhm6anOkEAiFXzVfTxOy6Cs3Aldq6Ldsk2vyQ2yKdw5kL9p/eKqeeaAR97ZKEQPaQUENVTOCVg+uw/OSnS316+KD84EpArLpIGHHvEHVkd2AIluvLDnq5x/iUE1/W0Av8kC/8xxAMAAXkXsTihiLdmTwhfShxFvok2MlDlbfITvFJWGR6xNyZk+B/SeyXmiFc4kVv7HnlHN8m3i9KI8+g6gvULO/qPusGgE5WGQkyUVD9s5i2vJTeS377FSkIZ6xEJXjXgrjlOomMiBQ== Received: from AM0PR10CA0010.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::20) by PA4PR07MB7327.eurprd07.prod.outlook.com (2603:10a6:102:f6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.496.23; Mon, 12 Oct 2026 11:53:30 +0000 Received: from AMS1EPF00000094.eurprd05.prod.outlook.com (2603:10a6:208:17c:cafe::4) by AM0PR10CA0010.outlook.office365.com (2603:10a6:208:17c::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Mon, 12 Oct 2026 11:53:29 +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 AMS1EPF00000094.mail.protection.outlook.com (10.167.242.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.6 via Frontend Transport; Mon, 12 Oct 2026 11:53:29 +0000 Received: from seroius18814.sero.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Mon, 12 Oct 2026 13:53:29 +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 4739D4020C1E; Mon, 12 Oct 2026 13:53:24 +0200 (CEST) Received: by seroius08462.sero.gic.ericsson.se (Postfix, from userid 160155) id 1803A7003EA9; Mon, 12 Oct 2026 13:53:24 +0200 (CEST) From: To: CC: , , Daniel Turull Subject: [PATCH v5 2/3] create-spdx-3.0: record component release date in SPDX output Date: Mon, 12 Oct 2026 13:53:18 +0200 Message-ID: <20261012115319.1704048-3-daniel.turull@ericsson.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261012115319.1704048-1-daniel.turull@ericsson.com> References: <20261012115319.1704048-1-daniel.turull@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF00000094:EE_|PA4PR07MB7327:EE_ X-MS-Office365-Filtering-Correlation-Id: 99f3a2a1-c931-43d1-c4ca-08df28576eea 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|376014|82310400026|36860700016|1800799024|23010399003|11063799006|56012099006|18002099003|22082099003|260925022911599003|260925021311599003|260925021911599003|261009223027099003|3023799007|10067099003; X-Microsoft-Antispam-Message-Info: 2OmTndjDJmATyWSisKIA9k5kJ8w//IYXK8kpEgsUsGshd1UDWwC5U34ifhWl7R9PLwoP0D+5B/ReIhbSSKGejjtjCTjOwRiXGtztCicrOrdew25BLLjLjJeJn3vwnIuKXV/eEhne5eiyw7P/EXpjUopWmKRPZnc5AXB6MDPirTZdTV2zQYFBdYBuvuhiZfZbjG1MOe27y9myZaqzsafGRp25sBG0FhYHj/uRs0NYyYkY1AFCpXPCSeMXcysf9KDtJLEQ0ixCkeC4XcgRDwIioeo3HzrM28Pp8T2vszLjmpOxZ4I+AVFqkjtxVYozcInPVrW0MzW2uUVVFESIh6AxJRoXPEemDtg2W0EBEjBtC6kcKXRteCOHyhCFb09pZVhXYJ2yEPqmdYJCqb8R+xVHIf++QgCr9eLQUK7hHvx0WZyO05bDTmR7QCY/7TlM0MNwAqXh+tm+1XCb3/5aidPncv1z2nheIKwXKxwVv4ZJMO6UHd+/j9vI0YJtNPROe+abQ3kpMkqDs/1PIMq3aWc7MQnESh4IuGOgPNSYPN2IhHi70fAdo8js+mvlrmSx6QjNJqUHbHvp8160FPXurUFy9ZeLIN4aa86hOwoHXaaZgfqcXi+tVeEPA6iV4Reip4c+rtirfdg8Nn9bjANCTo8zuPUylEVmPZlGXVtX/PnwKMnnls6Pv+mPJzv+W2EG3zzy5ymkSULoxsG5qjZzeLr9DA== 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)(376014)(82310400026)(36860700016)(1800799024)(23010399003)(11063799006)(56012099006)(18002099003)(22082099003)(260925022911599003)(260925021311599003)(260925021911599003)(261009223027099003)(3023799007)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PnbFgbwHWzYnk9qdMq5dJGSNs+u/fYbgWFAVLDc+67VJ+H2b8Wb4kkCbVx5jvvE38A7YL/fhs8gEIeyK07bUux2g4+lUdnGwE6+M1GD9ODLzvzfNh7yJR7K1/aUUNVpGb5H2P3WQqqFzMeJHIwVEJb4Rfi6YGV+E4ioUCp0Lrz/IgjOYHMp5GeAsNG7q8nwsPWyvWBQaxn7PLM2ROhNOoY/fVIvY1c5TP5/iAISygmGV7XkorKa2CIMM/nfCHwmPbeUBz0LWHjKZFcvAk4dSotYf5O8S+waggoQfVkt5BL7c1WykaEEWDnUIhTa1SWfIMu2QrwFn/E17xgjDOM6QEHIMGMSo1+zAxIz+Xxtoq0OHtuPAt1mSP1H/d/xcOTJUL5B/6KL3fhV0dPRvsHYF2z3WjYNu7Odh3k9zS4xxNaN3qNgI9gWNutvxVVIpZaX1 X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2026 11:53:29.7439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99f3a2a1-c931-43d1-c4ca-08df28576eea 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: AMS1EPF00000094.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB7327 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 ; Mon, 12 Oct 2026 11:53:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/247641 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 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. Reported-by: Mathieu Dubois-Briand 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. --- meta/lib/oe/spdx30_tasks.py | 22 ++++++++++++++ meta/lib/oeqa/selftest/cases/spdx.py | 44 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py index b6456a214a..dc82f21fb0 100644 --- a/meta/lib/oe/spdx30_tasks.py +++ b/meta/lib/oe/spdx30_tasks.py @@ -36,6 +36,24 @@ 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. + + Uses SOURCE_DATE_EPOCH, which by this point (do_create_spdx runs after + do_unpack and do_deploy_source_date_epoch) reflects the source mtimes. + 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 = d.getVar("SOURCE_DATE_EPOCH") + 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 +459,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 +523,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..fb1176fe66 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,46 @@ 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 SOURCE_DATE_EPOCH. + + 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. + """ + # base-files has S == UNPACKDIR and never gets a real + # SOURCE_DATE_EPOCH, so use tar, which unpacks a real tarball. + objset = self.check_recipe_spdx( + "tar", + "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/builds/build-tar.spdx.json", + ) + + # With all tasks restored from sstate do_unpack never runs, leaving + # SDE_FILE missing and SOURCE_DATE_EPOCH at its fallback value. + bitbake("tar -c unpack -f") + source_date_epoch = get_bb_var("SOURCE_DATE_EPOCH", "tar") + 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 Mon Oct 12 11:53:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Turull X-Patchwork-Id: 100442 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 3FD29CA9EC5 for ; Mon, 12 Oct 2026 11:53:33 +0000 (UTC) Received: from DB3PR0202CU003.outbound.protection.outlook.com (DB3PR0202CU003.outbound.protection.outlook.com [52.101.84.24]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11538.1791806012376605880 for ; Mon, 12 Oct 2026 04:53:32 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@ericsson.com header.s=selector2 header.b=He/Y1LK7; spf=pass (domain: ericsson.com, ip: 52.101.84.24, mailfrom: edaturu@ericsson.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A8q72DbhfN9Sag8ubk0t3nNWOTN4FWfsztObbdr16q139D77N8XJ47ZVlrHLdEiywXu4ukwzVNBCvn+vcKnd9SzIps88ZDkc72NG1nYlBXRV8G+1R2Qbh99A5hsqrkUmQrtEQkkAgTHoZdB9CW3iZxPoqkth9ACXrZytOvSomXU6o8Q9Fli5tQiFQXOONgm9fNqQ8ykFSIj0SMG6RcPlU500yu4+mQURpWbT0Nf/IW4gX8iMk4rWDx97umSC/0jwJOgfLa5lKSZkafTe7WUfT56MHo+/f5FG+jv1Q+WOCzdWBztQqxw7pBp/2MIqJqhJPFrEAbUo4gsFow6hftIVGw== 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=KldMJ3my+OMj30vM3v6MVCfiWYBfzwdnmI3qgv63/CPsh8bO6QXbrpRk+rBcf0sNFMrZ9va5+gGMJoalpYKtN+dfRGApn6uj4Q6YpPHa39DTey+kTbU3Zn1rWJ/p1PZDp4gCP/Kfy72ruCk5V3DstZta3Ru7jA9pOYiox0rLjtd5gENhENTqyv787RqWzi/splxp2AS5qUPsmdvyZLvJCRekKvFHe6q18223uq6rAWDxRV3ctagGfqvWDkMeKKvdVuRngh2Q/6Zgh5hpeyx/P0cm5VCFaQqWragvXWx/x7Vd5MHHaHYAf0Iw6xx8u9uf2mqkiQis4bgLU/+rF4n7BA== 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=He/Y1LK7Xyuq89fDaFL9KAoNX/3nbMQBomFunuloffuOzWbNVNA01Mlz6G+OvOaLQ7shn9WiBYM5/Hr3G0scNs9XRKzOlJyJRhc9KNla2TM6AVpCG1Zo+uZeKMoByiY6F3upMoAZ4bBnWFSfKxB/EuhnKA3VFtO3wMIhcIXE6oxjGwmBy/GUcRkbaXhriY70Rl51LiXeiCGcAHThxPTzPiQ1ZHn74EIxwWRR4UPnVKz5dhj6GtrlRijA38CmeOtfNiQjG7RXY4nYo+r/HFOOJm74oMUhk8UwYev3SpICSNEbcTPAt/dFvrMRSFDOfmkd/1g7dVleU+kJwveu2zTGcw== Received: from AM0PR02CA0156.eurprd02.prod.outlook.com (2603:10a6:20b:28d::23) by PA1PR07MB11903.eurprd07.prod.outlook.com (2603:10a6:102:562::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.496.21; Mon, 12 Oct 2026 11:53:27 +0000 Received: from AMS1EPF0000008F.eurprd05.prod.outlook.com (2603:10a6:20b:28d:cafe::89) by AM0PR02CA0156.outlook.office365.com (2603:10a6:20b:28d::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Mon, 12 Oct 2026 11:53:27 +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 AMS1EPF0000008F.mail.protection.outlook.com (10.167.242.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; Mon, 12 Oct 2026 11:53:26 +0000 Received: from seroius18813.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; Mon, 12 Oct 2026 13:53:26 +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 4813C95808; Mon, 12 Oct 2026 13:53:24 +0200 (CEST) Received: by seroius08462.sero.gic.ericsson.se (Postfix, from userid 160155) id 1BC73700396D; Mon, 12 Oct 2026 13:53:24 +0200 (CEST) From: To: CC: , , Daniel Turull Subject: [PATCH v5 3/3] scripts/contrib: add spdx-release-date-report.py Date: Mon, 12 Oct 2026 13:53:19 +0200 Message-ID: <20261012115319.1704048-4-daniel.turull@ericsson.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261012115319.1704048-1-daniel.turull@ericsson.com> References: <20261012115319.1704048-1-daniel.turull@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF0000008F:EE_|PA1PR07MB11903:EE_ X-MS-Office365-Filtering-Correlation-Id: 26421375-e9c6-4ad9-f86d-08df28576d2f 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|376014|1800799024|82310400026|36860700016|23010399003|56012099006|11063799006|261009223027099003|260925021311599003|260925021911599003|260925022911599003|10067099003|18002099003|22082099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: e7icZLewdSd89rgIA6kb/lOkhp625+ikf6LkhXnwK0UykCWu36jE/c83JBZ6V22VbPT/gBydOv2ynzVDWnPdxAGn1LcqQcZAtsZoBdf5mPx8CnUGXNImyoBGh1bCdnYsoYWSy4MZrohIZoxi1A2JrHR+tHTmdtCvQaNYCKXLWi+zlFQBjF6++rxGnamXIsPhIB2lYV7UsPJeqoOgV38qappUDeaLVnOdl83OqYkvWmebbN/iGFaMX/3I8B+3zzCV/DJfwA+aLm9YHXDgmsX/McNyroEV6E/TPoQbtMMWu2Usyy/hUl2d9nSIohxGfoVhOZSeNrOkIIB+yEK7a9Y5O/cXqPkCBisEqbTMDOJilMh/fljzaIXH8foXKopal+BaD34WaXbihCDZDZdDY103hZvi0uJgdxjsoV5zt5AfOFOkyppPslVFmJIYgyocD9RL5xQX8kwRjH9wKN9TJL8shtRqgX08m5yTuAQipFWejU6mUe0/YuZQsnFKRm1W29qXMj6k+AiySqRRn1WJkdtL63gWmbbmPHLbTL3jQ/JAx/qdmZXn7pzXAOausDkl3iRWdEfEL4bdV5yBILcb2/4VZT7PPF9oDHld+OJQgKLxHxCrDkrph+0iqUodTjmFdEp3zOzUXb/WkPOmEZhIkO1Yuc+cnRFigulohu9W86+KEINl4cg5ijlC13sCNsvsNlJmyryLUjFwv+rC8YGJaV8zBQ== 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)(376014)(1800799024)(82310400026)(36860700016)(23010399003)(56012099006)(11063799006)(261009223027099003)(260925021311599003)(260925021911599003)(260925022911599003)(10067099003)(18002099003)(22082099003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z+39owJIf31Wpj2fYwS2v225CM5riaL+VNoTCNEvvoMdHT766FLt9I6X8I2FKJBB3i5Elm9s3cXwNS8B9Z62i5EYQuvs+DHliJcHWVP80pO4YC7P4V7qA3kiaNG9JtTP4PXbnpsCoU5zRqHXsxRwtMo2W8m26Fuw0OUB8oCzYBLwZj3z07EPkT6IatJMLBD4+bNUiTZ7d2CpiB7h5rYexQrZ5rvVasQp6eVggaFh6+aPcNNZrdoSjZlbjAvlof+0Hq6/p55x0moA22X6U3qZgOv1QmzIsXSFDQ90OxeLQcSlYacSmfmHYrb8s9NJMJBQqDjc8DnowQIfX+tLZAUVJJZqPp8KhIPrg7v5ASU+47HOlRg7JefjbvWZXtBPIJZsgtNqJRrCATvEGwIDxS8ohsgoWnfukrpup4aLu0MoxIev/6XtJ3SLv8q7hNVasmPw X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2026 11:53:26.8412 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26421375-e9c6-4ad9-f86d-08df28576d2f 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: AMS1EPF0000008F.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR07MB11903 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 ; Mon, 12 Oct 2026 11:53:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/247639 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())