* [PATCH v4 0/3] Add support for multi Cargo.lock files
@ 2026-11-30 20:40 Marco Felsch
2026-11-30 20:40 ` [PATCH v4 1/3] classes/cargo-update-recipe-crates: use bb.warn() instead of print() Marco Felsch
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Marco Felsch @ 2026-11-30 20:40 UTC (permalink / raw)
To: openembedded-core; +Cc: peter.kjellerstedt, paul, yocto, Marco Felsch
Hi,
the main purpose of this series is to add support to reference multiple
Cargo.lock files which is handy once a recipe want to rebuild the
std-crate for minimized special purpose builds.
In addition to this, the series improves the warning printing and adds
support to parse the Cargo.lock v1 file format.
Regards,
Marco
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
Changes in v4:
- Link to v3: https://lore.kernel.org/r/20261126-mfe-multi-cargo-lock-files-v3-1-7ee885214204@pengutronix.de
- Add new patch-1 to convert printf to bb.warn()
- make use of bb.warn() to print warnings
- split patches into patch-2 and patch-3
- add the checksum to seen list only if the checksum exists
Changes in v3:
- Link to v2: https://lore.kernel.org/r/20261124-mfe-multi-cargo-lock-files-v2-1-8fd15cf316aa@pengutronix.de
- Convert to space-separated list to simplify :remove handling and align
with standard bitbake behavior
Changes in v2:
- Link to v1: https://lore.kernel.org/r/20261021-mfe-multi-cargo-lock-files-v1-0-d3510d4ad963@pengutronix.de
- Drop mainlined fixes patch
- Re-use CARGO_LOCK_SRC_DIR to make it backportable
- Add support for v1 Cargo.lock file format
---
Marco Felsch (3):
classes/cargo-update-recipe-crates: use bb.warn() instead of print()
classes/cargo-update-recipe-crates: support v1 Cargo.lock format
classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
.../cargo-update-recipe-crates.bbclass | 85 ++++++++++++++++------
1 file changed, 63 insertions(+), 22 deletions(-)
---
base-commit: 7412d08ab2ee94354a93f3765b94479d84c6b034
change-id: 20261021-mfe-multi-cargo-lock-files-41f9aea21595
Best regards,
--
Marco Felsch <m.felsch@pengutronix.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 1/3] classes/cargo-update-recipe-crates: use bb.warn() instead of print()
2026-11-30 20:40 [PATCH v4 0/3] Add support for multi Cargo.lock files Marco Felsch
@ 2026-11-30 20:40 ` Marco Felsch
2026-11-30 20:40 ` [PATCH v4 2/3] classes/cargo-update-recipe-crates: support v1 Cargo.lock format Marco Felsch
2026-11-30 20:40 ` [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories Marco Felsch
2 siblings, 0 replies; 8+ messages in thread
From: Marco Felsch @ 2026-11-30 20:40 UTC (permalink / raw)
To: openembedded-core; +Cc: peter.kjellerstedt, paul, yocto, Marco Felsch
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 <m.felsch@pengutronix.de>
---
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
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] classes/cargo-update-recipe-crates: support v1 Cargo.lock format
2026-11-30 20:40 [PATCH v4 0/3] Add support for multi Cargo.lock files Marco Felsch
2026-11-30 20:40 ` [PATCH v4 1/3] classes/cargo-update-recipe-crates: use bb.warn() instead of print() Marco Felsch
@ 2026-11-30 20:40 ` Marco Felsch
2026-11-30 20:40 ` [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories Marco Felsch
2 siblings, 0 replies; 8+ messages in thread
From: Marco Felsch @ 2026-11-30 20:40 UTC (permalink / raw)
To: openembedded-core; +Cc: peter.kjellerstedt, paul, yocto, Marco Felsch
Cargo.lock files in the old v1 format don't store a checksum per
[[package]] but collect them in the [metadata] table as
"checksum <name> <version> (<source>)" = "<sha256>". 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 "<none>" entries used for e.g. git sources.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
.../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 <name> <version> (<source>)" 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 <name> <version> (<source>)" = "<sha256>"
+ # Packages without a checksum (e.g. git sources) use "<none>".
+ 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 == '<none>':
+ 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
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
2026-11-30 20:40 [PATCH v4 0/3] Add support for multi Cargo.lock files Marco Felsch
2026-11-30 20:40 ` [PATCH v4 1/3] classes/cargo-update-recipe-crates: use bb.warn() instead of print() Marco Felsch
2026-11-30 20:40 ` [PATCH v4 2/3] classes/cargo-update-recipe-crates: support v1 Cargo.lock format Marco Felsch
@ 2026-11-30 20:40 ` Marco Felsch
2026-11-30 21:24 ` Paul Barker
2 siblings, 1 reply; 8+ messages in thread
From: Marco Felsch @ 2026-11-30 20:40 UTC (permalink / raw)
To: openembedded-core; +Cc: peter.kjellerstedt, paul, yocto, Marco Felsch
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.
Crates found in multiple lockfiles are listed only once, in the section
of the first Cargo.lock containing them; conflicting checksums for the
same crate version now 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 <m.felsch@pengutronix.de>
---
.../cargo-update-recipe-crates.bbclass | 53 ++++++++++++++--------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
index 9f92f0a522979fde8f0b88abdefb9a03c0c651ee..449a1c5d81b92c686e9aea76648a55e88ec77efc 100644
--- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
+++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
@@ -23,12 +23,12 @@ do_update_crates[doc] = "Update the recipe by reading Cargo.lock and write in ${
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.
+# Crates found in multiple Cargo.lock files are listed only once, in the
+# section of the first Cargo.lock file that contains them.
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:
@@ -48,13 +48,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 = '# from %s' % os.path.relpath(filename, src_dir)
c_list += '\nSRC_URI += " \\'
with open(filename, 'rb') as fp:
crates = tomllib.load(fp)
@@ -65,20 +65,31 @@ 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
+
+ if not ncrates:
+ return None
c_list += '\n"\n'
c_list += cksum_list
@@ -90,23 +101,25 @@ python do_update_crates() {
pn = d.getVar("PN")
crates = f"# Autogenerated with 'bitbake -c update_crates {pn}'\n\n"
+ seen = {}
found = False
- for root, dirs, files in os.walk(cargo_lock_src_dir):
- # 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
+ for cargo_lock_src_dir in d.getVar("CARGO_LOCK_SRC_DIR").split():
+ for root, dirs, files in os.walk(cargo_lock_src_dir):
+ # 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}")
+ raise ValueError(f"Unable to find any Cargo.lock in '{d.getVar('CARGO_LOCK_SRC_DIR')}'")
target_file = d.expand("${THISDIR}/${BPN}-crates.inc")
with open(target_file, 'w') as f:
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
2026-11-30 20:40 ` [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories Marco Felsch
@ 2026-11-30 21:24 ` Paul Barker
2026-12-01 9:37 ` [OE-core] " Marco Felsch
[not found] ` <18ED17AB19C3015E.2226965@lists.openembedded.org>
0 siblings, 2 replies; 8+ messages in thread
From: Paul Barker @ 2026-11-30 21:24 UTC (permalink / raw)
To: Marco Felsch, openembedded-core; +Cc: peter.kjellerstedt, yocto
Hi Marco,
Thanks for the v4 series, patches 1/3 & 2/3 are good, I have a couple of
comments on this one.
On Mon Nov 30, 2026 at 8:40 PM GMT, Marco Felsch wrote:
> 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"
In this example you'd need to ensure ${STAGING_LIBDIR_NATIVE} is
populated before do_update_crates runs. It's probably worth modifying
the `addtask` line so do_update_crates always runs after
do_prepare_recipe_sysroot.
We should also consider what should happen if one of these directories
is missing or doesn't contain a Cargo.lock file. Should that cause an
error?
>
> This way the behavior can be backported.
>
> Crates found in multiple lockfiles are listed only once, in the section
> of the first Cargo.lock containing them; conflicting checksums for the
> same crate version now fail the task. The crates.io warning now names the
> lockfile it came from. Output for recipes with a single lockfile is
> unchanged.
The "first" Cargo.lock file mentioning a particular crate will depend on
the order in which Cargo.lock files are parsed. I don't think os.walk()
explores subdirectories in a deterministic order, can we modify this so
that the output is deterministic?
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> .../cargo-update-recipe-crates.bbclass | 53 ++++++++++++++--------
> 1 file changed, 33 insertions(+), 20 deletions(-)
>
> diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> index 9f92f0a522979fde8f0b88abdefb9a03c0c651ee..449a1c5d81b92c686e9aea76648a55e88ec77efc 100644
> --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> @@ -23,12 +23,12 @@ do_update_crates[doc] = "Update the recipe by reading Cargo.lock and write in ${
>
> 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.
> +# Crates found in multiple Cargo.lock files are listed only once, in the
> +# section of the first Cargo.lock file that contains them.
> 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:
> @@ -48,13 +48,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 = '# from %s' % os.path.relpath(filename, src_dir)
If there are two entries in CARGO_LOCK_SRC_DIR, each path containing a
Cargo.toml file, this will just say `# from Cargo.lock` for each. Is
there a better way to differentiate them without embedding absolute
paths in the output?
Best regards,
--
Paul Barker
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
2026-11-30 21:24 ` Paul Barker
@ 2026-12-01 9:37 ` Marco Felsch
[not found] ` <18ED17AB19C3015E.2226965@lists.openembedded.org>
1 sibling, 0 replies; 8+ messages in thread
From: Marco Felsch @ 2026-12-01 9:37 UTC (permalink / raw)
To: Paul Barker
Cc: openembedded-core, peter.kjellerstedt, yocto, antoine.lubineau
Hi Paul,
On 26-11-30 21:24, Paul Barker wrote:
> Hi Marco,
>
> Thanks for the v4 series, patches 1/3 & 2/3 are good, I have a couple of
> comments on this one.
Thanks for the review! :)
> On Mon Nov 30, 2026 at 8:40 PM GMT, Marco Felsch wrote:
> > 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"
>
> In this example you'd need to ensure ${STAGING_LIBDIR_NATIVE} is
> populated before do_update_crates runs. It's probably worth modifying
> the `addtask` line so do_update_crates always runs after
> do_prepare_recipe_sysroot.
My rust package which uses this mechanism has the following line:
| do_update_crates[depends] += "rust-native:do_populate_sysroot"
I would still need this line with your proposed change, right? If this
is the case, what benefit would have a do_prepare_recipe_sysroot?
> We should also consider what should happen if one of these directories
> is missing or doesn't contain a Cargo.lock file. Should that cause an
> error?
That's a good point, it should have the same behavior as it is right now
with the single directory use-case:
- each specified path need at least one Cargo.lock file
- each specified path must exist
=> else an error is thrown.
Do you agree?
> > This way the behavior can be backported.
> >
> > Crates found in multiple lockfiles are listed only once, in the section
> > of the first Cargo.lock containing them; conflicting checksums for the
> > same crate version now fail the task. The crates.io warning now names the
> > lockfile it came from. Output for recipes with a single lockfile is
> > unchanged.
>
> The "first" Cargo.lock file mentioning a particular crate will depend on
> the order in which Cargo.lock files are parsed. I don't think os.walk()
> explores subdirectories in a deterministic order, can we modify this so
> that the output is deterministic?
Please see the mail from Antoine:
https://lore.kernel.org/all/CAMPh3wqn5VMvufgZyUC3+=yzm3b0n3aciiROqnTYGDcsg2wgxg@mail.gmail.com/
This is already a bug in the current implementation. Seems like nobody
cared till now. Of course we can fix this but this for sure causes
changes on $someSpecificHostOs. For this reason I would like to leave
this discussion out of this series.
Regards,
Marco
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> > .../cargo-update-recipe-crates.bbclass | 53 ++++++++++++++--------
> > 1 file changed, 33 insertions(+), 20 deletions(-)
> >
> > diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> > index 9f92f0a522979fde8f0b88abdefb9a03c0c651ee..449a1c5d81b92c686e9aea76648a55e88ec77efc 100644
> > --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> > +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> > @@ -23,12 +23,12 @@ do_update_crates[doc] = "Update the recipe by reading Cargo.lock and write in ${
> >
> > 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.
> > +# Crates found in multiple Cargo.lock files are listed only once, in the
> > +# section of the first Cargo.lock file that contains them.
> > 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:
> > @@ -48,13 +48,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 = '# from %s' % os.path.relpath(filename, src_dir)
>
> If there are two entries in CARGO_LOCK_SRC_DIR, each path containing a
> Cargo.toml file, this will just say `# from Cargo.lock` for each. Is
> there a better way to differentiate them without embedding absolute
> paths in the output?
>
> Best regards,
>
> --
> Paul Barker
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#251650): https://lists.openembedded.org/g/openembedded-core/message/251650
> Mute This Topic: https://lists.openembedded.org/mt/122523102/4454719
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [m.felsch@pengutronix.de]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
[not found] ` <18ED17AB19C3015E.2226965@lists.openembedded.org>
@ 2026-12-01 16:25 ` Marco Felsch
2026-12-02 10:15 ` Paul Barker
0 siblings, 1 reply; 8+ messages in thread
From: Marco Felsch @ 2026-12-01 16:25 UTC (permalink / raw)
To: Paul Barker
Cc: openembedded-core, peter.kjellerstedt, yocto, antoine.lubineau
On 26-12-01 10:37, Marco Felsch wrote:
> Hi Paul,
>
> On 26-11-30 21:24, Paul Barker wrote:
> > Hi Marco,
> >
> > Thanks for the v4 series, patches 1/3 & 2/3 are good, I have a couple of
> > comments on this one.
[...]
> > > 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"
> >
> > In this example you'd need to ensure ${STAGING_LIBDIR_NATIVE} is
> > populated before do_update_crates runs. It's probably worth modifying
> > the `addtask` line so do_update_crates always runs after
> > do_prepare_recipe_sysroot.
>
> My rust package which uses this mechanism has the following line:
>
> | do_update_crates[depends] += "rust-native:do_populate_sysroot"
>
> I would still need this line with your proposed change, right? If this
> is the case, what benefit would have a do_prepare_recipe_sysroot?
With v5 this is fixed now. I see that {PN}:do_populate_sysroot didn't
fixed your point. Sorry for the noise.
> > We should also consider what should happen if one of these directories
> > is missing or doesn't contain a Cargo.lock file. Should that cause an
> > error?
>
> That's a good point, it should have the same behavior as it is right now
> with the single directory use-case:
> - each specified path need at least one Cargo.lock file
> - each specified path must exist
> => else an error is thrown.
>
> Do you agree?
I've implemented exactly this beavhior in v5. Should be fine since it
mimics the current status.
> > > This way the behavior can be backported.
> > >
> > > Crates found in multiple lockfiles are listed only once, in the section
> > > of the first Cargo.lock containing them; conflicting checksums for the
> > > same crate version now fail the task. The crates.io warning now names the
> > > lockfile it came from. Output for recipes with a single lockfile is
> > > unchanged.
> >
> > The "first" Cargo.lock file mentioning a particular crate will depend on
> > the order in which Cargo.lock files are parsed. I don't think os.walk()
> > explores subdirectories in a deterministic order, can we modify this so
> > that the output is deterministic?
>
> Please see the mail from Antoine:
> https://lore.kernel.org/all/CAMPh3wqn5VMvufgZyUC3+=yzm3b0n3aciiROqnTYGDcsg2wgxg@mail.gmail.com/
>
> This is already a bug in the current implementation. Seems like nobody
> cared till now. Of course we can fix this but this for sure causes
> changes on $someSpecificHostOs. For this reason I would like to leave
> this discussion out of this series.
I've added a deterministic fixes patch to the v5.
Sorry for pushing so fast, but I wanted to get this done because other
recipes rely on this mechanism for possible static builds.
Regards,
Marco
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
2026-12-01 16:25 ` Marco Felsch
@ 2026-12-02 10:15 ` Paul Barker
0 siblings, 0 replies; 8+ messages in thread
From: Paul Barker @ 2026-12-02 10:15 UTC (permalink / raw)
To: Marco Felsch
Cc: openembedded-core, peter.kjellerstedt, yocto, antoine.lubineau
On Tue Dec 1, 2026 at 4:25 PM GMT, Marco Felsch wrote:
> On 26-12-01 10:37, Marco Felsch wrote:
>> Hi Paul,
>>
>> On 26-11-30 21:24, Paul Barker wrote:
>> > Hi Marco,
>> >
>> > Thanks for the v4 series, patches 1/3 & 2/3 are good, I have a couple of
>> > comments on this one.
>
> [...]
>
>> > > 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"
>> >
>> > In this example you'd need to ensure ${STAGING_LIBDIR_NATIVE} is
>> > populated before do_update_crates runs. It's probably worth modifying
>> > the `addtask` line so do_update_crates always runs after
>> > do_prepare_recipe_sysroot.
>>
>> My rust package which uses this mechanism has the following line:
>>
>> | do_update_crates[depends] += "rust-native:do_populate_sysroot"
>>
>> I would still need this line with your proposed change, right? If this
>> is the case, what benefit would have a do_prepare_recipe_sysroot?
>
> With v5 this is fixed now. I see that {PN}:do_populate_sysroot didn't
> fixed your point. Sorry for the noise.
>
>> > We should also consider what should happen if one of these directories
>> > is missing or doesn't contain a Cargo.lock file. Should that cause an
>> > error?
>>
>> That's a good point, it should have the same behavior as it is right now
>> with the single directory use-case:
>> - each specified path need at least one Cargo.lock file
>> - each specified path must exist
>> => else an error is thrown.
>>
>> Do you agree?
>
> I've implemented exactly this beavhior in v5. Should be fine since it
> mimics the current status.
>
>> > > This way the behavior can be backported.
>> > >
>> > > Crates found in multiple lockfiles are listed only once, in the section
>> > > of the first Cargo.lock containing them; conflicting checksums for the
>> > > same crate version now fail the task. The crates.io warning now names the
>> > > lockfile it came from. Output for recipes with a single lockfile is
>> > > unchanged.
>> >
>> > The "first" Cargo.lock file mentioning a particular crate will depend on
>> > the order in which Cargo.lock files are parsed. I don't think os.walk()
>> > explores subdirectories in a deterministic order, can we modify this so
>> > that the output is deterministic?
>>
>> Please see the mail from Antoine:
>> https://lore.kernel.org/all/CAMPh3wqn5VMvufgZyUC3+=yzm3b0n3aciiROqnTYGDcsg2wgxg@mail.gmail.com/
>>
>> This is already a bug in the current implementation. Seems like nobody
>> cared till now. Of course we can fix this but this for sure causes
>> changes on $someSpecificHostOs. For this reason I would like to leave
>> this discussion out of this series.
>
> I've added a deterministic fixes patch to the v5.
>
> Sorry for pushing so fast, but I wanted to get this done because other
> recipes rely on this mechanism for possible static builds.
No problem, v5 looks good to me.
Best regards,
--
Paul Barker
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-02 10:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 20:40 [PATCH v4 0/3] Add support for multi Cargo.lock files Marco Felsch
2026-11-30 20:40 ` [PATCH v4 1/3] classes/cargo-update-recipe-crates: use bb.warn() instead of print() Marco Felsch
2026-11-30 20:40 ` [PATCH v4 2/3] classes/cargo-update-recipe-crates: support v1 Cargo.lock format Marco Felsch
2026-11-30 20:40 ` [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories Marco Felsch
2026-11-30 21:24 ` Paul Barker
2026-12-01 9:37 ` [OE-core] " Marco Felsch
[not found] ` <18ED17AB19C3015E.2226965@lists.openembedded.org>
2026-12-01 16:25 ` Marco Felsch
2026-12-02 10:15 ` Paul Barker
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.