fs/cpio: generate reproducible archives
authorYurii Monakov <monakov.y@gmail.com>
Mon, 29 Jun 2020 12:37:01 +0000 (15:37 +0300)
committerYann E. MORIN <yann.morin.1998@free.fr>
Mon, 29 Jun 2020 15:57:12 +0000 (17:57 +0200)
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@gmail.com>
[yann.morin.1998@free.fr:
  - use LC_ALL=C when sorting
  - wrap long line
  - reword commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
fs/cpio/cpio.mk

index 28a435dd5e57d682dc666d075ff5b1a9ee264456..81f8c393d18c39bbc1f0902063e15240ca4b0c45 100644 (file)
@@ -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)