summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-02-08 09:41:45 -0500
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-02-08 09:41:45 -0500
commitd88cee1d44a475b6ea276e87a4c98682255b881e (patch)
treef2e681b5211840d4eef688120041c2dd730002cc /guix/scripts
parentd2b9b4b861b71d11eaeaa12fe544c9ffb0b6644d (diff)
parent20059f92a97726b40d4d74e67463a64c98d1da0d (diff)
Merge branch 'master' into staging.
With conflicts resolved in: gnu/packages/version-control.scm
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/container/exec.scm10
-rw-r--r--guix/scripts/environment.scm11
-rw-r--r--guix/scripts/graph.scm14
-rw-r--r--guix/scripts/repl.scm14
4 files changed, 41 insertions, 8 deletions
diff --git a/guix/scripts/container/exec.scm b/guix/scripts/container/exec.scm
index 51b616b384..3e70b1d3c2 100644
--- a/guix/scripts/container/exec.scm
+++ b/guix/scripts/container/exec.scm
@@ -102,4 +102,12 @@ and the other containing arguments for the command to be executed."
environment)
(apply execlp program program program-args)))))))
(unless (zero? result)
- (leave (G_ "exec failed with status ~d~%") result)))))))
+ (match (status:exit-val result)
+ (#f
+ (if (status:term-sig result)
+ (leave (G_ "process terminated with signal ~a~%")
+ (status:term-sig result))
+ (leave (G_ "process stopped with signal ~a~%")
+ (status:stop-sig result))))
+ (code
+ (leave (G_ "process exited with status ~d~%") code)))))))))
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index c7fd8fd340..46435ae48e 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -1,8 +1,8 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2018 David Thompson <davet@gnu.org>
-;;; Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Mike Gerwitz <mtg@gnu.org>
-;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2022, 2023 John Kehayias <john.kehayias@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -475,10 +475,13 @@ cache."
(catch 'system-error
(lambda ()
(when emulate-fhs?
- ;; When running in a container with EMULATE-FHS?, override $PATH
+ ;; When running in a container with EMULATE-FHS?, augment $PATH
;; (optional, but to better match FHS expectations), and generate
;; /etc/ld.so.cache.
- (setenv "PATH" "/bin:/usr/bin:/sbin:/usr/sbin")
+ (setenv "PATH" (string-append "/bin:/usr/bin:/sbin:/usr/sbin"
+ (if (getenv "PATH")
+ (string-append ":" (getenv "PATH"))
+ "")))
(invoke "ldconfig" "-X"))
(apply execlp program program args))
(lambda _
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 2f102180c9..6847dd1962 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -569,6 +569,12 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
(category packaging)
(synopsis "view and query package dependency graphs")
+ (define (shorter? str1 str2)
+ (< (string-length str1) (string-length str2)))
+
+ (define length-sorted
+ (cut sort <> shorter?))
+
(with-error-handling
(define opts
(parse-command-line args %options
@@ -598,13 +604,17 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
(run-with-store store
;; XXX: Since grafting can trigger unsolicited builds, disable it.
- (mlet %store-monad ((_ (set-grafting #f))
+ (mlet %store-monad ((_g (set-grafting #f))
(nodes (mapm %store-monad
(node-type-convert type)
(reverse items))))
(if (assoc-ref opts 'path?)
+ ;; Sort by string length such that, in case of multiple
+ ;; outputs, the shortest one (which corresponds to "out") is
+ ;; picked (yup, a hack).
(match nodes
- (((node1 _ ...) (node2 _ ...))
+ (((= length-sorted (node1 _ ...))
+ (= length-sorted (node2 _ ...)))
(display-path node1 node2 type))
(_
(leave (G_ "'--path' option requires exactly two \
diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 50d18c7760..787c63d48e 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -52,12 +52,19 @@
(option '(#\t "type") #t #f
(lambda (opt name arg result)
(alist-cons 'type (string->symbol arg) result)))
+ (option '("list-types") #f #f
+ (lambda (opt name arg result)
+ (display (string-join '("guile" "machine") "\n" 'suffix))
+ (exit 0)))
(option '("listen") #t #f
(lambda (opt name arg result)
(alist-cons 'listen arg result)))
(option '(#\q) #f #f
(lambda (opt name arg result)
(alist-cons 'ignore-dot-guile? #t result)))
+ (option '(#\i "interactive") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'interactive? #t result)))
(option '(#\L "load-path") #t #f
(lambda (opt name arg result)
;; XXX: Imperatively modify the search paths.
@@ -71,6 +78,8 @@
In the Guix execution environment, run FILE as a Guile script with
command-line arguments ARGS. If no FILE is given, start a Guile REPL.\n"))
(display (G_ "
+ --list-types display REPL types and exit"))
+ (display (G_ "
-t, --type=TYPE start a REPL of the given TYPE"))
(display (G_ "
--listen=ENDPOINT listen to ENDPOINT instead of standard input"))
@@ -78,6 +87,9 @@ command-line arguments ARGS. If no FILE is given, start a Guile REPL.\n"))
-q inhibit loading of ~/.guile"))
(newline)
(display (G_ "
+ -i, --interactive launch REPL after evaluating FILE"))
+ (newline)
+ (display (G_ "
-L, --load-path=DIR prepend DIR to the package module search path"))
(newline)
(display (G_ "
@@ -190,7 +202,7 @@ call THUNK."
;; file in %LOAD-PATH. Thus, pass (getcwd) instead of ".".
(load-in-vicinity (getcwd) (car script)))))
- (when (null? script)
+ (when (or (null? script) (assoc-ref opts 'interactive?))
;; Start REPL
(let ((type (assoc-ref opts 'type)))
(call-with-connection (assoc-ref opts 'listen)