From: Mark H Weaver <mhw@netris.org>
To: bug-guix@gnu.org
Subject: Re: [PATCH] Improve shell script headers and pre-inst-env handling
Date: Mon, 11 Feb 2013 23:36:30 -0500 [thread overview]
Message-ID: <87zjzaxi5t.fsf@tines.lan> (raw)
In-Reply-To: <87d2w6z2tw.fsf@tines.lan> (Mark H. Weaver's message of "Mon, 11 Feb 2013 21:24:43 -0500")
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
Here's an improved version of the second patch. There's no functional
difference, but the code is easier to read IMO.
Mark
[-- Attachment #2: [PATCH 2/2] Improve shell script headers and pre-inst-env handling --]
[-- Type: text/x-diff, Size: 7711 bytes --]
From b1ea7f6ab01fb5c1ae1638315dad3fc8903682dc Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Mon, 11 Feb 2013 19:13:32 -0500
Subject: [PATCH 2/2] Improve shell script headers and pre-inst-env handling.
* pre-inst-env.in: Define $GUIX_UNINSTALLED.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Rewrite shell script headers to augment '%load-path' and
'%load-compiled-path' within Guile itself instead of setting environment
variables. Inhibit this behavior if $GUIX_UNINSTALLED is set.
---
guix-build.in | 22 ++++++++++++++++------
guix-download.in | 22 ++++++++++++++++------
guix-gc.in | 22 ++++++++++++++++------
guix-import.in | 22 ++++++++++++++++------
guix-package.in | 22 ++++++++++++++++------
pre-inst-env.in | 7 ++++++-
6 files changed, 86 insertions(+), 31 deletions(-)
diff --git a/guix-build.in b/guix-build.in
index f8c7115..29241c7 100644
--- a/guix-build.in
+++ b/guix-build.in
@@ -1,15 +1,25 @@
#!/bin/sh
# aside from this initial boilerplate, this is actually -*- scheme -*- code
+script=guix-build
+
prefix="@prefix@"
datarootdir="@datarootdir@"
-GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
-export GUILE_LOAD_COMPILED_PATH
-
-main='(module-ref (resolve-interface '\''(guix-build)) '\'guix-build')'
-exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
- -c "(apply $main (cdr (command-line)))" "$@"
+startup="
+(let ()
+ (define-syntax-rule (push! elt v) (set! v (cons elt v)))
+ (define (main interpreter module-dir script-file . args)
+ (unless (getenv \"GUIX_UNINSTALLED\")
+ (push! module-dir %load-path)
+ (push! module-dir %load-compiled-path))
+ (load script-file)
+ (let ((proc (module-ref (resolve-interface '($script))
+ '$script)))
+ (apply proc args)))
+ (apply main (command-line)))
+"
+exec "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@"
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
diff --git a/guix-download.in b/guix-download.in
index ea62b09..ccffbde 100644
--- a/guix-download.in
+++ b/guix-download.in
@@ -1,15 +1,25 @@
#!/bin/sh
# aside from this initial boilerplate, this is actually -*- scheme -*- code
+script=guix-download
+
prefix="@prefix@"
datarootdir="@datarootdir@"
-GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
-export GUILE_LOAD_COMPILED_PATH
-
-main='(module-ref (resolve-interface '\''(guix-download)) '\'guix-download')'
-exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
- -c "(apply $main (cdr (command-line)))" "$@"
+startup="
+(let ()
+ (define-syntax-rule (push! elt v) (set! v (cons elt v)))
+ (define (main interpreter module-dir script-file . args)
+ (unless (getenv \"GUIX_UNINSTALLED\")
+ (push! module-dir %load-path)
+ (push! module-dir %load-compiled-path))
+ (load script-file)
+ (let ((proc (module-ref (resolve-interface '($script))
+ '$script)))
+ (apply proc args)))
+ (apply main (command-line)))
+"
+exec "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@"
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
diff --git a/guix-gc.in b/guix-gc.in
index 1a4a541..84f18dd 100644
--- a/guix-gc.in
+++ b/guix-gc.in
@@ -1,15 +1,25 @@
#!/bin/sh
# aside from this initial boilerplate, this is actually -*- scheme -*- code
+script=guix-gc
+
prefix="@prefix@"
datarootdir="@datarootdir@"
-GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
-export GUILE_LOAD_COMPILED_PATH
-
-main='(module-ref (resolve-interface '\''(guix-gc)) '\'guix-gc')'
-exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
- -c "(apply $main (cdr (command-line)))" "$@"
+startup="
+(let ()
+ (define-syntax-rule (push! elt v) (set! v (cons elt v)))
+ (define (main interpreter module-dir script-file . args)
+ (unless (getenv \"GUIX_UNINSTALLED\")
+ (push! module-dir %load-path)
+ (push! module-dir %load-compiled-path))
+ (load script-file)
+ (let ((proc (module-ref (resolve-interface '($script))
+ '$script)))
+ (apply proc args)))
+ (apply main (command-line)))
+"
+exec "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@"
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
diff --git a/guix-import.in b/guix-import.in
index 97619a9..2666d78 100644
--- a/guix-import.in
+++ b/guix-import.in
@@ -1,15 +1,25 @@
#!/bin/sh
# aside from this initial boilerplate, this is actually -*- scheme -*- code
+script=guix-import
+
prefix="@prefix@"
datarootdir="@datarootdir@"
-GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
-export GUILE_LOAD_COMPILED_PATH
-
-main='(module-ref (resolve-interface '\''(guix-import)) '\'guix-import')'
-exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
- -c "(apply $main (cdr (command-line)))" "$@"
+startup="
+(let ()
+ (define-syntax-rule (push! elt v) (set! v (cons elt v)))
+ (define (main interpreter module-dir script-file . args)
+ (unless (getenv \"GUIX_UNINSTALLED\")
+ (push! module-dir %load-path)
+ (push! module-dir %load-compiled-path))
+ (load script-file)
+ (let ((proc (module-ref (resolve-interface '($script))
+ '$script)))
+ (apply proc args)))
+ (apply main (command-line)))
+"
+exec "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@"
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
diff --git a/guix-package.in b/guix-package.in
index ae3d2cd..32d9afd 100644
--- a/guix-package.in
+++ b/guix-package.in
@@ -1,15 +1,25 @@
#!/bin/sh
# aside from this initial boilerplate, this is actually -*- scheme -*- code
+script=guix-package
+
prefix="@prefix@"
datarootdir="@datarootdir@"
-GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
-export GUILE_LOAD_COMPILED_PATH
-
-main='(module-ref (resolve-interface '\''(guix-package)) '\'guix-package')'
-exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
- -c "(apply $main (cdr (command-line)))" "$@"
+startup="
+(let ()
+ (define-syntax-rule (push! elt v) (set! v (cons elt v)))
+ (define (main interpreter module-dir script-file . args)
+ (unless (getenv \"GUIX_UNINSTALLED\")
+ (push! module-dir %load-path)
+ (push! module-dir %load-compiled-path))
+ (load script-file)
+ (let ((proc (module-ref (resolve-interface '($script))
+ '$script)))
+ (apply proc args)))
+ (apply main (command-line)))
+"
+exec "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@"
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
diff --git a/pre-inst-env.in b/pre-inst-env.in
index 1dc63cd..5349c4c 100644
--- a/pre-inst-env.in
+++ b/pre-inst-env.in
@@ -43,7 +43,12 @@ export NIX_ROOT_FINDER NIX_SETUID_HELPER
# auto-compilation.
NIX_HASH="@NIX_HASH@"
-
export NIX_HASH
+# Define $GUIX_UNINSTALLED to prevent `guix-package' and other scripts from
+# prepending @guilemoduledir@ to the Guile load paths.
+
+GUIX_UNINSTALLED=1
+export GUIX_UNINSTALLED
+
exec "$@"
--
1.7.10.4
next prev parent reply other threads:[~2013-02-12 4:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-12 1:45 [PATCH] Improve shell script headers and pre-inst-env handling Mark H Weaver
2013-02-12 2:24 ` Mark H Weaver
2013-02-12 4:36 ` Mark H Weaver [this message]
2013-02-12 15:53 ` Ludovic Courtès
2013-02-12 15:56 ` Ludovic Courtès
2013-02-12 18:44 ` Mark H Weaver
2013-02-12 21:48 ` Ludovic Courtès
2013-02-12 22:44 ` Mark H Weaver
2013-02-13 14:42 ` Ludovic Courtès
2013-02-13 9:55 ` Mark H Weaver
2013-02-13 20:57 ` Ludovic Courtès
2013-02-14 8:28 ` Mark H Weaver
2013-02-14 9:44 ` [PATCH] Replace individual scripts with master 'guix' script Mark H Weaver
2013-02-14 13:41 ` Ludovic Courtès
2013-02-14 23:13 ` Mark H Weaver
2013-02-16 20:57 ` Ludovic Courtès
2013-02-17 14:59 ` 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=87zjzaxi5t.fsf@tines.lan \
--to=mhw@netris.org \
--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).