[PATCH] build: perl-build-system: Add `wrap' phase.

  • Done
  • quality assurance status badge
Details
4 participants
  • Arun Isaac
  • Jonathan Brielmaier
  • Ludovic Courtès
  • Marius Bakke
Owner
unassigned
Submitted by
Arun Isaac
Severity
normal
A
A
Arun Isaac wrote on 27 Mar 2017 21:38
(address . guix-patches@gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
3389aacc.ADsAAG-tXNgAAAAAAAAAAAOtUOAAAAACwQwAAAAAAAW9WABY2Wpd@mailjet.com
* guix/build/perl-build-system.scm (wrap): New procedure.
(%standard-phases): Add it.
---
guix/build/perl-build-system.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (57 lines)
diff --git a/guix/build/perl-build-system.scm b/guix/build/perl-build-system.scm
index 8f480eae1..32ef86b65 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))
@@ -68,6 +71,31 @@
(define-w/gnu-fallback* (install)
(zero? (system* "./Build" "install")))
+(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 `("PERL5LIB" prefix
+ ,(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 %standard-phases
;; Everything is as with the GNU Build System except for the `configure',
;; `build', `check', and `install' phases.
@@ -75,6 +103,7 @@
(replace 'install install)
(replace 'check check)
(replace 'build build)
+ (add-after 'install 'wrap wrap)
(replace 'configure configure)))
(define* (perl-build #:key inputs (phases %standard-phases)
--
2.11.0
A
A
Arun Isaac wrote on 27 Mar 2017 21:49
(address . 26275@debbugs.gnu.org)
d3615c29.AEUAITWsO4EAAAAAAAAAAAOwQVoAAAACwQwAAAAAAAW9WABY2WzM@mailjet.com
As discussed earlier at bug 26203
`wrap' phase to the perl-build-system. Please consider this a first
iteration and provide feedback.
A
A
Arun Isaac wrote on 28 Mar 2017 16:33
(address . 26275@debbugs.gnu.org)
f5525e2f.AEAAIZKx6N0AAAAAAAAAAAOwQVoAAAACwQwAAAAAAAW9WABY2nQ0@mailjet.com
Toggle quote (25 lines)
> +(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 `("PERL5LIB" prefix
> + ,(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)))

I copied this wrap function from the python build system, and modified
it a little to suite perl. Is there any reason `list-of-files' and
`bindirs' are initialized using `define' rather than a `let' binding?
This is probably a very basic Guile question, but still...

Thanks,
Arun Isaac.
M
M
Marius Bakke wrote on 28 Mar 2017 17:18
Re: bug#26275: [PATCH] build: perl-build-system: Add `wrap' phase.
87lgrptop7.fsf@kirby.i-did-not-set--mail-host-address--so-tickle-me
Hello!

I can't study the code right now, but at a glance it looks like this
will also include native-inputs in PERL5LIB. Can you try to filter them
out?

Doing that will effectively also solve

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (63 lines)
> * guix/build/perl-build-system.scm (wrap): New procedure.
> (%standard-phases): Add it.
> ---
> guix/build/perl-build-system.scm | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/guix/build/perl-build-system.scm b/guix/build/perl-build-system.scm
> index 8f480eae1..32ef86b65 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))
>
> @@ -68,6 +71,31 @@
> (define-w/gnu-fallback* (install)
> (zero? (system* "./Build" "install")))
>
> +(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 `("PERL5LIB" prefix
> + ,(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 %standard-phases
> ;; Everything is as with the GNU Build System except for the `configure',
> ;; `build', `check', and `install' phases.
> @@ -75,6 +103,7 @@
> (replace 'install install)
> (replace 'check check)
> (replace 'build build)
> + (add-after 'install 'wrap wrap)
> (replace 'configure configure)))
>
> (define* (perl-build #:key inputs (phases %standard-phases)
> --
> 2.11.0
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAljafrQACgkQoqBt8qM6
VPoaxwgAovh4FZ4VyPEGx+eV0vEC5IDSwUmGCdOZ5ditnNk94x238bueOpGMfHcm
crtWL9SkFsHE/r9WO6bjyYqB+zkSLiBrRGG0e4hMJFCIgtpGG+iip91q2OjhapYj
sQnsDUrENaVeIsOUKN36VB7aE7Zyq6YP5MYdnPdM/XKmA6/rJbNEHjh8x5p8aFwz
7/p3MnrWqfzubJcktJ5j/RpCqpiPNKKPJJuzge5+YmmA9MxEbTKUExtbMWofY7qs
+T6a7KjfqfN6e+WOoFFxYZXM5/KEGH5ItLYIQLEby+rdUwzsc/9emYuJ/BbKQ1yk
ibWh5VTuJD0wVEWRO5Gok0iXNIk0WQ==
=TgsL
-----END PGP SIGNATURE-----

A
A
Arun Isaac wrote on 28 Mar 2017 19:02
(address . 26275@debbugs.gnu.org)
3061ffaa.AEUAIU7oXLoAAAAAAAAAAAOwQVoAAAACwQwAAAAAAAW9WABY2pcQ@mailjet.com
Toggle quote (7 lines)
> I can't study the code right now, but at a glance it looks like this
> will also include native-inputs in PERL5LIB. Can you try to filter them
> out?
>
> Doing that will effectively also solve
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25235 . Patch welcome! :)

Yes, I'll do this! :-) I'll first send a patch for bug 25235, we'll
close that, and then come back here.
L
L
Ludovic Courtès wrote on 10 Apr 2017 23:53
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 26275@debbugs.gnu.org)
87pogkdj5v.fsf@gnu.org
Hi,

And sorry for the delay.

Arun Isaac <arunisaac@systemreboot.net> skribis:

Toggle quote (30 lines)
>> +(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 `("PERL5LIB" prefix
>> + ,(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)))
>
> I copied this wrap function from the python build system, and modified
> it a little to suite perl. Is there any reason `list-of-files' and
> `bindirs' are initialized using `define' rather than a `let' binding?
> This is probably a very basic Guile question, but still...

It’s purely cosmetic in this case: it makes them more visible and fits
within the 80-column limit. :-)

Technically:

(define (proc x y)
(define a …)
(define b …)
body …)

is equivalent to:

(define (proc x y)
(letrec ((a …)
(b …))
body …))


HTH!

Ludo’.
L
L
Ludovic Courtès wrote on 2 Jun 2017 18:33
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 26275@debbugs.gnu.org)
87k24u4ae9.fsf@gnu.org
Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> skribis:

Toggle quote (10 lines)
>> I can't study the code right now, but at a glance it looks like this
>> will also include native-inputs in PERL5LIB. Can you try to filter them
>> out?
>>
>> Doing that will effectively also solve
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25235 . Patch welcome! :)
>
> Yes, I'll do this! :-) I'll first send a patch for bug 25235, we'll
> close that, and then come back here.

What’s the status of this patch? It might still be time for
‘core-updates’ if it’s ready…

Ludo’.
A
A
Arun Isaac wrote on 2 Jun 2017 19:40
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 26275@debbugs.gnu.org)
17c2c1e9.AEMALAS8b-IAAAAAAAAAAAOwQVoAAAACwQwAAAAAAAW9WABZMaMj@mailjet.com
Toggle quote (3 lines)
> What’s the status of this patch? It might still be time for
> ‘core-updates’ if it’s ready…

I don't have a solution for the native-inputs being included in the
wrap. Without that, I can deliver a patch. I've just been waiting for
someone to figure out the native-inputs problem. This problem is shared
with the python wrap phase as well.


But, Alex Sassmannshausen has a generalized wrap phase for python and
I think we should close this bug report and bug 25235 to use his
patches. He too does not have a solution for the native-inputs problem.
J
J
Jonathan Brielmaier wrote on 16 Nov 2020 19:03
[PATCH] build: perl-build-system: Add `wrap' phase.
(address . 26275-done@debbugs.gnu.org)
205927f7-8628-04b7-4f7a-6bfb3da273cc@web.de
Functionality was added in 0fb9a8df429a7b9f40610ff15baaff0d8e31e8cf by
Ricardo.
Closed
?