From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Enge Subject: Re: #!/usr/bin/env perl Date: Sat, 23 Feb 2013 17:21:26 +0100 Message-ID: <201302231721.26689.andreas@enge.fr> References: <201301262131.48844.andreas@enge.fr> <874ni3ejmr.fsf@gnu.org> <201302222313.25004.andreas@enge.fr> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_GyOKR9p0d1vUx8G" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9Hqy-0003O0-Un for bug-guix@gnu.org; Sat, 23 Feb 2013 11:21:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9Hqt-00082W-PR for bug-guix@gnu.org; Sat, 23 Feb 2013 11:21:36 -0500 In-Reply-To: <201302222313.25004.andreas@enge.fr> 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: bug-guix@gnu.org --Boundary-00=_GyOKR9p0d1vUx8G Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Am Freitag, 22. Februar 2013 schrieb Andreas Enge: > Please find attached a patch for review. I tested it on a few example > files, but not yet with a real packet - I am waiting for the full > rebuild ;-) I had test failures in coreutils, and to check whether it was related to my patch, I tried from scratch with the current core-updates branch. Any call to guix aborts with Backtrace: In ice-9/boot-9.scm: 149: 9 [catch #t # ...] 157: 8 [#] In unknown file: ?: 7 [catch-closure] In ice-9/boot-9.scm: 63: 6 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 407: 5 [eval # #] In ice-9/boot-9.scm: 2111: 4 [save-module-excursion #] 3651: 3 [#] In unknown file: ?: 2 [load-compiled/vm "/home/privat/.cache/guile/ccache/2.0- LE-8-2.0/usr/local/guix-git/bin/guix.go"] In /usr/local/bin/guix: 59: 1 [#] In unknown file: ?: 0 [scm-error misc-error #f ...] ERROR: In procedure scm-error: ERROR: No variable named guix-main in # I am also attaching the final patch-shebang patch. Andreas --Boundary-00=_GyOKR9p0d1vUx8G 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 63ac645147871eb773032da23d9f52bbd4f823eb 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 | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 6921e31..82042e9 100644 =2D-- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2012, 2013 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2013 Andreas Enge ;;; ;;; This file is part of GNU Guix. ;;; @@ -426,7 +427,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 +466,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* ((interp (match:substring m 1)) + (arg1 (match:substring m 2)) + (rest (match:substring m 3)) + (has-env (string-suffix? "/env" interp)) + (cmd (if has-env arg1 (basename interp))) + (bin (search-path path cmd))) (if bin =2D (if (string=3D? bin cmd) + (if (string=3D? bin interp) #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: chan= ging `~a' to `~a'~%" + file (string-append inte= rp " " arg1) bin) + (patch p bin rest)) + (begin=20 + (format (current-error-port) + "patch-shebang: ~a: changi= ng `~a' to `~a'~%" + file interp bin) + (patch p bin + (string-append " " arg1 res= t))))) (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=_GyOKR9p0d1vUx8G--