[Pkg-javascript-devel] Bug#1030724: node-marked-man: please make the build reproducible

Chris Lamb lamby at debian.org
Mon Feb 6 19:38:03 GMT 2023


Source: node-marked-man
Version: 1.3.1-1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: timestamps toolchain
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0] we noticed that
node-marked-man generates manpages that vary depending on the system
timezone. For example, within the tree of src:node-gulp:

  $ dpkg-parsechangelog --show-field=Date
  Wed, 30 Nov 2022 23:28:47 +0100

  $ TZ="/usr/share/zoneinfo/Etc/GMT-14" marked-man --name gulp --date="$(dpkg-parsechangelog --show-field=Date)" docs/CLI.md | head -n1
  .TH "GULP" "1" "December 2022" "4.0.2"

  $ TZ="/usr/share/zoneinfo/Etc/GMT+11" marked-man --name gulp --date="$(dpkg-parsechangelog --show-field=Date)" docs/CLI.md | head -n1
  .TH "GULP" "1" "November 2022" "4.0.2"

This seems to be caused by the use of Date.prototype.toLocaleDateString
in utils.js:

    export function manDate(date) {
      const stamp = parseInt(date);
      if (!Number.isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
      date = new Date(date);
      return date.toLocaleString('en', { month: 'long', year: 'numeric' });
    }

A patch is attached that normalises this to UTC. After this patch is
applied, you get the following:

  $ TZ="/usr/share/zoneinfo/Etc/GMT-14" marked-man --name gulp --date="$(dpkg-parsechangelog --show-field=Date)" docs/CLI.md | head -n1
  .TH "GULP" "1" "November 2022" "4.0.2"

  $ TZ="/usr/share/zoneinfo/Etc/GMT+11" marked-man --name gulp --date="$(dpkg-parsechangelog --show-field=Date)" docs/CLI.md | head -n1
  .TH "GULP" "1" "November 2022" "4.0.2"


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


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
diff --git a/src/utils.js b/src/utils.js
index 1c1d37d..59d042f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -80,6 +80,7 @@ export function manDate(date) {
 	const stamp = parseInt(date);
 	if (!Number.isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
 	date = new Date(date);
+	date = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
 	return date.toLocaleString('en', { month: 'long', year: 'numeric' });
 }
 


More information about the Pkg-javascript-devel mailing list