Ludovic Courtès (2015-10-20 22:38 +0300) wrote:

> Alex Kost <alez...@gmail.com> skribis:
>
[...]
>> However this will fix only those packages, that use
>> ‘emacs-generate-autoloads’ directly or via ‘emacs-build-system’.  But
>> there are also packages that generate autoloads on their own (for
>> example, 'emacs-w3m' or 'guix' itself).  What to do for these ones?
>>
>> Perhaps we can make a special 'emacs-build' package (that will advise
>> ‘autoload-insert-section-header’ function somehow) and use it as an
>> input for emacs-packages, or are there other ways?
>
> What about patching Emacs directly?

Indeed!

> An upstreamable patch would be one that honors the ‘SOURCE_DATE_EPOCH’
> variable¹.
>
> Alternately, a patch that simply changes
> ‘autoload-insert-section-header’ to always use zero as the timestamp
> would work as well, unless this would somehow break functionality.
>
> Thoughts?

I like the idea to honor SOURCE_DATE_EPOCH, so I'm attaching a patch for
this.  But now I don't know how to make Guix set this variable during
the build process :-(  Need help.

> Thanks for looking into it,
> Ludo’.
>
> ¹ https://reproducible-builds.org/specs/source-date-epoch/

Thanks for the info!

>From b8dc19a65980690a636ad7f9f39b3c84991f4975 Mon Sep 17 00:00:00 2001
From: Alex Kost <alez...@gmail.com>
Date: Wed, 21 Oct 2015 15:59:23 +0300
Subject: [PATCH] gnu: emacs: Honor 'SOURCE_DATE_EPOCH'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by Ludovic Courtès <l...@gnu.org>.

* gnu/packages/patches/emacs-source-date-epoch.patch: New patch.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/emacs.scm (emacs)[source]: Use it.
---
 gnu-system.am                                      |  1 +
 gnu/packages/emacs.scm                             |  3 ++-
 gnu/packages/patches/emacs-source-date-epoch.patch | 20 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/emacs-source-date-epoch.patch

diff --git a/gnu-system.am b/gnu-system.am
index e62fe18..4a20801 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -437,6 +437,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/duplicity-test_selection-tmp.patch	\
   gnu/packages/patches/elfutils-tests-ptrace.patch		\
   gnu/packages/patches/emacs-exec-path.patch			\
+  gnu/packages/patches/emacs-source-date-epoch.patch		\
   gnu/packages/patches/eudev-rules-directory.patch		\
   gnu/packages/patches/expat-CVE-2015-1283.patch		\
   gnu/packages/patches/fastcap-mulGlobal.patch			\
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 6416b00..9751125 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -70,7 +70,8 @@
              (sha256
               (base32
                "0kn3rzm91qiswi0cql89kbv6mqn27rwsyjfb8xmwy9m5s8fxfiyx"))
-             (patches (list (search-patch "emacs-exec-path.patch")))))
+             (patches (list (search-patch "emacs-exec-path.patch")
+                            (search-patch "emacs-source-date-epoch.patch")))))
     (build-system glib-or-gtk-build-system)
     (arguments
      '(#:phases (alist-cons-before
diff --git a/gnu/packages/patches/emacs-source-date-epoch.patch b/gnu/packages/patches/emacs-source-date-epoch.patch
new file mode 100644
index 0000000..41c03ef
--- /dev/null
+++ b/gnu/packages/patches/emacs-source-date-epoch.patch
@@ -0,0 +1,20 @@
+Honor SOURCE_DATE_EPOCH variable to avoid non-determinism in generated
+"autoloads" files.
+
+--- a/lisp/emacs-lisp/autoload.el
++++ b/lisp/emacs-lisp/autoload.el
+@@ -378,8 +378,12 @@
+   "Insert the section-header line,
+ which lists the file name and which functions are in it, etc."
+   (insert generate-autoload-section-header)
+-  (prin1 `(autoloads ,autoloads ,load-name ,file ,time)
+-	 outbuf)
++  (let* ((env  (getenv "SOURCE_DATE_EPOCH"))
++         (time (if env
++                   (seconds-to-time (string-to-number env))
++                 time)))
++    (prin1 `(autoloads ,autoloads ,load-name ,file ,time)
++           outbuf))
+   (terpri outbuf)
+   ;; Break that line at spaces, to avoid very long lines.
+   ;; Make each sub-line into a comment.
-- 
2.5.0

Reply via email to