From patchwork Mon Nov 30 20:40:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 106594 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.41739.1796071233125536039 for ; Mon, 30 Nov 2026 12:40:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@pengutronix.de header.s=20260414 header.b=VM5nCW5k; 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 4FD4E205AB0; Mon, 30 Nov 2026 21:40:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796071226; 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=VM5nCW5ksSfrTzWdjsGLTBwYt+rP4C0XxZu7LgcEblo1sDItnx9lw7QxkoyfQ5AjTHxDiI yItpwUx5PuiAzy1Yi0SG+zpOE7FoEVHnzaUZ4h/HwQ0AvCpGa1Ac2j0zhOTTG8zu9OrUrI +jxhXRl/E+E+21z1RcBRoGukodItPpjhtzWffz0mmbQ1iJgfzdJT1l3+KfpsFuRYF3u3Rk +qGYclBF24BnB0JgITiZtHyjSf5TWOYO00sY2KYv85vpAILoIniybrJ/OJRzTLDJnak+bb r5EvBYs3iEO1+L3zUl0B96TdI+sAyyFnz+dgELPfdIY7iBjGSvkD91XrBHv3iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796071226; 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=BzQI60S29rOmRxHBytY3KNOrASjXyptOAsoMZ4K0mtLMQSCqN+rIuFCpoPq7X+tdhOOXVO c5omg42eQzTV+s1XNMnedLNxVJDlE5eGg2VrEUH0gRJtzY2rRiH1Igswec5Fki9e1zuQoZ aNZSkEBcnnjT6ZlwJrgYUYyTVybyhrEz1wC9iQUpEWmNkuJnzH/1d4HUmdCcY8kLhwbnqk bGk3nPvc1EDDYWmue7Aqvgrsd1kZSxHLibHzNinu897X3yRzqiRuEIDNzZw7cZTTnkxtkD XjlKBCQf02J+r57i3JajZ6rojROh7PRGgXBuA78ECACHDy3XL77pzsJTHNSRPQ== 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=1796071226; a=rsa-sha256; cv=none; b=feEb/8RlEIRRJ/GUo2yJvDiKOsYOvJruwz8rXpURnoisB8wz8BE7X4bkDVgrOyWkOk5VRo xwRKA1Yg/iUfY7g13jvej74T1hmK5G4CZ+aOk/+BBrJmm4RoDMGR1exoDYRTW3nedePqkK fopfexjQHCIxmshZntdMDNfibpDKvGfTUqcJMOsyneG6hjWMlwYdW9RM6X7jQ8UuoHanjO 7CRqve8qgxiFNkQ0+A1w/rXFHpewdTkSHWo7U1u6QTTH+IbBtkl3Kgi2PY9Fn1F9DfSpvm xcxZ/yWqgpascTxQxiCuk0XtuZu4YmaEa6aLnxSGE78UmupzQhiz5+jQPbiYNA== Received: from dude06.red.stw.pengutronix.de (localhost [IPv6:::1]) by dude06.red.stw.pengutronix.de (Postfix) with ESMTP id 33546640E5E; Mon, 30 Nov 2026 21:40:26 +0100 (CET) From: Marco Felsch Date: Mon, 30 Nov 2026 21:40:26 +0100 Subject: [PATCH v4 2/3] classes/cargo-update-recipe-crates: support v1 Cargo.lock format MIME-Version: 1.0 Message-Id: <20261130-mfe-multi-cargo-lock-files-v4-2-a3ebce5cc283@pengutronix.de> References: <20261130-mfe-multi-cargo-lock-files-v4-0-a3ebce5cc283@pengutronix.de> In-Reply-To: <20261130-mfe-multi-cargo-lock-files-v4-0-a3ebce5cc283@pengutronix.de> To: openembedded-core@lists.openembedded.org Cc: peter.kjellerstedt@axis.com, paul@pbarker.dev, 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 ; Mon, 30 Nov 2026 20:40:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251648 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