[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] build/utils: Add `wrap-language-programs`.
From: |
Alex Sassmannshausen |
Subject: |
[PATCH 1/3] build/utils: Add `wrap-language-programs`. |
Date: |
Wed, 16 Nov 2016 14:27:32 +0100 |
* guix/build/utils.scm (wrap-language-programs): New procedure.
---
guix/build/utils.scm | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index bc6f114..b14f96b 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -75,6 +75,7 @@
patch-/usr/bin/file
fold-port-matches
remove-store-references
+ wrap-language-programs
wrap-program
locale-category->string))
@@ -918,6 +919,41 @@ known as `nuke-refs' in Nixpkgs."
(put-u8 out (char->integer char))
result))))))
+(define (wrap-language-programs path-proc env-var)
+ "Return a procedure, which, invoked as part of a `wrap' phase, is capable of
+wrapping executables inside an environment in which ENV-VAR is correctly set.
+
+The string ENV-VAR is the name of the environmental variable we are setting
+for the executable we are wrapping. PATH-PROC is a procedure of 2 arguments,
+`inputs' and `outputs', returning the value that we should send ENV-VAR to.
+
+This is a specialized version of `wrap-program' below, intended specifically
+to grant all executables that are part of our output access to all libraries
+that were declared in our inputs. This is of use for languages such as Perl,
+Python and Guile."
+ (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)))))
+ '())))
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (define bindirs
+ (append-map (match-lambda
+ ((_ . dir)
+ (list (string-append dir "/bin")
+ (string-append dir "/sbin"))))
+ outputs))
+ (define vars
+ `(,env-var prefix ,(cons (path-proc inputs outputs)
+ (search-path-as-string->list
+ (or (getenv env-var) "")))))
+ (for-each (lambda (dir)
+ (let ((files (list-of-files dir)))
+ (for-each (cut wrap-program <> vars)
+ files)))
+ bindirs)))
+
(define* (wrap-program prog #:rest vars)
"Make a wrapper for PROG. VARS should look like this:
--
2.10.2
- [PATCH 0/3] Add a generalized `wrap-language-programs`, Alex Sassmannshausen, 2016/11/16
- [PATCH 2/3] build/perl-build-system: Add `wrap` phase., Alex Sassmannshausen, 2016/11/16
- [PATCH 1/3] build/utils: Add `wrap-language-programs`.,
Alex Sassmannshausen <=
- [PATCH 3/3] build/python-build-system: Refactor `wrap`., Alex Sassmannshausen, 2016/11/16
- Message not available
- Re: [PATCH 0/3] Add a generalized `wrap-language-programs`, Alex Sassmannshausen, 2016/11/17
- Re: [PATCH 0/3] Add a generalized `wrap-language-programs`, Leo Famulari, 2016/11/17
- Re: [PATCH 0/3] Add a generalized `wrap-language-programs`, Alex Sassmannshausen, 2016/11/18
- Re: [PATCH 0/3] Add a generalized `wrap-language-programs`, Leo Famulari, 2016/11/18
- Re: [PATCH 0/3] Add a generalized `wrap-language-programs`, Alex Sassmannshausen, 2016/11/18
- Re: [PATCH 0/3] Add a generalized `wrap-language-programs`, Hartmut Goebel, 2016/11/18