diff mbox series

[v5,3/4] classes/cargo-update-recipe-crates: make Cargo.lock search order deterministic

Message ID 20261201-mfe-multi-cargo-lock-files-v5-3-6c4eae24ec27@pengutronix.de
State New
Headers show
Series Add support for multi Cargo.lock files | expand

Commit Message

Marco Felsch Dec. 1, 2026, 4:21 p.m. UTC
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 <antoine.lubineau@tld-robotics.com>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 meta/classes-recipe/cargo-update-recipe-crates.bbclass | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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