Package: grunt / 1.0.1-8+deb10u1

reproducible-build.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From bf7c4be2840033ee6ef2efd85d086c81ee2504ee Mon Sep 17 00:00:00 2001
From: Chris Lamb <chris@chris-lamb.co.uk>
Date: Sun, 9 Jul 2017 09:40:54 +0100
Subject: [PATCH] Use SOURCE_DATE_EPOCH to render dates in template.

Whilst working on the Reproducible Builds effort [0], we noticed
that grunt can generate non-reproducible output. This is affecting the
reproducibility status other packages (such as jquery-tablesorter) that
set a "pkg.banner" such as:

   <%= grunt.template.today("mm-dd-yyyy")

 [0] https://reproducible-builds.org/

Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
---
 lib/grunt/template.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/grunt/template.js b/lib/grunt/template.js
index d1967df9..15e1fe10 100644
--- a/lib/grunt/template.js
+++ b/lib/grunt/template.js
@@ -10,7 +10,11 @@ template.date = require('dateformat');
 
 // Format today's date.
 template.today = function(format) {
-  return template.date(new Date(), format);
+  var now = new Date();
+  if (process.env.SOURCE_DATE_EPOCH) {
+    now = new Date((process.env.SOURCE_DATE_EPOCH * 1000) + (now.getTimezoneOffset() * 60000));
+  }
+  return template.date(now, format);
 };
 
 // Template delimiters.