fs/tar: explicitly set extended header values to ensure binary reproducibility
authorAtharva Lele <itsatharva@gmail.com>
Sat, 6 Jul 2019 06:55:01 +0000 (12:25 +0530)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 14 Jul 2019 10:21:11 +0000 (12:21 +0200)
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. Setting of mtime
is handled in fs/common.mk using touch on all files.

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

Signed-off-by: Atharva Lele <itsatharva@gmail.com>
Reviewed-by: Matt Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
fs/tar/tar.mk

index 4c6327ace8b0aeebadac0101bb6cc977d57f9206..393d01bfe85398bd2251adefa5370e74ecadd77c 100644 (file)
@@ -8,6 +8,9 @@ TAR_OPTS := $(call qstrip,$(BR2_TARGET_ROOTFS_TAR_OPTIONS))
 
 ROOTFS_TAR_DEPENDENCIES = $(BR2_TAR_HOST_DEPENDENCY)
 
+# do not store atime/ctime in PaxHeaders to ensure reproducbility
+TAR_OPTS += --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0
+
 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)