From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark H Weaver Subject: Re: [PATCH] Improve shell script headers and pre-inst-env handling Date: Mon, 11 Feb 2013 23:36:30 -0500 Message-ID: <87zjzaxi5t.fsf@tines.lan> References: <87haliz4nt.fsf@tines.lan> <87d2w6z2tw.fsf@tines.lan> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U57bz-0008TS-09 for bug-guix@gnu.org; Mon, 11 Feb 2013 23:36:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U57bw-0002JT-P5 for bug-guix@gnu.org; Mon, 11 Feb 2013 23:36:54 -0500 Received: from world.peace.net ([96.39.62.75]:43918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U57bw-0002JK-If for bug-guix@gnu.org; Mon, 11 Feb 2013 23:36:52 -0500 In-Reply-To: <87d2w6z2tw.fsf@tines.lan> (Mark H. Weaver's message of "Mon, 11 Feb 2013 21:24:43 -0500") 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 --=-=-= Content-Type: text/plain Here's an improved version of the second patch. There's no functional difference, but the code is easier to read IMO. Mark --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0002-Improve-shell-script-headers-and-pre-inst-env-handli.patch Content-Transfer-Encoding: quoted-printable Content-Description: [PATCH 2/2] Improve shell script headers and pre-inst-env handling >From b1ea7f6ab01fb5c1ae1638315dad3fc8903682dc Mon Sep 17 00:00:00 2001 From: Mark H Weaver 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 =20 +script=3Dguix-build + prefix=3D"@prefix@" datarootdir=3D"@datarootdir@" =20 -GUILE_LOAD_COMPILED_PATH=3D"@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" -export GUILE_LOAD_COMPILED_PATH - -main=3D'(module-ref (resolve-interface '\''(guix-build)) '\'guix-build')' -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ - -c "(apply $main (cdr (command-line)))" "$@" +startup=3D" +(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 =C2=A9 2012, 2013 Ludovic Court=C3=A8s 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 =20 +script=3Dguix-download + prefix=3D"@prefix@" datarootdir=3D"@datarootdir@" =20 -GUILE_LOAD_COMPILED_PATH=3D"@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" -export GUILE_LOAD_COMPILED_PATH - -main=3D'(module-ref (resolve-interface '\''(guix-download)) '\'guix-downlo= ad')' -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ - -c "(apply $main (cdr (command-line)))" "$@" +startup=3D" +(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 =C2=A9 2012, 2013 Ludovic Court=C3=A8s 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 =20 +script=3Dguix-gc + prefix=3D"@prefix@" datarootdir=3D"@datarootdir@" =20 -GUILE_LOAD_COMPILED_PATH=3D"@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" -export GUILE_LOAD_COMPILED_PATH - -main=3D'(module-ref (resolve-interface '\''(guix-gc)) '\'guix-gc')' -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ - -c "(apply $main (cdr (command-line)))" "$@" +startup=3D" +(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 =C2=A9 2012, 2013 Ludovic Court=C3=A8s 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 =20 +script=3Dguix-import + prefix=3D"@prefix@" datarootdir=3D"@datarootdir@" =20 -GUILE_LOAD_COMPILED_PATH=3D"@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" -export GUILE_LOAD_COMPILED_PATH - -main=3D'(module-ref (resolve-interface '\''(guix-import)) '\'guix-import')' -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ - -c "(apply $main (cdr (command-line)))" "$@" +startup=3D" +(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 =C2=A9 2012, 2013 Ludovic Court=C3=A8s 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 =20 +script=3Dguix-package + prefix=3D"@prefix@" datarootdir=3D"@datarootdir@" =20 -GUILE_LOAD_COMPILED_PATH=3D"@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" -export GUILE_LOAD_COMPILED_PATH - -main=3D'(module-ref (resolve-interface '\''(guix-package)) '\'guix-package= ')' -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ - -c "(apply $main (cdr (command-line)))" "$@" +startup=3D" +(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 =C2=A9 2012, 2013 Ludovic Court=C3=A8s 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. =20 NIX_HASH=3D"@NIX_HASH@" - export NIX_HASH =20 +# Define $GUIX_UNINSTALLED to prevent `guix-package' and other scripts from +# prepending @guilemoduledir@ to the Guile load paths. + +GUIX_UNINSTALLED=3D1 +export GUIX_UNINSTALLED + exec "$@" --=20 1.7.10.4 --=-=-=--