[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/13: guix: ruby-build-system: Build compiled gems reproducibly.
From: |
Ben Woodcroft |
Subject: |
01/13: guix: ruby-build-system: Build compiled gems reproducibly. |
Date: |
Wed, 10 Aug 2016 11:57:34 +0000 (UTC) |
benwoodcroft pushed a commit to branch wip-rails
in repository guix.
commit 2acb5e527aa56edb3123bb641bb32d3d60320e0b
Author: Ben Woodcroft <address@hidden>
Date: Wed Aug 10 12:23:59 2016 +1000
guix: ruby-build-system: Build compiled gems reproducibly.
* guix/build/ruby-build-system.scm (log-file-deletion): New procedure.
(install): Remove files containing non-reproducible elements. Print when
each
file is deleted.
---
guix/build/ruby-build-system.scm | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index 79ac380..95793f7 100644
--- a/guix/build/ruby-build-system.scm
+++ b/guix/build/ruby-build-system.scm
@@ -120,18 +120,44 @@ GEM-FLAGS are passed to the 'gem' invokation, if present."
1))
(out (assoc-ref outputs "out"))
(gem-home (string-append out "/lib/ruby/gems/" ruby-version ".0"))
- (gem-name (first-matching-file "\\.gem$")))
+ (gem-file (first-matching-file "\\.gem$"))
+ (gem-file-basename (basename gem-file))
+ (gem-name (substring gem-file-basename
+ 0
+ (- (string-length gem-file-basename) 4)))
+ (gem-directory (string-append gem-home "/gems/" gem-name)))
(setenv "GEM_HOME" gem-home)
(mkdir-p gem-home)
- (and (apply system* "gem" "install" gem-name
+ (and (apply system* "gem" "install" gem-file
"--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))))
+ (begin
+ ;; Remove the cached gem file as this is unnecessary and contains
+ ;; timestamped files rendering builds not reproducible.
+ (let ((cached-gem (string-append gem-home "/cache/" gem-file)))
+ (log-file-deletion cached-gem)
+ (delete-file cached-gem))
+ ;; For gems with native extensions, several Makefile-related files
+ ;; are created that contain timestamps or other elements making
+ ;; them not reproducible. They are unnecessary so we remove them.
+ (if (file-exists? (string-append gem-directory "/ext"))
+ (begin
+ (for-each (lambda (file)
+ (log-file-deletion file)
+ (delete-file file))
+ (append
+ (find-files (string-append gem-home "/doc")
+ "page-Makefile.ri")
+ (find-files (string-append gem-home "/extensions")
+ "gem_make.out")
+ (find-files (string-append gem-directory "/ext")
+ "Makefile")))))
+ #t))))
+
+(define (log-file-deletion file)
+ (display (string-append "deleting '" file "' for reproducibility\n")))
(define %standard-phases
(modify-phases gnu:%standard-phases
- branch wip-rails created (now 9a46eda), Ben Woodcroft, 2016/08/10
- 03/13: gnu: ruby-concurrent: Adjust for 'replace-git-ls-files'., Ben Woodcroft, 2016/08/10
- 01/13: guix: ruby-build-system: Build compiled gems reproducibly.,
Ben Woodcroft <=
- 04/13: gnu: Add ruby-asciimath., Ben Woodcroft, 2016/08/10
- 02/13: guix: ruby-build-system: Add replace-git-ls-files., Ben Woodcroft, 2016/08/10
- 09/13: gnu: Add ruby-creole., Ben Woodcroft, 2016/08/10
- 11/13: gnu: Add ruby-erubis., Ben Woodcroft, 2016/08/10
- 07/13: gnu: Add ruby-rack-protection., Ben Woodcroft, 2016/08/10
- 12/13: gnu: Add ruby-ruby-engine., Ben Woodcroft, 2016/08/10
- 06/13: gnu: Add ruby-rack-test., Ben Woodcroft, 2016/08/10
- 10/13: gnu: Add ruby-sporkmonger-rack-mount., Ben Woodcroft, 2016/08/10
- 05/13: gnu: Add ruby-asciidoctor., Ben Woodcroft, 2016/08/10
- 08/13: gnu: Add ruby-contest., Ben Woodcroft, 2016/08/10