From 02d2b52458fae1c391e79f89a89696f3b07fdb2b Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Mon, 31 May 2021 18:22:31 +0200 Subject: [PATCH 01/18] =?UTF-8?q?build:=20Allow=20overriding=20the=20shell?= =?UTF-8?q?=20interpreter=20in=20=E2=80=98wrap-program=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, when creating new wrappers, 'wrap-program' would search for an interpreter to use in PATH. However, this is incorrect when cross-compiling. Allow overriding the shell interpreter to use, via an optional keyword argument #:sh. In time, when all users of 'wrap-program' have been corrected, this keyword argument can be made mandatory. * guix/build/utils.scm (wrap-program): Introduce a #:sh keyword argument, defaulting to (which "sh"). Use this keyword argument. Partially-Fixes: --- guix/build/utils.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index dbfc0a9142..c6731b37ae 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2018, 2019 Ricardo Wurmus ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2020, 2021 Maxim Cournoyer +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -1234,7 +1235,7 @@ known as `nuke-refs' in Nixpkgs." (and (string-prefix? "." base) (string-suffix? "-real" base))))) -(define* (wrap-program prog #:rest vars) +(define* (wrap-program prog #:key (sh (which "bash")) #:rest vars) "Make a wrapper for PROG. VARS should look like this: '(VARIABLE DELIMITER POSITION LIST-OF-DIRECTORIES) @@ -1261,7 +1262,12 @@ programs that expect particular shared libraries to be in $LD_LIBRARY_PATH, or modules in $GUILE_LOAD_PATH, etc. If PROG has previously been wrapped by 'wrap-program', the wrapper is extended -with definitions for VARS." +with definitions for VARS. If it is not, SH will be used as interpreter." + (define vars/filtered + (match vars + ((#:sh _ . vars) vars) + (vars vars))) + (define wrapped-file (string-append (dirname prog) "/." (basename prog) "-real")) @@ -1315,7 +1321,7 @@ with definitions for VARS." (for-each (lambda (var) (display (export-variable var) port) (newline port)) - vars) + vars/filtered) (display last port) (close-port port)) @@ -1327,8 +1333,8 @@ with definitions for VARS." (lambda (port) (format port "#!~a~%~a~%exec -a \"$0\" \"~a\" \"$@\"~%" - (which "bash") - (string-join (map export-variable vars) "\n") + sh + (string-join (map export-variable vars/filtered) "\n") (canonicalize-path wrapped-file)))) (chmod prog-tmp #o755) -- 2.31.1