[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] build-system/perl: Add wrap phase.
From: |
Alex Sassmannshausen |
Subject: |
[PATCH] build-system/perl: Add wrap phase. |
Date: |
Sat, 12 Nov 2016 18:24:46 +0100 |
* guix/build/perl-build-system.scm (wrap): New procedure.
(%standard-phases): Declare new phase, `wrap`, and use `wrap`
procedure.
---
guix/build/perl-build-system.scm | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/guix/build/perl-build-system.scm b/guix/build/perl-build-system.scm
index 8f480ea..194d76b 100644
--- a/guix/build/perl-build-system.scm
+++ b/guix/build/perl-build-system.scm
@@ -19,7 +19,10 @@
(define-module (guix build perl-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 (srfi srfi-1)
+ #:use-module (srfi srfi-26)
#:export (%standard-phases
perl-build))
@@ -47,6 +50,36 @@
(format #t "running `perl' with arguments ~s~%" args)
(zero? (apply system* "perl" args))))
+(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"))
+ (perl (assoc-ref inputs "perl"))
+ (var `("PERL5LIB" prefix
+ ,(cons (string-append out "/lib/perl5/site_perl/"
+ ;; Like in python’s, we assume version
+ ;; at end of `perl' string.
+ (last (string-split perl #\-)))
+ (search-path-as-string->list
+ (or (getenv "PERL5LIB") ""))))))
+ (for-each (lambda (dir)
+ (let ((files (list-of-files dir)))
+ (for-each (cut wrap-program <> var)
+ files)))
+ bindirs)))
+
(define-syntax-rule (define-w/gnu-fallback* (name args ...) body ...)
(define* (name args ... #:rest rest)
(if (access? "Build" X_OK)
@@ -70,9 +103,11 @@
(define %standard-phases
;; Everything is as with the GNU Build System except for the `configure',
- ;; `build', `check', and `install' phases.
+ ;; `build', `check', and `install' phases. We also add a `wrap' phase to
+ ;; wrap perl binaries with a complete PERL5LIB path.
(modify-phases gnu:%standard-phases
(replace 'install install)
+ (add-after 'install 'wrap wrap)
(replace 'check check)
(replace 'build build)
(replace 'configure configure)))
--
2.10.1
Re: [PATCH] Wrap binaries in perl build system., Eric Bavier, 2016/11/15