[Buildroot] [git commit branch/2020.05.x] fs/cpio: generate reproducible archives

Peter Korsgaard peter at korsgaard.com
Thu Jul 16 16:33:21 UTC 2020


commit: https://git.buildroot.net/buildroot/commit/?id=f5027f8371b1a187bdf52e753d69cc3fb33b673c
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2020.05.x

The output of 'find' depends on the directory entries, and is not
ordered. As a consequence, the cpio archive is not reproducible.

Fix that by sorting the output of find. Use the 'C' locale to enforce
reproducibility that does not depend on the locale.

The command line is now pretty long, so we wrap it.

Signed-off-by: Yurii Monakov <monakov.y at gmail.com>
[yann.morin.1998 at free.fr:
  - use LC_ALL=C when sorting
  - wrap long line
  - reword commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
(cherry picked from commit 4728fdd4c06be07883e59eeb148c86cb74e10d73)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 fs/cpio/cpio.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/cpio/cpio.mk b/fs/cpio/cpio.mk
index 28a435dd5e..81f8c393d1 100644
--- a/fs/cpio/cpio.mk
+++ b/fs/cpio/cpio.mk
@@ -37,7 +37,11 @@ ROOTFS_CPIO_OPTS += --reproducible
 endif
 
 define ROOTFS_CPIO_CMD
-	cd $(TARGET_DIR) && find . | cpio $(ROOTFS_CPIO_OPTS) --quiet -o -H newc > $@
+	cd $(TARGET_DIR) && \
+	find . \
+	| LC_ALL=C sort \
+	| cpio $(ROOTFS_CPIO_OPTS) --quiet -o -H newc \
+	> $@
 endef
 
 ifeq ($(BR2_TARGET_ROOTFS_CPIO_UIMAGE),y)


More information about the buildroot mailing list