From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] build-system/perl: Add wrap phase. Date: Sun, 13 Nov 2016 13:23:54 +0100 Message-ID: <87a8d3h8kl.fsf@gnu.org> References: <20161112172446.5571-1-alex@pompo.co> <20161112172446.5571-2-alex@pompo.co> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5tpK-0006nU-Lf for guix-devel@gnu.org; Sun, 13 Nov 2016 07:24:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5tpJ-00056B-Nf for guix-devel@gnu.org; Sun, 13 Nov 2016 07:24:02 -0500 In-Reply-To: <20161112172446.5571-2-alex@pompo.co> (Alex Sassmannshausen's message of "Sat, 12 Nov 2016 18:24:46 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Alex Sassmannshausen Cc: guix-devel@gnu.org, Alex Sassmannshausen Alex Sassmannshausen 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=E2=80=99t 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=E2=80=99s, we as= sume 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 =E2=80=98perl-build-system=E2=80=99 but in tot= al 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 =3D 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 =3D # 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 =3D 1159 --8<---------------cut here---------------end--------------->8--- So I think this should go to =E2=80=98core-updates=E2=80=99. 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 =E2=80=A6) (search-path-as-string->list =E2=80=A6))) Thanks! Ludo=E2=80=99.