all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Wrap binaries in perl build system.
@ 2016-11-12 17:24 Alex Sassmannshausen
  2016-11-12 17:24 ` [PATCH] build-system/perl: Add wrap phase Alex Sassmannshausen
  2016-11-16  4:39 ` [PATCH] Wrap binaries in perl build system Eric Bavier
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Sassmannshausen @ 2016-11-12 17:24 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Sassmannshausen

Hello,

Perl, like Python and Guile, uses an environmental variable to make libraries
accessible to binaries.  For this purpose, binaries need to be wrapped with an
executable which sets the env variable appropriately.

This patch implements the same functionality that the Python build side code
already has (I pretty much lifted it from there).

This works nicely in my tests (a package I will submit once this has been
merged).

Comments welcome,

Alex

Alex Sassmannshausen (1):
  build-system/perl: Add wrap phase.

 guix/build/perl-build-system.scm | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

-- 
2.10.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] build-system/perl: Add wrap phase.
  2016-11-12 17:24 [PATCH] Wrap binaries in perl build system Alex Sassmannshausen
@ 2016-11-12 17:24 ` Alex Sassmannshausen
  2016-11-13 12:23   ` Ludovic Courtès
  2016-11-16  4:39 ` [PATCH] Wrap binaries in perl build system Eric Bavier
  1 sibling, 1 reply; 7+ messages in thread
From: Alex Sassmannshausen @ 2016-11-12 17:24 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Sassmannshausen

* 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] build-system/perl: Add wrap phase.
  2016-11-12 17:24 ` [PATCH] build-system/perl: Add wrap phase Alex Sassmannshausen
@ 2016-11-13 12:23   ` Ludovic Courtès
  2016-11-13 15:11     ` Hartmut Goebel
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2016-11-13 12:23 UTC (permalink / raw)
  To: Alex Sassmannshausen; +Cc: guix-devel, Alex Sassmannshausen

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’.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] build-system/perl: Add wrap phase.
  2016-11-13 12:23   ` Ludovic Courtès
@ 2016-11-13 15:11     ` Hartmut Goebel
  2016-11-13 20:05       ` Leo Famulari
  0 siblings, 1 reply; 7+ messages in thread
From: Hartmut Goebel @ 2016-11-13 15:11 UTC (permalink / raw)
  To: guix-devel

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 :-)

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] build-system/perl: Add wrap phase.
  2016-11-13 15:11     ` Hartmut Goebel
@ 2016-11-13 20:05       ` Leo Famulari
  2016-11-13 21:41         ` Hartmut Goebel
  0 siblings, 1 reply; 7+ messages in thread
From: Leo Famulari @ 2016-11-13 20:05 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: guix-devel

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] build-system/perl: Add wrap phase.
  2016-11-13 20:05       ` Leo Famulari
@ 2016-11-13 21:41         ` Hartmut Goebel
  0 siblings, 0 replies; 7+ messages in thread
From: Hartmut Goebel @ 2016-11-13 21:41 UTC (permalink / raw)
  To: Leo Famulari; +Cc: guix-devel

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.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Wrap binaries in perl build system.
  2016-11-12 17:24 [PATCH] Wrap binaries in perl build system Alex Sassmannshausen
  2016-11-12 17:24 ` [PATCH] build-system/perl: Add wrap phase Alex Sassmannshausen
@ 2016-11-16  4:39 ` Eric Bavier
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Bavier @ 2016-11-16  4:39 UTC (permalink / raw)
  To: Alex Sassmannshausen; +Cc: guix-devel, Alex Sassmannshausen

On Sat, 12 Nov 2016 18:24:45 +0100
Alex Sassmannshausen <alex.sassmannshausen@gmail.com> wrote:

> Hello,
> 
> Perl, like Python and Guile, uses an environmental variable to make libraries
> accessible to binaries.  For this purpose, binaries need to be wrapped with an
> executable which sets the env variable appropriately.
> 
> This patch implements the same functionality that the Python build side code
> already has (I pretty much lifted it from there).
> 
> This works nicely in my tests (a package I will submit once this has been
> merged).
> 
> Comments welcome,

I don't recall specifically why this hasn't been done all along, but
IIRC there was some concern that, perl coming up in so many places as
it does, setting the perl environment variable at the application level
could adversely pollute the environments of packages farther down.

I don't know of any examples where this has actually caused problems,
however, so I'd support building a branch and seeing what happens.

2cents,
`~Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-16  4:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-12 17:24 [PATCH] Wrap binaries in perl build system Alex Sassmannshausen
2016-11-12 17:24 ` [PATCH] build-system/perl: Add wrap phase Alex Sassmannshausen
2016-11-13 12:23   ` Ludovic Courtès
2016-11-13 15:11     ` Hartmut Goebel
2016-11-13 20:05       ` Leo Famulari
2016-11-13 21:41         ` Hartmut Goebel
2016-11-16  4:39 ` [PATCH] Wrap binaries in perl build system Eric Bavier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.