From patchwork Tue Dec 1 16:21:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 106844 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.14700.1796142089397611533 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=CK/z0qEU; 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.4.pengutronix.de [10.17.1.27]) (Authenticated sender: relay-from-dude06.red.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id B055C2058FB; 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=bmwrFt3+2ZcEhyDiDSwEditFN9OS2xDDQzvI6wV6Wns=; b=CK/z0qEUC8XekmBmyqEVOZh4DSjUOoo+25TwLIjm0wYH0F+L/Q9FUv8n6ZDh91Un/xO7hC xzRZfca7zyQMcyOL3yRqAkpEMQSu0PYJTyTDxUSaNiIFjPi+w+jUMUrZCQJepPxOOQjTgo c4oNxjDLxVqh/CLbKkNN3RxMgKn2d+x/n7VSEz/cP3DCRIpwp4RQ0+DGt37+bFmWHb2VMc A8XnSas+ppUnftmmMCLUukT1D+p4sq/++lO75c9IcsizrxM2ck7FBXLQpi+s9Vi/LbKXlt imIJd4vwYlg0gLxOYCuyLUS5xF045rvFmDTe+4XBj2rh0H1bewabe/uiAwqZiA== 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=bmwrFt3+2ZcEhyDiDSwEditFN9OS2xDDQzvI6wV6Wns=; b=E6eIHJSm+JB5prBeMySg/S6y+MD3XwRERGSYR1J+RUu4uNa6KxxgbNmiUTl6g6zAiKNWWH rDR0YUxqyLki0IxfwTSN7sQ0RyZxzXCiAEnIkKpHOY2B0eZMxQA77O4HjsB6Duip7oYqd6 oOS2qdEgoSb0zsUkqbIrf9KE+OGe14+6HzLBDqwHGPW8i4Iy76ZOgZjNDl7MJ+nd0nWUi2 +YtCbOQ9HWsF0ChVUU+o3U+Ha4Trd2e/NFJT9vwXw2RPVUhJNZySgTN5zYG9TnYVFUpIjx QPuyQgFXVZ38DIbImGWYeojZM/9XLAMB/pWAud7hcgdV+o7OQkdZOnr5i8mATg== 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=TJsEaYt5yfmodYOrWw7b5QEz+Oa+qQzIlG0b8mt2NEsRP6ctrQUnMZG+FITUEnp9TEkEpw Z57T7/dfstlXklqWGHRsq1R1nMu8tJpgUBf87gHX+Hvt1OL+a4Zq9FlcBgBHfKp6H5UBev wAgyulr3pZ/i/tG6nxsRhM6P34lbucKD28OHPrkMSrMISxlfWJbdKLYiTsHH9KZZJ7aL3M lhj5fq3L8Hg3tzkGrgQqa9yo9lB/CPHKNg9pznx0RpiRSv3Oi1Ir1GD7PSPijWH3ojWxYD QtnpYvJkLG49OgHHoCCJCdQcOpDANdaaTohoV/PScr2KnEJOxaR/rnIyuv15xg== Received: from dude06.red.stw.pengutronix.de (localhost [IPv6:::1]) by dude06.red.stw.pengutronix.de (Postfix) with ESMTP id 98BD1640A81; Tue, 01 Dec 2026 17:21:22 +0100 (CET) From: Marco Felsch Date: Tue, 01 Dec 2026 17:21:16 +0100 Subject: [PATCH v5 1/4] classes/cargo-update-recipe-crates: use bb.warn() instead of print() MIME-Version: 1.0 Message-Id: <20261201-mfe-multi-cargo-lock-files-v5-1-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/251756 The do_update_crates task is a regular python task since commit d56fb40b32c1 ("classes/cargo-update-recipe-crates: use tomllib directly"), so the print() output only ends up in the task log and is neither shown on the console nor counted in the warning summary. Make use of bb.warn() to fix this. Signed-off-by: Marco Felsch --- meta/classes-recipe/cargo-update-recipe-crates.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index 0767b566ee287d11dc2e1e6d0aeea0a0d3b225b8..d4318bc9f5749503cb7995927e2e54b9771a6b75 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass @@ -40,7 +40,7 @@ python do_update_crates() { crates_candidates = list(filter(lambda c: 'crates.io' in c.get('source', ''), crates['package'])) if not crates_candidates: - print("WARNING: Unable to find any candidate crates that use crates.io") + bb.warn("Unable to find any candidate crates that use crates.io") return None # Update crates uri and their checksum, to avoid name clashing on the checksum 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 From patchwork Tue Dec 1 16:21:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 106845 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.14698.1796142089386627553 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=HbTngzSR; 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 CA0F2205AD1; 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=sATJQ5vCrf4gJZSYep7Q7D7neM+rnB1t0v2/CP1DGTo=; b=HbTngzSRYYvJWnXtEzRh/GVi/EmFsp1VrQaDyD4ZqpSmknbjdcdCAqq+wIQ2+Y6zKUm7R6 ML8qfsVPrdZCUrBW1EdFzON91/1IeNrfjSzbOVGiIxj4abdC4nnW4yEwexHMZmLFjM82ka DDI984uXq54YjmZFai5rXvR09lP91RB8tcIfeejQ2RNYRWomDPv4kIrGW9P7atmZWl+RJN To55T0aQ8NIWfUt4Lb48bKxPKV1EjM+qTSB2pu801o2/Vec8aRcJKNuhj0eWAMz623fEAa oGfbJsfqgPRQsFhsuodwRPeqFY9c25lW/WFh+KxCn+C3cwD6gjwDbjSCaPkxqQ== 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=sATJQ5vCrf4gJZSYep7Q7D7neM+rnB1t0v2/CP1DGTo=; b=O+BPPfo2r34S1ETEipaCGg5aRkae9XqqcxJ67V9Bq78ZwFLLPO0SX7YEFNJYt6Gb0RhX4D YvxoCKSUEx0xDIpLmjl2BHLfiHDuukOHRNdTi7JWNnmPz8E4g6IkvFX3e7j0F9Wce4JGzL RtnlNi7SK/siatMnRZ7cHWJ1CjXHukmwNtsmlVFELxq+sdfoxgzg2Dg/M48JNpYSCCKH50 7j8y+1VfkdjXD0vKnKASf+iKuv1S2ZVKqHTx756YkQ1okjc0qL4XXOGu7YHHV4jcx+r9ka gWcERJFWHXi32A3ZEtA2r12w1u5dlbw1iIJ1luiy7IVbfEkZUs62xMLiFf9ctQ== 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=Awgjr3KvUY4EJLkdZKD3nT383eogaNktJQBgqV+TIF6jBWcaWLhrjqQIKN+Eb7fIjInxzz 684XONlpnZg5rng20PiqCck60E0+7tXViJ+IhiH0uit0KOinyQWCrk9odj6y90unbn+84G 2wEnHsU8VAgcWRJJaL7WYUnMRC5yL5Ogey1v0Ff+BOJq/k6K7A8aOhAFfzV9QSap2aWix8 la5G/n5TrOnIz4NXByuc5FRhUlBQAog8F9Xt+vA5rYfzrtopCZBm2m+d50tz16NLthRd1h EokEvvvFoIWlzjrSepKtwYfxy7Ls7WUwM9r5wAOGKLSeg2MGIGx5QFV1vHwh9g== Received: from dude06.red.stw.pengutronix.de (localhost [IPv6:::1]) by dude06.red.stw.pengutronix.de (Postfix) with ESMTP id 9970F6418D1; Tue, 01 Dec 2026 17:21:22 +0100 (CET) From: Marco Felsch Date: Tue, 01 Dec 2026 17:21:18 +0100 Subject: [PATCH v5 3/4] classes/cargo-update-recipe-crates: make Cargo.lock search order deterministic MIME-Version: 1.0 Message-Id: <20261201-mfe-multi-cargo-lock-files-v5-3-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/251757 os.walk() returns directory entries in filesystem order, so the order of the "# from ..." sections in the generated ${BPN}-crates.inc depends on the host the task runs on, causing spurious diffs. Sort the subdirectories in place to walk them in a stable order. The files list needs no sorting since only one Cargo.lock can exist per directory. Existing -crates.inc files with multiple Cargo.lock sections may be reordered once when they are regenerated. Link: https://lore.kernel.org/all/CAMPh3wqn5VMvufgZyUC3+=yzm3b0n3aciiROqnTYGDcsg2wgxg@mail.gmail.com/ Reported-by: Antoine Lubineau Signed-off-by: Marco Felsch --- meta/classes-recipe/cargo-update-recipe-crates.bbclass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index 9f92f0a522979fde8f0b88abdefb9a03c0c651ee..9db08c08f87a28c7be8f33fa98ceb1bdbec539c8 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass @@ -92,6 +92,9 @@ python do_update_crates() { found = False for root, dirs, files in os.walk(cargo_lock_src_dir): + # os.walk() order depends on the filesystem, sort to get a + # reproducible output across hosts + dirs.sort() # ignore git and patches directories if root.startswith(os.path.join(cargo_lock_src_dir, '.pc')): continue From patchwork Tue Dec 1 16:21:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 106843 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.14699.1796142089388118665 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=MeJWJX6C; 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.4.pengutronix.de [10.17.1.27]) (Authenticated sender: relay-from-dude06.red.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id C412B205AAF; 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=4LJTR0fzjTNCDC4OGdrhpFaKGJb5tJPwlb0LYods/EI=; b=MeJWJX6CZqndsOaqdZMK/FJM2xc+xHrwH6rVKVCNJpXJlQsgt09hN/JkLmkBOrEys4395J 032ojG3yxu//MI6C0Hp3JzfNp9cPwQwjyTZUvFQeILPqcsknOoTG50E6euBFmgmYNyBMXC FEJGAq7TKpF0gpz4yNqbK2+8xoUrdNKNsEVDYJ6NsgtqqNRz+R5ApwOaWLVRrhsHkJkrDH h6sulJY37ffP0tkec9MISKDxFGgI3K7N59BlNJh+vUyeWE84rhrnTx21igi9pb+Hg1zE2+ Lnbw832VxnnWHA92DGBdkh2BC5NKY4y0yoFnrYu8fIKSC31QihhEBHEviVydEQ== 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=4LJTR0fzjTNCDC4OGdrhpFaKGJb5tJPwlb0LYods/EI=; b=CG7mADWf+5HzBwygdIubUYEebnHcYKgGZOBg+8qk2Quq+/tCoe6jXecTKPY6Ia0Lc6sBFC XhP0/mzYZ0o4sC6OXL6ralheollBge6jqxXE5JGz88BQwUnxD17+ChlPla65Zqy4akOCWG GnV0ZRI9So4MygLgyz1GGXmLTSD0r4FK7XhfPdLAPLtzMppddNQXt6Yuo2Z9KPtw26Hhf4 OgyEWksJpKnu+tfgCX+niq6+E8/WDXuaMFnxPwL+VoGdh8AwX6jq6YpLJYIEe8UBFVjrzc etP6ny1B+sCNUlY1fYWnnVtgUc2hHQfUToaEmc5Lwbw/AQZJJsah8QvmgCQoiA== 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=FqvgraeTLbfiemHf+dmVbIV9UDqtdlXxnjNumxr+lK4ZJYB25TzXwvWVLB1pbjjfab+wk1 VJNbhxRLrCKGR/weWZICw1FTMAOaVby9HXne3w4X3ACuLq0hiT9yKv/zbqiM7hWcl1i80H 9nLb+Mkmg0yUeZzm2jucW08CaMhLMvKkCMLGEFeLfcStjYIP9I4+lohNmC55q8pl26OT8V I5Y+CUK4evh0wLOzlcmQzXapAlqkfgzx0d494uuoW8E/9RiaZHGyyrxgPLNK7/nbRG8neK uznCyHuSn0Cb+srLW43TBPSKh6hROdcJ7GO+Uwlmdd0zsgkj7M3Ps3X7gvVVIw== Received: from dude06.red.stw.pengutronix.de (localhost [IPv6:::1]) by dude06.red.stw.pengutronix.de (Postfix) with ESMTP id 99BED642849; Tue, 01 Dec 2026 17:21:22 +0100 (CET) From: Marco Felsch Date: Tue, 01 Dec 2026 17:21:19 +0100 Subject: [PATCH v5 4/4] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories MIME-Version: 1.0 Message-Id: <20261201-mfe-multi-cargo-lock-files-v5-4-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/251755 Recipes using cargo's -Z build-std must also vendor the standard library's dependencies. The std sources staged by rust-native (.../rustlib/src/rust/library) ship a Cargo.lock but no vendor directory, so those crates need crate:// entries in SRC_URI as well. Until now only a single directory could be scanned (CARGO_LOCK_SRC_DIR), which forced the std crate list to be maintained by hand and go stale on toolchain upgrades, breaking do_compile with: error: failed to select a version for the requirement `cfg-if = "^1.0"` (locked to 1.0.4) Keep the existing CARGO_LOCK_SRC_DIR and extend it to support a space-separated list of directories, to allow: CARGO_LOCK_SRC_DIR = "${S} ${STAGING_LIBDIR_NATIVE}/rustlib/src/rust/library" This way the behavior can be backported. Since such entries point into the recipe sysroot, do_update_crates now runs after do_prepare_recipe_sysroot. For cargo recipes this only pulls in the DEPENDS they need anyway, e.g. rust-native. As before for the single directory, each entry must exist and contain at least one Cargo.lock, otherwise the task fails. Crates found in multiple lockfiles are listed only once, in the section of the first Cargo.lock containing them, following the order of CARGO_LOCK_SRC_DIR; conflicting checksums for the same crate version fail the task. The crates.io warning now names the lockfile it came from. Output for recipes with a single lockfile is unchanged. Signed-off-by: Marco Felsch --- .../cargo-update-recipe-crates.bbclass | 78 ++++++++++++++-------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index 9db08c08f87a28c7be8f33fa98ceb1bdbec539c8..e15019f99794fb97e654aa5160cdccf3b15534f8 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass @@ -17,17 +17,23 @@ ## ## To perform the update: bitbake -c update_crates recipe-name -addtask do_update_crates after do_patch +addtask do_update_crates after do_patch do_prepare_recipe_sysroot do_update_crates[nostamp] = "1" do_update_crates[doc] = "Update the recipe by reading Cargo.lock and write in ${THISDIR}/${BPN}-crates.inc" RECIPE_UPGRADE_EXTRA_TASKS += "do_update_crates" -# The directory where to search for Cargo.lock files +# Space-separated list of directories where to search for Cargo.lock files. +# Each directory must exist and contain at least one Cargo.lock file. +# Crates found in multiple Cargo.lock files are listed only once, in the +# section of the first Cargo.lock file that contains them, following the +# order of the directories listed here. CARGO_LOCK_SRC_DIR ??= "${S}" python do_update_crates() { - cargo_lock_src_dir = d.getVar("CARGO_LOCK_SRC_DIR") + cargo_lock_src_dirs = d.getVar("CARGO_LOCK_SRC_DIR").split() + if not cargo_lock_src_dirs: + raise ValueError("CARGO_LOCK_SRC_DIR is empty") def get_legacy_checksums(crates, filename): # Old (v1) Cargo.lock files do not carry a 'checksum' field per @@ -48,13 +54,13 @@ python do_update_crates() { checksums[(name, version, source)] = value return checksums - def get_crates(filename): + def get_crates(filename, src_dir, seen): try: import tomllib except ImportError: import bb._vendor.tomli as tomllib - c_list = '# from %s' % os.path.relpath(filename, cargo_lock_src_dir) + c_list = '\n# from %s' % os.path.relpath(filename, src_dir) c_list += '\nSRC_URI += " \\' with open(filename, 'rb') as fp: crates = tomllib.load(fp) @@ -65,20 +71,32 @@ python do_update_crates() { crates_candidates = list(filter(lambda c: 'crates.io' in c.get('source', ''), crates['package'])) if not crates_candidates: - bb.warn("Unable to find any candidate crates that use crates.io") + bb.warn("Unable to find any candidate crates that use crates.io in %s" % filename) return None # Update crates uri and their checksum, to avoid name clashing on the checksum # we need to rename crates with name and version to have a unique key + # Crates already emitted for a previous Cargo.lock are skipped. cksum_list = '' + ncrates = 0 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'])) + if rename in seen: + if seen[rename] != checksum: + raise ValueError(f"Conflicting checksums for crate {rename}") + continue c_list += '\n crate://crates.io/%s/%s \\' % (c['name'], c['version']) if checksum is not None: cksum_list += '\nSRC_URI[%s.sha256sum] = "%s"' % (rename, checksum) + seen[rename] = checksum + ncrates += 1 + + # All crates were already emitted for a previous Cargo.lock + if not ncrates: + return '' c_list += '\n"\n' c_list += cksum_list @@ -88,28 +106,32 @@ python do_update_crates() { import os pn = d.getVar("PN") - crates = f"# Autogenerated with 'bitbake -c update_crates {pn}'\n\n" - - found = False - for root, dirs, files in os.walk(cargo_lock_src_dir): - # os.walk() order depends on the filesystem, sort to get a - # reproducible output across hosts - dirs.sort() - # ignore git and patches directories - if root.startswith(os.path.join(cargo_lock_src_dir, '.pc')): - continue - if root.startswith(os.path.join(cargo_lock_src_dir, '.git')): - continue - for file in files: - if file == 'Cargo.lock': - cargo_lock_path = os.path.join(root, file) - c = get_crates(cargo_lock_path) - if c is not None: - crates += c - found = True - - if not found: - raise ValueError(f"Unable to find any Cargo.lock in {cargo_lock_src_dir}") + crates = f"# Autogenerated with 'bitbake -c update_crates {pn}'\n" + + seen = {} + for cargo_lock_src_dir in cargo_lock_src_dirs: + if not os.path.isdir(cargo_lock_src_dir): + raise ValueError(f"CARGO_LOCK_SRC_DIR entry {cargo_lock_src_dir} does not exist") + found = False + for root, dirs, files in os.walk(cargo_lock_src_dir): + # os.walk() order depends on the filesystem, sort to get a + # reproducible output across hosts + dirs.sort() + # ignore git and patches directories + if root.startswith(os.path.join(cargo_lock_src_dir, '.pc')): + continue + if root.startswith(os.path.join(cargo_lock_src_dir, '.git')): + continue + for file in files: + if file == 'Cargo.lock': + cargo_lock_path = os.path.join(root, file) + c = get_crates(cargo_lock_path, cargo_lock_src_dir, seen) + if c is not None: + crates += c + found = True + + if not found: + raise ValueError(f"Unable to find any Cargo.lock in {cargo_lock_src_dir}") target_file = d.expand("${THISDIR}/${BPN}-crates.inc") with open(target_file, 'w') as f: