civodul pushed a commit to branch devel
in repository shepherd.

commit f5ac34948a44144fb7745e89bf6e6ccc7bea07db
Author: Ludovic Courtès <[email protected]>
AuthorDate: Sun Nov 3 18:16:25 2024 +0100

    maint: ‘make dist’ builds tarballs deterministically.
    
    Inspired by the work of Janneke Nieuwenhuizen <[email protected]> to build
    the Guix tarballs in a deterministic fashion.
    
    * Makefile.am (GZIP_ENV, am__tar): New variables.
    * .guix/modules/shepherd-package.scm (development-packages): Add
    “git-minimal”.
    (source-tarball): Remove comment about timestamps and remove ‘setenv’
    call for ‘TAR_OPTIONS’.
---
 .guix/modules/shepherd-package.scm |  6 ++----
 Makefile.am                        | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/.guix/modules/shepherd-package.scm 
b/.guix/modules/shepherd-package.scm
index 86f5f36..070e278 100644
--- a/.guix/modules/shepherd-package.scm
+++ b/.guix/modules/shepherd-package.scm
@@ -66,7 +66,8 @@
 
 (define development-packages
   ;; Packages needed when building from Git.
-  '("autoconf" "automake" "gettext-minimal" "texinfo" "help2man"))
+  '("autoconf" "automake" "gettext-minimal" "texinfo" "help2man"
+    "git-minimal"))                               ;for 'make dist'
 
 (define-public guile-fibers-on-libevent
   ;; Fibers running on the libevent backend.
@@ -157,14 +158,11 @@ interface and is based on GNU Guile.")
 
 (define source-tarball
   ;; Tarball make from the Git checkout.
-  ;; XXX: Timestamps in the tarball are non-deterministic.
   (dist-package shepherd source-checkout
                 #:phases #~(modify-phases %dist-phases
                              (replace 'build-dist
                                (lambda args
                                  ;; Run "make" before "make distcheck".
-                                 (setenv "TAR_OPTIONS" "\
- --mtime=2023-01-01 --owner=guix --group=guix --sort=name")
                                  (apply (assoc-ref %dist-phases 'build-dist)
                                         #:build-before-dist? #t
                                         #:dist-target "dist"
diff --git a/Makefile.am b/Makefile.am
index 5a3491e..8308e76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -338,6 +338,22 @@ $(scripts_install_go_files): install-dist_scriptsDATA
 
 
 
+# Reproducible tarball.
+
+# Don't embed a timestamp in the gzip header.
+override GZIP_ENV = --best --no-name
+
+# Use either the time of last commit, or $SOURCE_DATE_EPOCH, or the Epoch as
+# the timestamp for all the files in the tarball.
+override am__tar = $${TAR-tar}                 \
+ --format=ustar                                        \
+ --sort=name                                   \
+ --mode=go=rX,u+rw,a-s                         \
+ --mtime=@$$(git log -1 --format="%at" || echo $${SOURCE_DATE_EPOCH:-0}) \
+ --owner=0 --group=0 --numeric-owner           \
+ -cf -                                         \
+ "$$tardir"
+
 SUBDIRS = po
 
 ACLOCAL_AMFLAGS = -I m4

Reply via email to