mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 22:08:16 -05:00
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.
This commit is contained in:
parent
ed5940b617
commit
edf0a45846
1 changed files with 32 additions and 6 deletions
|
@ -120,18 +120,44 @@ (define* (install #:key inputs outputs (gem-flags '())
|
||||||
1))
|
1))
|
||||||
(out (assoc-ref outputs "out"))
|
(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$")))
|
(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)
|
(setenv "GEM_HOME" gem-home)
|
||||||
(mkdir-p gem-home)
|
(mkdir-p gem-home)
|
||||||
(and (apply system* "gem" "install" gem-name
|
(and (apply system* "gem" "install" gem-file
|
||||||
"--local" "--ignore-dependencies"
|
"--local" "--ignore-dependencies"
|
||||||
;; Executables should go into /bin, not /lib/ruby/gems.
|
;; Executables should go into /bin, not /lib/ruby/gems.
|
||||||
"--bindir" (string-append out "/bin")
|
"--bindir" (string-append out "/bin")
|
||||||
gem-flags)
|
gem-flags)
|
||||||
;; Remove the cached gem file as this is unnecessary and contains
|
(begin
|
||||||
;; timestamped files rendering builds not reproducible.
|
;; Remove the cached gem file as this is unnecessary and contains
|
||||||
(begin (delete-file (string-append gem-home "/cache/" gem-name))
|
;; timestamped files rendering builds not reproducible.
|
||||||
#t))))
|
(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
|
(define %standard-phases
|
||||||
(modify-phases gnu:%standard-phases
|
(modify-phases gnu:%standard-phases
|
||||||
|
|
Loading…
Reference in a new issue