From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Enge Subject: Re: #!/usr/bin/env perl Date: Fri, 22 Feb 2013 23:13:24 +0100 Message-ID: <201302222313.25004.andreas@enge.fr> References: <201301262131.48844.andreas@enge.fr> <874ni3ejmr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_E2+JRUEI+ATmVxL" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U90sC-00022B-MJ for bug-guix@gnu.org; Fri, 22 Feb 2013 17:13:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U90s4-00029j-QP for bug-guix@gnu.org; Fri, 22 Feb 2013 17:13:44 -0500 In-Reply-To: <874ni3ejmr.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: bug-guix@gnu.org --Boundary-00=_E2+JRUEI+ATmVxL Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Am Samstag, 26. Januar 2013 schrieb Ludovic Court=C3=A8s: > The function you want to patch ;-) is =E2=80=98patch-shebang=E2=80=99 in > build/utils.scm. Since that entails a full rebuild, that=E2=80=99s somet= hing > for a new =E2=80=98core-updates=E2=80=99 branch. Please find attached a patch for review. I tested it on a few example=20 files, but not yet with a real packet - I am waiting for the full rebuild=20 ;-) Andreas --Boundary-00=_E2+JRUEI+ATmVxL Content-Type: text/x-patch; charset="UTF-8"; name="0001-Patch-shebang-Handle-usr-bin-env-command.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Patch-shebang-Handle-usr-bin-env-command.patch" =46rom b4763457c1127a3c910dc3d28f1ce933175a8be0 Mon Sep 17 00:00:00 2001 =46rom: Andreas Enge Date: Fri, 22 Feb 2013 23:00:41 +0100 Subject: [PATCH] Patch-shebang: Handle "#!/usr/bin/env command" * guix/build/utils.scm (patch-shebang): Handle replacement of "#!.*/env CMD ARGS" by "#!/nix/store/path/.../to/CMD ARGS". =2D-- guix/build/utils.scm | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 6921e31..bab82fe 100644 =2D-- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -426,7 +426,7 @@ bytes transferred and the continuation of the transfer = as a thunk." (stat:mtimensec stat))) =20 (define patch-shebang =2D (let ((shebang-rx (make-regexp "^[[:blank:]]*([[:graph:]]+)(.*)$"))) + (let ((shebang-rx (make-regexp "^[[:blank:]]*([[:graph:]]+)[[:blank:]]*(= [[:graph:]]*)(.*)$"))) (lambda* (file #:optional (path (search-path-as-string->list (getenv "PATH"))) @@ -465,16 +465,27 @@ FILE are kept unchanged." (let ((line (false-if-exception (read-line p)))) (and=3D> (and line (regexp-exec shebang-rx line)) (lambda (m) =2D (let* ((cmd (match:substring m 1)) =2D (bin (search-path path (basename cmd)))) + (let* ((first (match:substring m 1)) + (second (match:substring m 2)) + (third (match:substring m 3)) + (has-env (string=3D? (string-pad first 4)= "/env")) + (cmd (if has-env second (basename first))) + (bin (search-path path cmd))) (if bin =2D (if (string=3D? bin cmd) + (if (string=3D? bin first) #f ; nothing to do =2D (begin =2D (format (current-error-port) =2D "patch-shebang: ~a: changi= ng `~a' to `~a'~%" =2D file cmd bin) =2D (patch p bin (match:substring m 2)= ))) + (if has-env + (begin + (format (current-error-port) + "patch-shebang: ~a: changi= ng `~a' to `~a'~%" + file (string-append first = " " second) bin) + (patch p bin third)) + (begin=20 + (format (current-error-port) + "patch-shebang: ~a: changi= ng `~a' to `~a'~%" + file first bin) + (patch p bin + (string-append " " second third)= )))) (begin (format (current-error-port) "patch-shebang: ~a: warning: no = binary for interpreter `~a' found in $PATH~%" =2D-=20 1.7.10.4 --Boundary-00=_E2+JRUEI+ATmVxL--