guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] build-system/perl: Add wrap phase.


From: Ludovic Courtès
Subject: Re: [PATCH] build-system/perl: Add wrap phase.
Date: Sun, 13 Nov 2016 13:23:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Alex Sassmannshausen <address@hidden> 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’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]