summary refs log tree commit diff
path: root/gnu/installer.scm
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2022-01-15 14:50:01 +0100
committerMathieu Othacehe <othacehe@gnu.org>2022-02-02 16:46:43 +0100
commit408427a36c6545115068d5f06de2ea21407374c6 (patch)
tree45532524443880802b1eac427ce9c0e3e109169c /gnu/installer.scm
parent0b9fbbb4dd24f227c9a708561ba291f6169ad2e6 (diff)
downloadguix-408427a36c6545115068d5f06de2ea21407374c6.tar.gz
installer: Add installer-specific run command process.
* gnu/installer/record.scm (installer)[run-command]: Add field.
* gnu/installer/utils.scm (run-command-in-installer): Add parameter.
* gnu/installer.scm (installer-program): Parameterize
run-command-in-installer with current installer's run-command.
* gnu/installer/newt.scm (newt-run-command): New variable.
(newt-installer): Use it.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'gnu/installer.scm')
-rw-r--r--gnu/installer.scm79
1 files changed, 41 insertions, 38 deletions
diff --git a/gnu/installer.scm b/gnu/installer.scm
index d0d012f04b..3cc5c79d4e 100644
--- a/gnu/installer.scm
+++ b/gnu/installer.scm
@@ -416,44 +416,47 @@ selected keymap."
             (define steps (#$steps current-installer))
             ((installer-init current-installer))
 
-            (catch #t
-              (lambda ()
-                (define results
-                  (run-installer-steps
-                   #:rewind-strategy 'menu
-                   #:menu-proc (installer-menu-page current-installer)
-                   #:steps steps))
-
-                (match (result-step results 'final)
-                  ('success
-                   ;; We did it!  Let's reboot!
-                   (sync)
-                   (stop-service 'root))
-                  (_
-                   ;; The installation failed, exit so that it is restarted
-                   ;; by login.
-                   #f)))
-              (const #f)
-              (lambda (key . args)
-                (installer-log-line "crashing due to uncaught exception: ~s ~s"
-                        key args)
-                (let ((error-file "/tmp/last-installer-error")
-                      (dump-archive "/tmp/dump.tgz"))
-                  (call-with-output-file error-file
-                    (lambda (port)
-                      (display-backtrace (make-stack #t) port)
-                      (print-exception port
-                                       (stack-ref (make-stack #t) 1)
-                                       key args)))
-                  (make-dump dump-archive
-                             #:result %current-result
-                             #:backtrace error-file)
-                  (let ((report
-                         ((installer-dump-page current-installer)
-                          dump-archive)))
-                    ((installer-exit-error current-installer)
-                     error-file report key args)))
-                (primitive-exit 1)))
+            (parameterize
+                ((run-command-in-installer
+                  (installer-run-command current-installer)))
+              (catch #t
+                (lambda ()
+                  (define results
+                    (run-installer-steps
+                     #:rewind-strategy 'menu
+                     #:menu-proc (installer-menu-page current-installer)
+                     #:steps steps))
+
+                  (match (result-step results 'final)
+                    ('success
+                     ;; We did it!  Let's reboot!
+                     (sync)
+                     (stop-service 'root))
+                    (_
+                     ;; The installation failed, exit so that it is restarted
+                     ;; by login.
+                     #f)))
+                (const #f)
+                (lambda (key . args)
+                  (installer-log-line "crashing due to uncaught exception: ~s ~s"
+                          key args)
+                  (let ((error-file "/tmp/last-installer-error")
+                        (dump-archive "/tmp/dump.tgz"))
+                    (call-with-output-file error-file
+                      (lambda (port)
+                        (display-backtrace (make-stack #t) port)
+                        (print-exception port
+                                         (stack-ref (make-stack #t) 1)
+                                         key args)))
+                    (make-dump dump-archive
+                               #:result %current-result
+                               #:backtrace error-file)
+                    (let ((report
+                           ((installer-dump-page current-installer)
+                            dump-archive)))
+                      ((installer-exit-error current-installer)
+                       error-file report key args)))
+                  (primitive-exit 1))))
 
             ((installer-exit current-installer))))))