Message ID | 20161112172446.5571-2-alex@pompo.co |
---|---|
State | New |
Headers | show |
Alex Sassmannshausen <alex.sassmannshausen@gmail.com> skribis: > * guix/build/perl-build-system.scm (wrap): New procedure. > (%standard-phases): Declare new phase, `wrap`, and use `wrap` > procedure. Nice! > +(define* (wrap #:key inputs outputs #:allow-other-keys) Please add a docstring, even if the original code didn’t have one. ;-) > + (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))) Please have it return #t explicitly, for clarity. Otherwise LGTM! There are 479 packages using ‘perl-build-system’ but in total 1,159 packages are affected: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(gnu packages) scheme@(guile-user)> ,use(guix build-system perl) scheme@(guile-user)> ,use(guix) scheme@(guile-user)> (fold-packages (lambda (p n) (if (eq? (package-build-system p) perl-build-system) (+ 1 n) n)) 0) $2 = 479 scheme@(guile-user)> ,use(guix graph) scheme@(guile-user)> ,use(guix scripts graph) scheme@(guile-user)> ,enter-store-monad store-monad@(guile-user) [1]> (node-back-edges %package-node-type (fold-packages cons '())) $3 = #<procedure 5d0fee0 at guix/graph.scm:87:17 (node)> store-monad@(guile-user) [1]> ,q scheme@(guile-user)> (node-reachable-count (fold-packages (lambda (p l) (if (eq? (package-build-system p) perl-build-system) (cons p l) l)) '()) $3) $4 = 1159 --8<---------------cut here---------------end--------------->8--- So I think this should go to ‘core-updates’. We should probably factorize this in (guix build utils) eventually and have both python-build-system and perl-build-system use it. Like: (wrap-language-programs directories "PERL5LIB" (cons (string-append …) (search-path-as-string->list …))) Thanks! Ludo’.
Am 13.11.2016 um 13:23 schrieb Ludovic Courtès: > We should probably factorize this in (guix build utils) eventually and > have both python-build-system and perl-build-system use it. Like: Since we are preparing the new python build system, now would be a good time for doing so :-)
On Sun, Nov 13, 2016 at 04:11:07PM +0100, Hartmut Goebel wrote: > Am 13.11.2016 um 13:23 schrieb Ludovic Courtès: > > We should probably factorize this in (guix build utils) eventually and > > have both python-build-system and perl-build-system use it. Like: > > Since we are preparing the new python build system, now would be a good > time for doing so :-) Swerve of subject: Hartmut, can you merge the master branch into wip-python-build-system, delete wip-python-build-system on Savannah and push the newly updated branch as python-build-system? Perhaps it's also okay to just rebase on top of the new master. Wip-* branches indicate that history can be broken, in my opinion. It's up to you.
Am 13.11.2016 um 21:05 schrieb Leo Famulari: > Swerve of subject: Hartmut, can you merge the master branch into > wip-python-build-system, delete wip-python-build-system on Savannah and > push the newly updated branch as python-build-system? > > Perhaps it's also okay to just rebase on top of the new master. Wip-* > branches indicate that history can be broken, in my opinion. > > It's up to you. I'll rebase on top of master later this week.
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)))