summaryrefslogtreecommitdiff
path: root/gnu
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
parent0b9fbbb4dd24f227c9a708561ba291f6169ad2e6 (diff)
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')
-rw-r--r--gnu/installer.scm79
-rw-r--r--gnu/installer/newt.scm10
-rw-r--r--gnu/installer/record.scm7
-rw-r--r--gnu/installer/utils.scm10
4 files changed, 65 insertions, 41 deletions
diff --git a/gnu/installer.scm b/gnu/installer.scm
index d0d012f04b2..3cc5c79d4e7 100644
--- a/gnu/installer.scm
+++ b/gnu/installer.scm
@@ -416,44 +416,47 @@ selected keymap."
416 (define steps (#$steps current-installer)) 416 (define steps (#$steps current-installer))
417 ((installer-init current-installer)) 417 ((installer-init current-installer))
418 418
419 (catch #t 419 (parameterize
420 (lambda () 420 ((run-command-in-installer
421 (define results 421 (installer-run-command current-installer)))
422 (run-installer-steps 422 (catch #t
423 #:rewind-strategy 'menu 423 (lambda ()
424 #:menu-proc (installer-menu-page current-installer) 424 (define results
425 #:steps steps)) 425 (run-installer-steps
426 426 #:rewind-strategy 'menu
427 (match (result-step results 'final) 427 #:menu-proc (installer-menu-page current-installer)
428 ('success 428 #:steps steps))
429 ;; We did it! Let's reboot! 429
430 (sync) 430 (match (result-step results 'final)
431 (stop-service 'root)) 431 ('success
432 (_ 432 ;; We did it! Let's reboot!
433 ;; The installation failed, exit so that it is restarted 433 (sync)
434 ;; by login. 434 (stop-service 'root))
435 #f))) 435 (_
436 (const #f) 436 ;; The installation failed, exit so that it is restarted
437 (lambda (key . args) 437 ;; by login.
438 (installer-log-line "crashing due to uncaught exception: ~s ~s" 438 #f)))
439 key args) 439 (const #f)
440 (let ((error-file "/tmp/last-installer-error") 440 (lambda (key . args)
441 (dump-archive "/tmp/dump.tgz")) 441 (installer-log-line "crashing due to uncaught exception: ~s ~s"
442 (call-with-output-file error-file 442 key args)
443 (lambda (port) 443 (let ((error-file "/tmp/last-installer-error")
444 (display-backtrace (make-stack #t) port) 444 (dump-archive "/tmp/dump.tgz"))
445 (print-exception port 445 (call-with-output-file error-file
446 (stack-ref (make-stack #t) 1) 446 (lambda (port)
447 key args))) 447 (display-backtrace (make-stack #t) port)
448 (make-dump dump-archive 448 (print-exception port
449 #:result %current-result 449 (stack-ref (make-stack #t) 1)
450 #:backtrace error-file) 450 key args)))
451 (let ((report 451 (make-dump dump-archive
452 ((installer-dump-page current-installer) 452 #:result %current-result
453 dump-archive))) 453 #:backtrace error-file)
454 ((installer-exit-error current-installer) 454 (let ((report
455 error-file report key args))) 455 ((installer-dump-page current-installer)
456 (primitive-exit 1))) 456 dump-archive)))
457 ((installer-exit-error current-installer)
458 error-file report key args)))
459 (primitive-exit 1))))
457 460
458 ((installer-exit current-installer)))))) 461 ((installer-exit current-installer))))))
459 462
diff --git a/gnu/installer/newt.scm b/gnu/installer/newt.scm
index 61fb9cf2ca8..fc851339d13 100644
--- a/gnu/installer/newt.scm
+++ b/gnu/installer/newt.scm
@@ -79,6 +79,13 @@ problem. The backtrace is displayed below~a. Please report it by email to \
79 (newt-finish) 79 (newt-finish)
80 (clear-screen)) 80 (clear-screen))
81 81
82(define (newt-run-command . args)
83 (newt-suspend)
84 (clear-screen)
85 (define result (run-command args))
86 (newt-resume)
87 result)
88
82(define (final-page result prev-steps) 89(define (final-page result prev-steps)
83 (run-final-page result prev-steps)) 90 (run-final-page result prev-steps))
84 91
@@ -150,4 +157,5 @@ problem. The backtrace is displayed below~a. Please report it by email to \
150 (welcome-page welcome-page) 157 (welcome-page welcome-page)
151 (parameters-menu parameters-menu) 158 (parameters-menu parameters-menu)
152 (parameters-page parameters-page) 159 (parameters-page parameters-page)
153 (dump-page dump-page))) 160 (dump-page dump-page)
161 (run-command newt-run-command)))
diff --git a/gnu/installer/record.scm b/gnu/installer/record.scm
index e7cd45ee83e..23db3edd70e 100644
--- a/gnu/installer/record.scm
+++ b/gnu/installer/record.scm
@@ -42,7 +42,8 @@
42 installer-welcome-page 42 installer-welcome-page
43 installer-parameters-menu 43 installer-parameters-menu
44 installer-parameters-page 44 installer-parameters-page
45 installer-dump-page)) 45 installer-dump-page
46 installer-run-command))
46 47
47 48
48;;; 49;;;
@@ -94,4 +95,6 @@
94 ;; procedure (keyboard-layout-selection) -> void 95 ;; procedure (keyboard-layout-selection) -> void
95 (parameters-page installer-parameters-page) 96 (parameters-page installer-parameters-page)
96 ;; procedure (dump) -> void 97 ;; procedure (dump) -> void
97 (dump-page installer-dump-page)) 98 (dump-page installer-dump-page)
99 ;; procedure command -> bool
100 (run-command installer-run-command))
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index 66c41ac2a1a..fb62fb88968 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -25,6 +25,7 @@
25 #:use-module (srfi srfi-1) 25 #:use-module (srfi srfi-1)
26 #:use-module (srfi srfi-19) 26 #:use-module (srfi srfi-19)
27 #:use-module (srfi srfi-34) 27 #:use-module (srfi srfi-34)
28 #:use-module (srfi srfi-35)
28 #:use-module (ice-9 control) 29 #:use-module (ice-9 control)
29 #:use-module (ice-9 match) 30 #:use-module (ice-9 match)
30 #:use-module (ice-9 popen) 31 #:use-module (ice-9 popen)
@@ -39,6 +40,7 @@
39 run-external-command-with-handler 40 run-external-command-with-handler
40 run-external-command-with-line-hooks 41 run-external-command-with-line-hooks
41 run-command 42 run-command
43 run-command-in-installer
42 44
43 syslog-port 45 syslog-port
44 %syslog-line-hook 46 %syslog-line-hook
@@ -168,6 +170,14 @@ successfully, #f otherwise."
168 (pause) 170 (pause)
169 succeeded?) 171 succeeded?)
170 172
173(define run-command-in-installer
174 (make-parameter
175 (lambda (. args)
176 (raise
177 (condition
178 (&serious)
179 (&message (message "run-command-in-installer not set")))))))
180
171 181
172;;; 182;;;
173;;; Logging. 183;;; Logging.