summaryrefslogtreecommitdiff
path: root/nonguix
diff options
context:
space:
mode:
authorJulien Lepiller <julien@lepiller.eu>2020-07-02 14:12:10 +0200
committerJulien Lepiller <julien@lepiller.eu>2020-07-02 15:50:51 +0200
commit1f61e376ce7e6e5873744181bd740b8223a7f93f (patch)
treea276cd55277f01137d2f625e7939b1e3ca3e35d1 /nonguix
parent7d21e7db2b13f2df815ed0bdf26ef94688123677 (diff)
nonguix: Allow disabling passing $0 in make-wrapper.
* nonguix/build/utils.scm (make-wrapper): Add skip-argument-0? keyword.
Diffstat (limited to 'nonguix')
-rw-r--r--nonguix/build/utils.scm17
1 files changed, 14 insertions, 3 deletions
diff --git a/nonguix/build/utils.scm b/nonguix/build/utils.scm
index 451f63b..ab437f2 100644
--- a/nonguix/build/utils.scm
+++ b/nonguix/build/utils.scm
@@ -35,7 +35,7 @@ See https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header."
(array-ref (get-bytevector-n (current-input-port) 5) 4)))
#:binary #t))
-(define* (make-wrapper wrapper real-file #:rest vars)
+(define* (make-wrapper wrapper real-file #:key (skip-argument-0? #f) #:rest vars)
"Like `wrap-program' but create WRAPPER around REAL-FILE.
The wrapper automatically changes directory to that of REAL-FILE.
@@ -76,13 +76,24 @@ contents:
(format #f "export ~a=\"$~a${~a:+:}~a\""
var var var (string-join rest ":")))))
+ (define (remove-keyword-arguments lst)
+ (match lst
+ (() '())
+ (((? keyword? _) _ lst ...)
+ (remove-keyword-arguments lst))
+ (_ lst)))
+
(mkdir-p (dirname wrapper))
(call-with-output-file wrapper
(lambda (port)
(format port
- "#!~a~%~a~%cd \"~a\"~%exec -a \"$0\" \"~a\" \"$@\"~%"
+ (if skip-argument-0?
+ "#!~a~%~a~%cd \"~a\"~%exec \"~a\" \"$@\"~%"
+ "#!~a~%~a~%cd \"~a\"~%exec -a \"$0\" \"~a\" \"$@\"~%")
(which "bash")
- (string-join (map export-variable vars) "\n")
+ (string-join
+ (map export-variable (remove-keyword-arguments vars))
+ "\n")
(dirname real-file)
(canonicalize-path real-file))))
(chmod wrapper #o755))