summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Woodcroft <donttrustben@gmail.com>2015-12-30 10:27:33 +1000
committerRicardo Wurmus <ricardo.wurmus@mdc-berlin.de>2016-01-06 12:42:41 +0100
commit7266848ace1da9b43c3a06bf4c942c56d4ba3d6a (patch)
treeda7ddac6063c113308e301a47586bb336292a80c
parenta243e12aba1dccbe5e67be8feb2337bdf8bfba71 (diff)
downloadguix-7266848ace1da9b43c3a06bf4c942c56d4ba3d6a.tar.gz
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.
-rw-r--r--guix/build/ruby-build-system.scm19
1 files changed, 12 insertions, 7 deletions
diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index 2685da1a72..6439bf69eb 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 <davet@gnu.org>
 ;;; Copyright © 2015 Pjotr Prins <pjotr.public01@thebird.nl>
+;;; Copyright © 2015 Ben Woodcroft <donttrustben@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))))
+    (and (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.
+         (begin (delete-file (string-append gem-home "/cache/" gem-name))
+                #t))))
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases