From patchwork Tue Dec 1 16:21:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 106842 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.15126.1796142089393920727 for ; Tue, 01 Dec 2026 08:21:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@pengutronix.de header.s=20260414 header.b=J8ugkbCO; spf=pass (domain: pengutronix.de, ip: 185.203.200.13, mailfrom: m.felsch@pengutronix.de) Received: from dude06.red.stw.pengutronix.de (dude06.red.stw.pengutronix.de [IPv6:2a0a:edc0:0:1101:1d::5c]) (Authenticated sender: relay-from-dude06.red.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id AB79F2029FF; Tue, 01 Dec 2026 17:21:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796142082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owSznV8oZIrc1ErHtALiiDJ6ivGsqJttT31tvUrsF9w=; b=J8ugkbCOjzC+yGvQpf3hXJDyOoSEpbdZuPFV+Oyp5k6vFHdOQ5G0b35uha1QBN+JwWxsDi m9ML77aYsswpIQTp9bxfdwR0RwdVJIyBc4+RAMl/87exRUXy8ZszFk5uhD4SOF0E+HxwDc R3ZIXOAWV332ZFu2arWIJpJAQDH8oDTiLRbVi/84aEBhX5q935zLcWcwmEpOQFsHADtTOT yLjNadOvqzQLvSAQVBi8JtBljk5TMnskl3X8zm2x/l0VERfOzHwzgdtpO6Ys4Gyug2mnVJ kWpJf+SLTsLwVujegq2Z3INzMDcE8aAkZHenYCp5R3jd2mqupRUdv/jHcbEGpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796142082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owSznV8oZIrc1ErHtALiiDJ6ivGsqJttT31tvUrsF9w=; b=SiPnimlXyWrCn2zyT8nZKnJRToqa+kznp18eSKgYCXqPA1ApIKUTLaR4hfwjd07Q8cHC8K TWUTgbn5+bIQMhvBi2SbaewZWU+mbrNv8Uvzfv/IHj+fG6zvkoU6z2KCU+Su+NoMYOR/A9 GBt0qFGYS7cwh2/CEYYeKmko7dB4vm+bkBtbDK2IPHuZMafgZ59TtmjxjsOTgZiTS5MLQJ bJ8+QU0Xh7KVoXUOErEyBftKWlEavsV/U3ehnXfVHHFDEEWbE5zF6xwrMNbPx676F5rcaU ItApDb/ZAhjnToBPibcnB2KT90WYI/49vwpLf3G5nSYgxAL/Vs5Uqk6SzxLd/Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=relay-from-dude06.red.stw.pengutronix.de smtp.mailfrom=m.felsch@pengutronix.de ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796142082; a=rsa-sha256; cv=none; b=UIq56NZXz4rGpVNXybq81SxbfEqv6RilG8QCnUOqQthDIoQdRlgE17siOsZprRo8Y7GKD3 bIryr9ehthleN9bNz30fg98ZlFBGngW2sxnBqe0XYeKB/7uOjQxwmcDEOLeM+CwMhCwqJ4 e+OAnMQX2tc8s1c2nQpKtDkygOUUHdKAvp7WiScwTHxl8Z28Y/d7W6YKFbPpwxn7oNlFFr J/xEY99id/SXNkomn+3udJnNFSe+tc6E7ivZhWh0Fx5mLuJFtW6hXGtp/45IHVdM8Y6T8o Pz5knT6tuOD8be/3CKXjYwD2Rs6f1idsq5Ax13MWPqCd5IuTI3lM/Emhf7boag== Received: from dude06.red.stw.pengutronix.de (localhost [IPv6:::1]) by dude06.red.stw.pengutronix.de (Postfix) with ESMTP id 991BB64174C; Tue, 01 Dec 2026 17:21:22 +0100 (CET) From: Marco Felsch Date: Tue, 01 Dec 2026 17:21:17 +0100 Subject: [PATCH v5 2/4] classes/cargo-update-recipe-crates: support v1 Cargo.lock format MIME-Version: 1.0 Message-Id: <20261201-mfe-multi-cargo-lock-files-v5-2-6c4eae24ec27@pengutronix.de> References: <20261201-mfe-multi-cargo-lock-files-v5-0-6c4eae24ec27@pengutronix.de> In-Reply-To: <20261201-mfe-multi-cargo-lock-files-v5-0-6c4eae24ec27@pengutronix.de> To: openembedded-core@lists.openembedded.org Cc: peter.kjellerstedt@axis.com, paul@pbarker.dev, antoine.lubineau@tld-robotics.com, yocto@pengutronix.de, Marco Felsch X-Mailer: b4 0.14.2 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Tue, 01 Dec 2026 16:21:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251754 Cargo.lock files in the old v1 format don't store a checksum per [[package]] but collect them in the [metadata] table as "checksum ()" = "". do_update_crates only read the per-package field, so it emitted crate:// entries without SRC_URI[...sha256sum] for such lockfiles. Fall back to the [metadata] checksums and skip "" entries used for e.g. git sources. Signed-off-by: Marco Felsch --- .../cargo-update-recipe-crates.bbclass | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index d4318bc9f5749503cb7995927e2e54b9771a6b75..9f92f0a522979fde8f0b88abdefb9a03c0c651ee 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass @@ -9,6 +9,10 @@ ## This class is used to update the list of crates in SRC_URI ## by reading Cargo.lock in the source tree. ## +## Both the current Cargo.lock format (checksum stored per [[package]]) +## and the old v1 format (checksums stored in the [metadata] table as +## "checksum ()" checksum-val) are supported. +## ## See meta/recipes-devtools/python/python3-bcrypt_*.bb for an example ## ## To perform the update: bitbake -c update_crates recipe-name @@ -25,6 +29,25 @@ CARGO_LOCK_SRC_DIR ??= "${S}" python do_update_crates() { cargo_lock_src_dir = d.getVar("CARGO_LOCK_SRC_DIR") + def get_legacy_checksums(crates, filename): + # Old (v1) Cargo.lock files do not carry a 'checksum' field per + # [[package]]; instead they are collected in the [metadata] table: + # "checksum ()" = "" + # Packages without a checksum (e.g. git sources) use "". + checksums = {} + for key, value in crates.get('metadata', {}).items(): + if not key.startswith('checksum '): + continue + parts = key.split(' ', 3) + if len(parts) != 4 or not (parts[3].startswith('(') and parts[3].endswith(')')): + bb.warn("Unable to parse metadata entry '%s' in %s" % (key, filename)) + continue + name, version, source = parts[1], parts[2], parts[3][1:-1] + if value == '': + continue + checksums[(name, version, source)] = value + return checksums + def get_crates(filename): try: import tomllib @@ -36,6 +59,8 @@ python do_update_crates() { with open(filename, 'rb') as fp: crates = tomllib.load(fp) + legacy_checksums = get_legacy_checksums(crates, filename) + # Build a list with crates info that have crates.io in the source crates_candidates = list(filter(lambda c: 'crates.io' in c.get('source', ''), crates['package'])) @@ -48,9 +73,12 @@ python do_update_crates() { cksum_list = '' for c in crates_candidates: rename = "%s-%s" % (c['name'], c['version']) + checksum = c.get('checksum') + if checksum is None: + checksum = legacy_checksums.get((c['name'], c['version'], c['source'])) c_list += '\n crate://crates.io/%s/%s \\' % (c['name'], c['version']) - if 'checksum' in c: - cksum_list += '\nSRC_URI[%s.sha256sum] = "%s"' % (rename, c['checksum']) + if checksum is not None: + cksum_list += '\nSRC_URI[%s.sha256sum] = "%s"' % (rename, checksum) c_list += '\n"\n' c_list += cksum_list