On 30/12/15 10:51, Ben Woodcroft wrote:
Too ham-fisted?
Maybe, but badly committed at least. Try this.
>From 3d23171d88b9f38c90efa469f6519b52b15a1d01 Mon Sep 17 00:00:00 2001
From: Ben Woodcroft <donttrust...@gmail.com>
Date: Wed, 30 Dec 2015 10:27:33 +1000
Subject: [PATCH] build: ruby: Remove cached gem after install.

The .gem file stored in GEM_HOME after install is both redundant and an
archive that stores timestamped files which makes builds non-deterministic. So
delete it after 'gem install'.

* guix/build/ruby-build-system.scm (install): Remove cached gem after install.
---
 guix/build/ruby-build-system.scm | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index 2685da1..b020272 100644
--- a/guix/build/ruby-build-system.scm
+++ b/guix/build/ruby-build-system.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <da...@gnu.org>
 ;;; Copyright © 2015 Pjotr Prins <pjotr.publi...@thebird.nl>
+;;; Copyright © 2015 Ben Woodcroft <donttrust...@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -115,15 +116,19 @@ GEM-FLAGS are passed to the 'gem' invokation, if present."
                                          (assoc-ref inputs "ruby"))
                            1))
          (out (assoc-ref outputs "out"))
-         (gem-home (string-append out "/lib/ruby/gems/" ruby-version ".0")))
-
+         (gem-home (string-append out "/lib/ruby/gems/" ruby-version ".0"))
+         (gem-name (first-matching-file "\\.gem$")))
     (setenv "GEM_HOME" gem-home)
     (mkdir-p gem-home)
-    (zero? (apply system* "gem" "install" (first-matching-file "\\.gem$")
-                  "--local" "--ignore-dependencies"
-                  ;; Executables should go into /bin, not /lib/ruby/gems.
-                  "--bindir" (string-append out "/bin")
-                  gem-flags))))
+    (apply system* "gem" "install" gem-name
+           "--local" "--ignore-dependencies"
+           ;; Executables should go into /bin, not /lib/ruby/gems.
+           "--bindir" (string-append out "/bin")
+           gem-flags)
+    ;; Remove the cached gem file as this is unnecessary and contains
+    ;; timestamped files rendering builds not reproducible.
+    (delete-file (string-append gem-home "/cache/" gem-name))
+    #t))
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases
-- 
2.6.3

Reply via email to