diff mbox series

[bug#48933] build: Make outputs of node-build-system reproducible.

Message ID YMs8IpUBDYN0rPSt@noor.fritz.box
State Accepted
Headers show
Series [bug#48933] build: Make outputs of node-build-system reproducible. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Lars-Dominik Braun June 17, 2021, 12:12 p.m. UTC
Hi Ludo,

> >  (define* (repack #:key inputs #:allow-other-keys)
> > -  (invoke "tar" "-czf" "../package.tgz" ".")
> > +  (invoke "tar"
> > +          ;; Add options suggested by https://reproducible-builds.org/docs/archives/
*
> > +          "--sort=name"
> > +          (string-append "--mtime=" (getenv "SOURCE_DATE_EPOCH"))
> 
> I think it should be "--mtime=@".
you’re right, fixed.

> I didn’t know about this ‘--pax-option’ trick; since it’s only useful
> when POSIXLY_CORRECT is set, perhaps we can remove it?
True, removed.

> (guix docker) does this:
> and (guix packages) does something similar.
Hm, maybe it would make sense to export a set of options, so
build systems/packages can share them? Or create a package that wraps
tar with the proper options?

> So ‘--sort=name’ seems to be missing.
It’s present, see above ↑*

Updated patch attached. I’ll push it if there are no further comments.

Cheers,
Lars

Comments

Ludovic Courtès June 20, 2021, 8:58 p.m. UTC | #1
Hi,

Lars-Dominik Braun <lars@6xq.net> skribis:

[...]

>> (guix docker) does this:
>> and (guix packages) does something similar.
> Hm, maybe it would make sense to export a set of options, so
> build systems/packages can share them? Or create a package that wraps
> tar with the proper options?

Would be nice.

Even better would be to use a custom tar implementation (similar to
(guix cpio)) that would make it easier and less clunky to ensure
reproducibility.

>> So ‘--sort=name’ seems to be missing.
> It’s present, see above ↑*

Indeed.  :-)

> Updated patch attached. I’ll push it if there are no further comments.

Perfect, thanks!

Ludo’.
Lars-Dominik Braun June 24, 2021, 12:12 p.m. UTC | #2
Hi,

> > Updated patch attached. I’ll push it if there are no further comments.
> 
> Perfect, thanks!
pushed as 9c93573d15e90232de0effb4c28332c454dbc290.

Cheers,
Lars
diff mbox series

Patch

From 6692ebc8561d4e419c276fcdd01a4088d29c5fd7 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Thu, 17 Jun 2021 14:11:19 +0200
Subject: [PATCH] build: Make outputs of node-build-system reproducible.

package.json records two hashes of package.tgz, which change for each
build, resulting in non-reproducible builds.

* guix/build/node-build-system.scm (repack): Add reproducibility options
to tar command.
---
 guix/build/node-build-system.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index a55cab237c..70a367618e 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -120,7 +120,14 @@ 
   #t)
 
 (define* (repack #:key inputs #:allow-other-keys)
-  (invoke "tar" "-czf" "../package.tgz" ".")
+  (invoke "tar"
+          ;; Add options suggested by https://reproducible-builds.org/docs/archives/
+          "--sort=name"
+          (string-append "--mtime=@" (getenv "SOURCE_DATE_EPOCH"))
+          "--owner=0"
+          "--group=0"
+          "--numeric-owner"
+          "-czf" "../package.tgz" ".")
   #t)
 
 (define* (install #:key outputs inputs #:allow-other-keys)
-- 
2.31.1