From: Ben Woodcroft <donttrustben@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 1/3] guix: ruby-build-system: Build compiled gems reproducibly.
Date: Wed, 10 Aug 2016 13:33:23 +1000 [thread overview]
Message-ID: <20160810033325.3880-2-donttrustben@gmail.com> (raw)
In-Reply-To: <20160810033325.3880-1-donttrustben@gmail.com>
* 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
--
2.9.1
next prev parent reply other threads:[~2016-08-10 3:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 3:33 [PATCH 0/3]; ruby-build-system improvements Ben Woodcroft
2016-08-10 3:33 ` Ben Woodcroft [this message]
2016-08-18 10:06 ` [PATCH 1/3] guix: ruby-build-system: Build compiled gems reproducibly Ricardo Wurmus
2016-08-30 1:08 ` Ben Woodcroft
2016-08-10 3:33 ` [PATCH 2/3] guix: ruby-build-system: Add replace-git-ls-files Ben Woodcroft
2016-08-10 3:33 ` [PATCH 3/3] gnu: ruby-concurrent: Adjust for 'replace-git-ls-files' Ben Woodcroft
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160810033325.3880-2-donttrustben@gmail.com \
--to=donttrustben@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.