Skip to contentSkip to conversation

fs/tar: explicitly set extended header values to ensure binary reproducibility

PATCH Superseded Atharva Lele 1 participant 1 message Jul 2, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/tar: explicitly set extended header values to ensure binary reproducibility

Since we use --xattrs-include='*' to include all extended attributes, tar creates a PAX formatted archive. The archive metadata captures atime and ctime of files. To fix this, GNU recommends that we pass this added argument to tar to create binary reproducible packages.

Diffoscope output pre-change: https://gitlab.com/snippets/1871111
Diffoscope output after change is blank i.e. binary reproducibile rootfs is created.

GNU Recommendation: https://www.gnu.org/software/tar/manual/tar.html#SEC147

---
 fs/tar/tar.mk | 4 ++++
 1 file changed, 4 insertions(+)
fs/tar/tar.mk +4 -0
index 4c6327ace8..f6d11baa84 100644
@@ -8,6 +8,10 @@ TAR_OPTS := $(call qstrip,$(BR2_TARGET_ROOTFS_TAR_OPTIONS))
 
 ROOTFS_TAR_DEPENDENCIES = $(BR2_TAR_HOST_DEPENDENCY)
 
+ifeq ($(BR2_REPRODUCIBLE),y)
+TAR_OPTS += --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0
+endif
+
 define ROOTFS_TAR_CMD
 	(cd $(TARGET_DIR); find -print0 | LC_ALL=C sort -z | \
 		tar $(TAR_OPTS) -cf $@ --null --xattrs-include='*' --no-recursion -T - --numeric-owner)
Signature · 1 line
2.20.1