From: Christopher Baines <mail@cbaines.net>
To: 28773@debbugs.gnu.org
Subject: [bug#28773] [PATCH 2/3] ruby-build-system: Add a new wrap phase.
Date: Tue, 10 Oct 2017 08:47:04 +0100 [thread overview]
Message-ID: <20171010074705.5676-2-mail@cbaines.net> (raw)
In-Reply-To: <20171010074705.5676-1-mail@cbaines.net>
Wrap files in bin/ and sbin/ with the location of the gem itself (GEM_HOME)
and the location of any other gems in use (GEM_PATH). This ensures that the
bin files will run with the right environment when executed.
It does however mean that native-inputs will also get wrapped up in any
binaries, which is not good, as it increases the size of the closure, and
risks this code being used at runtime.
* guix/build/ruby-build-system.scm (wrap): New procedure.
(%standard-phases): Add the wrap phase.
---
guix/build/ruby-build-system.scm | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index af193b9ce..b6f0fc941 100644
--- a/guix/build/ruby-build-system.scm
+++ b/guix/build/ruby-build-system.scm
@@ -21,6 +21,7 @@
(define-module (guix build ruby-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build utils)
+ #:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:use-module (ice-9 regex)
@@ -269,6 +270,30 @@ extended with definitions for VARS."
(chmod prog-tmp #o755)
(rename-file prog-tmp prog))))
+(define* (wrap #:key inputs outputs #:allow-other-keys)
+ (define (list-of-files dir)
+ (map (cut string-append dir "/" <>)
+ (or (scandir dir (lambda (f)
+ (let ((s (stat (string-append dir "/" f))))
+ (eq? 'regular (stat:type s)))))
+ '())))
+
+ (define bindirs
+ (append-map (match-lambda
+ ((_ . dir)
+ (list (string-append dir "/bin")
+ (string-append dir "/sbin"))))
+ outputs))
+
+ (let* ((out (assoc-ref outputs "out"))
+ (var `("GEM_PATH" prefix
+ (,(getenv "GEM_HOME") ,(getenv "GEM_PATH")))))
+ (for-each (lambda (dir)
+ (let ((files (list-of-files dir)))
+ (for-each (cut wrap-ruby-program <> var)
+ files)))
+ bindirs)))
+
(define (log-file-deletion file)
(display (string-append "deleting '" file "' for reproducibility\n")))
@@ -280,7 +305,8 @@ extended with definitions for VARS."
(add-after 'extract-gemspec 'replace-git-ls-files replace-git-ls-files)
(replace 'build build)
(replace 'check check)
- (replace 'install install)))
+ (replace 'install install)
+ (add-after 'install 'wrap wrap)))
(define* (ruby-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.14.2
next prev parent reply other threads:[~2017-10-10 7:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 7:44 [bug#28773] [PATCH] Wrap bin files in the ruby build system Christopher Baines
2017-10-10 7:47 ` [bug#28773] [PATCH 1/3] ruby-build-system: Add wrap-ruby-program Christopher Baines
2017-10-10 7:47 ` Christopher Baines [this message]
2017-10-10 7:47 ` [bug#28773] [PATCH 3/3] gnu: Remove redundant wrapping from packages using ruby-build-system Christopher Baines
2017-10-16 13:19 ` [bug#28773] [PATCH] Wrap bin files in the ruby build system Ludovic Courtès
2017-10-18 10:39 ` Ben Woodcroft
2018-01-11 21:47 ` Ludovic Courtès
2018-01-12 6:51 ` Ben Woodcroft
2018-01-14 22:22 ` Christopher Baines
2018-01-14 22:22 ` Christopher Baines
2018-01-14 22:25 ` bug#28773: [PATCH] Specify native search path for all ruby packages Christopher Baines
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=20171010074705.5676-2-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=28773@debbugs.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.