[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: installer: Take 'guix system init' exit code into account.
From: |
guix-commits |
Subject: |
04/07: installer: Take 'guix system init' exit code into account. |
Date: |
Fri, 26 Apr 2019 08:19:46 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 9529f7850e3ae91cce70620e684fc6d0dc25e815
Author: Ludovic Courtès <address@hidden>
Date: Fri Apr 26 13:56:22 2019 +0200
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'.
---
gnu/installer/final.scm | 5 ++---
gnu/installer/utils.scm | 26 ++++++++++++++++++++++----
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index bf68a5a..c41670c 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -99,7 +99,7 @@ USERS."
"Create /etc/shadow and /etc/passwd on the installation target for USERS.
Start COW-STORE service on target directory and launch guix install command in
a subshell. LOCALE must be the locale name under which that command will run,
-or #f."
+or #f. Return #t on success and #f on failure."
(let ((install-command
(format #f "guix system init ~a ~a"
(%installer-configuration-file)
@@ -114,5 +114,4 @@ or #f."
(create-user-database users (%installer-target-dir))
(start-service 'cow-store (list (%installer-target-dir)))
- (false-if-exception (run-shell-command install-command
- #:locale locale))))
+ (run-shell-command install-command #:locale locale)))
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index 2567227..ddb96bc 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 <address@hidden>
+;;; Copyright © 2019 Ludovic Courtès <address@hidden>
;;;
;;; 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))))
- branch master updated (9ca5ff8 -> 272db5b), guix-commits, 2019/04/26
- 03/07: installer: Run wrapped program with 'execl', not 'system'., guix-commits, 2019/04/26
- 05/07: installer: Actually reboot when the user presses "Reboot.", guix-commits, 2019/04/26
- 04/07: installer: Take 'guix system init' exit code into account.,
guix-commits <=
- 06/07: doc: Add 'BASE-URL' variable., guix-commits, 2019/04/26
- 07/07: doc: Use ftp.gnu.org for downloads., guix-commits, 2019/04/26
- 01/07: accounts: Always honor the configured user account shell., guix-commits, 2019/04/26
- 02/07: system: Provide a new VM image configuration., guix-commits, 2019/04/26