aboutsummaryrefslogtreecommitdiff
path: root/gnu/installer/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-04-26 13:56:22 +0200
committerLudovic Courtès <ludo@gnu.org>2019-04-26 14:19:36 +0200
commit9529f7850e3ae91cce70620e684fc6d0dc25e815 (patch)
treec965c7e8a5f3bb41343114528be90c1c6c207ecc /gnu/installer/utils.scm
parent6c849cdb988d403fec11ace82704535723de9e66 (diff)
downloadguix-9529f7850e3ae91cce70620e684fc6d0dc25e815.tar
guix-9529f7850e3ae91cce70620e684fc6d0dc25e815.tar.gz
installer: Take 'guix system init' exit code into account.
This allows the installer to distinguish success from failure, and also ensures the shell that runs 'guix system init' exits upon completion. * gnu/installer/utils.scm (run-shell-command)[pause]: New procedure. Add "exec" before COMMAND in the script. Guard 'invoke' call and handle 'invoke-error?'. Add call to 'pause' on completion. * gnu/installer/final.scm (install-system): Remove 'false-if-exception'.
Diffstat (limited to 'gnu/installer/utils.scm')
-rw-r--r--gnu/installer/utils.scm26
1 files changed, 22 insertions, 4 deletions
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index 256722729c..ddb96bc338 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -19,6 +20,8 @@
(define-module (gnu installer utils)
#:use-module (guix utils)
#:use-module (guix build utils)
+ #:use-module (guix i18n)
+ #:use-module (srfi srfi-34)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 regex)
#:use-module (ice-9 textual-ports)
@@ -55,7 +58,12 @@ number. If no percentage is found, return #f"
(string->number (match:substring result 1)))))
(define* (run-shell-command command #:key locale)
- "Run COMMAND, a string, with Bash, and in the given LOCALE."
+ "Run COMMAND, a string, with Bash, and in the given LOCALE. Return true if
+COMMAND exited successfully, #f otherwise."
+ (define (pause)
+ (format #t (G_ "Press Enter to continue.~%"))
+ (read-line (current-input-port)))
+
(call-with-temporary-output-file
(lambda (file port)
(when locale
@@ -69,7 +77,17 @@ number. If no percentage is found, return #f"
(string-take locale
(string-index locale #\_))))))
- (format port "~a~%" command)
- ;; (format port "exit~%")
+ (format port "exec ~a~%" command)
(close port)
- (invoke "bash" "--init-file" file))))
+
+ (guard (c ((invoke-error? c)
+ (newline)
+ (format (current-error-port)
+ (G_ "Command failed with exit code ~a.~%")
+ (invoke-error-exit-status c))
+ (pause)
+ #f))
+ (invoke "bash" "--init-file" file)
+ (newline)
+ (pause)
+ #t))))