unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Andreas Enge <andreas@enge.fr>
To: bug-guix@gnu.org
Subject: Re: #!/usr/bin/env perl
Date: Sat, 23 Feb 2013 17:21:26 +0100	[thread overview]
Message-ID: <201302231721.26689.andreas@enge.fr> (raw)
In-Reply-To: <201302222313.25004.andreas@enge.fr>

[-- Attachment #1: Type: Text/Plain, Size: 1198 bytes --]

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 #<catch-closure 286aa00> ...]
 157: 8 [#<procedure 28060f0 ()>]
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 #<procedure 280b100 at 
ice-9/boot-9.scm:3646:3 ()>]
3651: 3 [#<procedure 280b100 at ice-9/boot-9.scm:3646: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 [#<procedure 28381c0 ()>]
In unknown file:
   ?: 0 [scm-error misc-error #f ...]

ERROR: In procedure scm-error:
ERROR: No variable named guix-main in #<interface (guix ui) 28a0ea0>

I am also attaching the final patch-shebang patch.

Andreas

[-- Attachment #2: 0001-Patch-shebang-Handle-usr-bin-env-command.patch --]
[-- Type: text/x-patch, Size: 3719 bytes --]

From 63ac645147871eb773032da23d9f52bbd4f823eb Mon Sep 17 00:00:00 2001
From: Andreas Enge <andreas@enge.fr>
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".
---
 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
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
 ;;;
 ;;; 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)))
 
 (define patch-shebang
-  (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=> (and line (regexp-exec shebang-rx line))
                         (lambda (m)
-                          (let* ((cmd (match:substring m 1))
-                                 (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
-                                (if (string=? bin cmd)
+                                (if (string=? bin interp)
                                     #f            ; nothing to do
-                                    (begin
-                                      (format (current-error-port)
-                                              "patch-shebang: ~a: changing `~a' to `~a'~%"
-                                              file cmd bin)
-                                      (patch p bin (match:substring m 2))))
+                                    (if has-env
+                                        (begin
+                                          (format (current-error-port)
+                                                  "patch-shebang: ~a: changing `~a' to `~a'~%"
+                                                  file (string-append interp " " arg1) bin)
+                                          (patch p bin rest))
+                                      (begin 
+                                        (format (current-error-port)
+                                                "patch-shebang: ~a: changing `~a' to `~a'~%"
+                                                file interp bin)
+                                        (patch p bin
+                                               (string-append " " arg1 rest)))))
                                 (begin
                                   (format (current-error-port)
                                           "patch-shebang: ~a: warning: no binary for interpreter `~a' found in $PATH~%"
-- 
1.7.10.4


  parent reply	other threads:[~2013-02-23 16:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-26 20:31 #!/usr/bin/env perl Andreas Enge
2013-01-26 21:09 ` Ludovic Courtès
2013-02-22 22:13   ` Andreas Enge
2013-02-22 23:26     ` Ludovic Courtès
2013-02-23  0:03       ` Andreas Enge
2013-02-23 15:15         ` Ludovic Courtès
2013-02-23 16:21     ` Andreas Enge [this message]
2013-02-23 17:31       ` Ludovic Courtès
2013-02-23 17:48         ` Andreas Enge
2013-02-23 18:45           ` Ludovic Courtès
2013-02-23 18:58             ` Andreas Enge
2013-02-23 19:14               ` Ludovic Courtès
2013-02-23 19:19                 ` Andreas Enge
2013-02-25  2:49       ` Mark H Weaver
2013-02-25  9:43         ` Andreas Enge
2013-02-25 15:40           ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201302231721.26689.andreas@enge.fr \
    --to=andreas@enge.fr \
    --cc=bug-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).