summaryrefslogtreecommitdiff
path: root/gnu/installer
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2022-01-15 14:50:07 +0100
committerMathieu Othacehe <othacehe@gnu.org>2022-02-02 16:46:44 +0100
commit726d0bd2f36363392ba2fcefd6e5d4aeed27dc9e (patch)
tree6b74b5d28b4dc3c7cefe89a0f7061dc3c80042d3 /gnu/installer
parent59fec4a1a2e1027dd03304b56200cc5e753c9faa (diff)
installer: Use named prompt to abort or break installer steps.
* gnu/installer/steps.scm (run-installer-steps): Set up 'installer-step prompt. * gnu/installer/newt/ethernet.scm (run-ethernet-page) * gnu/installer/newt/final.scm (run-config-display-page, run-install-failed-page) * gnu/installer/newt/keymap.scm (run-layout-page, run-variant-page) * gnu/installer/newt/locale.scm (run-language-page, run-territory-page, run-codeset-page, run-modifier-page, run-locale-page) * gnu/installer/newt/network.scm (run-technology-page, wait-service-online) * gnu/installer/newt/page.scm (run-listbox-selection-page, run-checkbox-tree-page) * gnu/installer/newt/partition.scm (button-exit-action) * gnu/installer/newt/services.scm (run-desktop-environments-cbt-page, run-networking-cbt-page, run-other-services-cbt-page, run-network-management-page) * gnu/installer/newt/timezone.scm (run-timezone-page) * gnu/installer/newt/user.scm (run-user-page) * gnu/installer/newt/welcome.scm (run-menu-page) * gnu/installer/newt/wifi.scm (run-wifi-page): Use the 'installer-step prompt to abort. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'gnu/installer')
-rw-r--r--gnu/installer/newt/ethernet.scm8
-rw-r--r--gnu/installer/newt/final.scm8
-rw-r--r--gnu/installer/newt/keymap.scm8
-rw-r--r--gnu/installer/newt/locale.scm25
-rw-r--r--gnu/installer/newt/network.scm16
-rw-r--r--gnu/installer/newt/page.scm4
-rw-r--r--gnu/installer/newt/partition.scm6
-rw-r--r--gnu/installer/newt/services.scm16
-rw-r--r--gnu/installer/newt/timezone.scm4
-rw-r--r--gnu/installer/newt/user.scm5
-rw-r--r--gnu/installer/newt/welcome.scm2
-rw-r--r--gnu/installer/newt/wifi.scm4
-rw-r--r--gnu/installer/steps.scm127
13 files changed, 85 insertions, 148 deletions
diff --git a/gnu/installer/newt/ethernet.scm b/gnu/installer/newt/ethernet.scm
index ecd22efbb2f..d75a6405192 100644
--- a/gnu/installer/newt/ethernet.scm
+++ b/gnu/installer/newt/ethernet.scm
@@ -65,9 +65,7 @@ connection is pending."
65 (run-error-page 65 (run-error-page
66 (G_ "No ethernet service available, please try again.") 66 (G_ "No ethernet service available, please try again.")
67 (G_ "No service")) 67 (G_ "No service"))
68 (raise 68 (abort-to-prompt 'installer-step 'abort))
69 (condition
70 (&installer-step-abort))))
71 ((service) 69 ((service)
72 ;; Only one service is available so return it directly. 70 ;; Only one service is available so return it directly.
73 service) 71 service)
@@ -81,7 +79,5 @@ connection is pending."
81 #:button-text (G_ "Exit") 79 #:button-text (G_ "Exit")
82 #:button-callback-procedure 80 #:button-callback-procedure
83 (lambda _ 81 (lambda _
84 (raise 82 (abort-to-prompt 'installer-step 'abort))
85 (condition
86 (&installer-step-abort))))
87 #:listbox-callback-procedure connect-ethernet-service)))) 83 #:listbox-callback-procedure connect-ethernet-service))))
diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm
index efe422f4f41..7c3f73ee82f 100644
--- a/gnu/installer/newt/final.scm
+++ b/gnu/installer/newt/final.scm
@@ -59,9 +59,7 @@ This will take a few minutes.")
59 #:file-textbox-height height 59 #:file-textbox-height height
60 #:exit-button-callback-procedure 60 #:exit-button-callback-procedure
61 (lambda () 61 (lambda ()
62 (raise 62 (abort-to-prompt 'installer-step 'abort)))))
63 (condition
64 (&installer-step-abort)))))))
65 63
66(define (run-install-success-page) 64(define (run-install-success-page)
67 (match (current-clients) 65 (match (current-clients)
@@ -88,9 +86,7 @@ press the button to reboot.")))
88 (G_ "Restart the installer") 86 (G_ "Restart the installer")
89 (G_ "The final system installation step failed. You can resume from \ 87 (G_ "The final system installation step failed. You can resume from \
90a specific step, or restart the installer.")) 88a specific step, or restart the installer."))
91 (1 (raise 89 (1 (abort-to-prompt 'installer-step 'abort))
92 (condition
93 (&installer-step-abort))))
94 (2 90 (2
95 ;; Keep going, the installer will be restarted later on. 91 ;; Keep going, the installer will be restarted later on.
96 #t))) 92 #t)))
diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.scm
index 92f7f46f34d..c5d4be67925 100644
--- a/gnu/installer/newt/keymap.scm
+++ b/gnu/installer/newt/keymap.scm
@@ -59,9 +59,7 @@ different layout at any time from the parameters menu.")))
59 ((param) (const #f)) 59 ((param) (const #f))
60 (else 60 (else
61 (lambda _ 61 (lambda _
62 (raise 62 (abort-to-prompt 'installer-step 'abort)))))))
63 (condition
64 (&installer-step-abort)))))))))
65 63
66(define (run-variant-page variants variant->text) 64(define (run-variant-page variants variant->text)
67 (let ((title (G_ "Variant"))) 65 (let ((title (G_ "Variant")))
@@ -74,9 +72,7 @@ different layout at any time from the parameters menu.")))
74 #:button-text (G_ "Back") 72 #:button-text (G_ "Back")
75 #:button-callback-procedure 73 #:button-callback-procedure
76 (lambda _ 74 (lambda _
77 (raise 75 (abort-to-prompt 'installer-step 'abort)))))
78 (condition
79 (&installer-step-abort)))))))
80 76
81(define (sort-layouts layouts) 77(define (sort-layouts layouts)
82 "Sort LAYOUTS list by putting the US layout ahead and return it." 78 "Sort LAYOUTS list by putting the US layout ahead and return it."
diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm
index bfd89aca2cb..01171e253f9 100644
--- a/gnu/installer/newt/locale.scm
+++ b/gnu/installer/newt/locale.scm
@@ -43,9 +43,7 @@ installation process and for the installed system.")
43 #:button-text (G_ "Exit") 43 #:button-text (G_ "Exit")
44 #:button-callback-procedure 44 #:button-callback-procedure
45 (lambda _ 45 (lambda _
46 (raise 46 (abort-to-prompt 'installer-step 'abort))))
47 (condition
48 (&installer-step-abort))))))
49 47
50 ;; Immediately install the chosen language so that the territory page that 48 ;; Immediately install the chosen language so that the territory page that
51 ;; comes after (optionally) is displayed in the chosen language. 49 ;; comes after (optionally) is displayed in the chosen language.
@@ -63,9 +61,7 @@ installation process and for the installed system.")
63 #:button-text (G_ "Back") 61 #:button-text (G_ "Back")
64 #:button-callback-procedure 62 #:button-callback-procedure
65 (lambda _ 63 (lambda _
66 (raise 64 (abort-to-prompt 'installer-step 'abort)))))
67 (condition
68 (&installer-step-abort)))))))
69 65
70(define (run-codeset-page codesets) 66(define (run-codeset-page codesets)
71 (let ((title (G_ "Locale codeset"))) 67 (let ((title (G_ "Locale codeset")))
@@ -78,9 +74,7 @@ installation process and for the installed system.")
78 #:button-text (G_ "Back") 74 #:button-text (G_ "Back")
79 #:button-callback-procedure 75 #:button-callback-procedure
80 (lambda _ 76 (lambda _
81 (raise 77 (abort-to-prompt 'installer-step 'abort)))))
82 (condition
83 (&installer-step-abort)))))))
84 78
85(define (run-modifier-page modifiers modifier->text) 79(define (run-modifier-page modifiers modifier->text)
86 (let ((title (G_ "Locale modifier"))) 80 (let ((title (G_ "Locale modifier")))
@@ -94,9 +88,7 @@ symbol.")
94 #:button-text (G_ "Back") 88 #:button-text (G_ "Back")
95 #:button-callback-procedure 89 #:button-callback-procedure
96 (lambda _ 90 (lambda _
97 (raise 91 (abort-to-prompt 'installer-step 'abort)))))
98 (condition
99 (&installer-step-abort)))))))
100 92
101(define* (run-locale-page #:key 93(define* (run-locale-page #:key
102 supported-locales 94 supported-locales
@@ -110,11 +102,10 @@ associating a territory code with a territory name. The formatted locale, under
110glibc format is returned." 102glibc format is returned."
111 103
112 (define (break-on-locale-found locales) 104 (define (break-on-locale-found locales)
113 "Raise the &installer-step-break condition if LOCALES contains exactly one 105 "Break to the installer step if LOCALES contains exactly one
114element." 106element."
115 (and (= (length locales) 1) 107 (and (= (length locales) 1)
116 (raise 108 (abort-to-prompt 'installer-step 'break)))
117 (condition (&installer-step-break)))))
118 109
119 (define (filter-locales locales result) 110 (define (filter-locales locales result)
120 "Filter the list of locale records LOCALES using the RESULT returned by 111 "Filter the list of locale records LOCALES using the RESULT returned by
@@ -218,8 +209,8 @@ glibc locale string and return it."
218 209
219 ;; If run-installer-steps returns locally, it means that the user had to go 210 ;; If run-installer-steps returns locally, it means that the user had to go
220 ;; through all steps (language, territory, codeset and modifier) to select a 211 ;; through all steps (language, territory, codeset and modifier) to select a
221 ;; locale. In that case, like if we exited by raising &installer-step-break 212 ;; locale. In that case, like if we exited by breaking to the installer
222 ;; condition, turn the result into a glibc locale string and return it. 213 ;; step, turn the result into a glibc locale string and return it.
223 (result->locale-string 214 (result->locale-string
224 supported-locales 215 supported-locales
225 (run-installer-steps #:steps locale-steps))) 216 (run-installer-steps #:steps locale-steps)))
diff --git a/gnu/installer/newt/network.scm b/gnu/installer/newt/network.scm
index fb221483c3e..0477a489beb 100644
--- a/gnu/installer/newt/network.scm
+++ b/gnu/installer/newt/network.scm
@@ -65,12 +65,8 @@ Internet and return the selected technology. For now, only technologies with
65 (G_ "Exit") 65 (G_ "Exit")
66 (G_ "The install process requires Internet access but no \ 66 (G_ "The install process requires Internet access but no \
67network devices were found. Do you want to continue anyway?")) 67network devices were found. Do you want to continue anyway?"))
68 ((1) (raise 68 ((1) (abort-to-prompt 'installer-step 'break))
69 (condition 69 ((2) (abort-to-prompt 'installer-step 'abort))))
70 (&installer-step-break))))
71 ((2) (raise
72 (condition
73 (&installer-step-abort))))))
74 ((technology) 70 ((technology)
75 ;; Since there's only one technology available, skip the selection 71 ;; Since there's only one technology available, skip the selection
76 ;; screen. 72 ;; screen.
@@ -86,9 +82,7 @@ network devices were found. Do you want to continue anyway?"))
86 #:button-text (G_ "Exit") 82 #:button-text (G_ "Exit")
87 #:button-callback-procedure 83 #:button-callback-procedure
88 (lambda _ 84 (lambda _
89 (raise 85 (abort-to-prompt 'installer-step 'abort))))))
90 (condition
91 (&installer-step-abort))))))))
92 86
93(define (find-technology-by-type technologies type) 87(define (find-technology-by-type technologies type)
94 "Find and return a technology with the given TYPE in TECHNOLOGIES list." 88 "Find and return a technology with the given TYPE in TECHNOLOGIES list."
@@ -156,9 +150,7 @@ FULL-VALUE tentatives, spaced by 1 second."
156 (G_ "The selected network does not provide access to the \ 150 (G_ "The selected network does not provide access to the \
157Internet and the Guix substitute server, please try again.") 151Internet and the Guix substitute server, please try again.")
158 (G_ "Connection error")) 152 (G_ "Connection error"))
159 (raise 153 (abort-to-prompt 'installer-step 'abort))))
160 (condition
161 (&installer-step-abort))))))
162 154
163(define (run-network-page) 155(define (run-network-page)
164 "Run a page to allow the user to configure connman so that it can access the 156 "Run a page to allow the user to configure connman so that it can access the
diff --git a/gnu/installer/newt/page.scm b/gnu/installer/newt/page.scm
index 695c7d875f7..8c675fa8373 100644
--- a/gnu/installer/newt/page.scm
+++ b/gnu/installer/newt/page.scm
@@ -488,7 +488,7 @@ the current listbox item has to be selected by key."
488 (string=? str (listbox-item->text item)))) 488 (string=? str (listbox-item->text item))))
489 keys) 489 keys)
490 ((key . item) item) 490 ((key . item) item)
491 (#f (raise (condition (&installer-step-abort)))))) 491 (#f (abort-to-prompt 'installer-step 'abort))))
492 492
493 ;; On every listbox element change, check if we need to skip it. If yes, 493 ;; On every listbox element change, check if we need to skip it. If yes,
494 ;; depending on the 'last-listbox-key', jump forward or backward. If no, 494 ;; depending on the 'last-listbox-key', jump forward or backward. If no,
@@ -690,7 +690,7 @@ ITEMS when 'Ok' is pressed."
690 (string=? str (item->text item)))) 690 (string=? str (item->text item))))
691 keys) 691 keys)
692 ((key . item) item) 692 ((key . item) item)
693 (#f (raise (condition (&installer-step-abort)))))) 693 (#f (abort-to-prompt 'installer-step 'abort))))
694 694
695 (add-form-to-grid grid form #t) 695 (add-form-to-grid grid form #t)
696 (make-wrapped-grid-window grid title) 696 (make-wrapped-grid-window grid title)
diff --git a/gnu/installer/newt/partition.scm b/gnu/installer/newt/partition.scm
index 6a3aa3daff4..e7a97810ac6 100644
--- a/gnu/installer/newt/partition.scm
+++ b/gnu/installer/newt/partition.scm
@@ -36,10 +36,8 @@
36 #:export (run-partitioning-page)) 36 #:export (run-partitioning-page))
37 37
38(define (button-exit-action) 38(define (button-exit-action)
39 "Raise the &installer-step-abort condition." 39 "Abort the installer step."
40 (raise 40 (abort-to-prompt 'installer-step 'abort))
41 (condition
42 (&installer-step-abort))))
43 41
44(define (run-scheme-page) 42(define (run-scheme-page)
45 "Run a page asking the user for a partitioning scheme." 43 "Run a page asking the user for a partitioning scheme."
diff --git a/gnu/installer/newt/services.scm b/gnu/installer/newt/services.scm
index c2188258131..9951ad22127 100644
--- a/gnu/installer/newt/services.scm
+++ b/gnu/installer/newt/services.scm
@@ -46,9 +46,7 @@ to choose from them later when you log in.")
46 #:checkbox-tree-height 9 46 #:checkbox-tree-height 9
47 #:exit-button-callback-procedure 47 #:exit-button-callback-procedure
48 (lambda () 48 (lambda ()
49 (raise 49 (abort-to-prompt 'installer-step 'abort)))))
50 (condition
51 (&installer-step-abort)))))))
52 50
53(define (run-networking-cbt-page) 51(define (run-networking-cbt-page)
54 "Run a page allowing the user to select networking services." 52 "Run a page allowing the user to select networking services."
@@ -65,9 +63,7 @@ system.")
65 #:checkbox-tree-height 5 63 #:checkbox-tree-height 5
66 #:exit-button-callback-procedure 64 #:exit-button-callback-procedure
67 (lambda () 65 (lambda ()
68 (raise 66 (abort-to-prompt 'installer-step 'abort)))))
69 (condition
70 (&installer-step-abort)))))))
71 67
72(define (run-printing-services-cbt-page) 68(define (run-printing-services-cbt-page)
73 "Run a page allowing the user to select document services such as CUPS." 69 "Run a page allowing the user to select document services such as CUPS."
@@ -85,9 +81,7 @@ system.")
85 #:checkbox-tree-height 9 81 #:checkbox-tree-height 9
86 #:exit-button-callback-procedure 82 #:exit-button-callback-procedure
87 (lambda () 83 (lambda ()
88 (raise 84 (abort-to-prompt 'installer-step 'abort)))))
89 (condition
90 (&installer-step-abort)))))))
91 85
92(define (run-console-services-cbt-page) 86(define (run-console-services-cbt-page)
93 "Run a page to select various system adminstration services for non-graphical 87 "Run a page to select various system adminstration services for non-graphical
@@ -130,9 +124,7 @@ client may be enough for a server.")
130 #:button-text (G_ "Exit") 124 #:button-text (G_ "Exit")
131 #:button-callback-procedure 125 #:button-callback-procedure
132 (lambda _ 126 (lambda _
133 (raise 127 (abort-to-prompt 'installer-step 'abort)))))
134 (condition
135 (&installer-step-abort)))))))
136 128
137(define (run-services-page) 129(define (run-services-page)
138 (let ((desktop (run-desktop-environments-cbt-page))) 130 (let ((desktop (run-desktop-environments-cbt-page)))
diff --git a/gnu/installer/newt/timezone.scm b/gnu/installer/newt/timezone.scm
index 67bf41ff84d..bed9f9d5cba 100644
--- a/gnu/installer/newt/timezone.scm
+++ b/gnu/installer/newt/timezone.scm
@@ -65,9 +65,7 @@ returned."
65 #:button-callback-procedure 65 #:button-callback-procedure
66 (if (null? path) 66 (if (null? path)
67 (lambda _ 67 (lambda _
68 (raise 68 (abort-to-prompt 'installer-step 'abort))
69 (condition
70 (&installer-step-abort))))
71 (lambda _ 69 (lambda _
72 (loop (all-but-last path)))) 70 (loop (all-but-last path))))
73 #:listbox-callback-procedure 71 #:listbox-callback-procedure
diff --git a/gnu/installer/newt/user.scm b/gnu/installer/newt/user.scm
index 58bb86bf96c..97141cfe646 100644
--- a/gnu/installer/newt/user.scm
+++ b/gnu/installer/newt/user.scm
@@ -20,7 +20,6 @@
20 20
21(define-module (gnu installer newt user) 21(define-module (gnu installer newt user)
22 #:use-module (gnu installer user) 22 #:use-module (gnu installer user)
23 #:use-module ((gnu installer steps) #:select (&installer-step-abort))
24 #:use-module (gnu installer newt page) 23 #:use-module (gnu installer newt page)
25 #:use-module (gnu installer newt utils) 24 #:use-module (gnu installer newt utils)
26 #:use-module (gnu installer utils) 25 #:use-module (gnu installer utils)
@@ -257,9 +256,7 @@ administrator (\"root\").")
257 (run users)) 256 (run users))
258 (reverse users)) 257 (reverse users))
259 ((components=? argument exit-button) 258 ((components=? argument exit-button)
260 (raise 259 (abort-to-prompt 'installer-step 'abort))))
261 (condition
262 (&installer-step-abort))))))
263 ('exit-fd-ready 260 ('exit-fd-ready
264 ;; Read the complete user list at once. 261 ;; Read the complete user list at once.
265 (match argument 262 (match argument
diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm
index 5f461279e25..7a7ddfb7bdf 100644
--- a/gnu/installer/newt/welcome.scm
+++ b/gnu/installer/newt/welcome.scm
@@ -84,7 +84,7 @@ we want this page to occupy all the screen space available."
84 (string=? str (listbox-item->text item)))) 84 (string=? str (listbox-item->text item))))
85 keys) 85 keys)
86 ((key . item) item) 86 ((key . item) item)
87 (#f (raise (condition (&installer-step-abort)))))) 87 (#f (abort-to-prompt 'installer-step 'abort))))
88 88
89 (set-textbox-text logo-textbox (read-all logo)) 89 (set-textbox-text logo-textbox (read-all logo))
90 90
diff --git a/gnu/installer/newt/wifi.scm b/gnu/installer/newt/wifi.scm
index f5d8f1fdbff..8a87cbdf4b1 100644
--- a/gnu/installer/newt/wifi.scm
+++ b/gnu/installer/newt/wifi.scm
@@ -237,9 +237,7 @@ force a wifi scan."
237 (run-wifi-scan-page) 237 (run-wifi-scan-page)
238 (run-wifi-page)) 238 (run-wifi-page))
239 ((components=? argument exit-button) 239 ((components=? argument exit-button)
240 (raise 240 (abort-to-prompt 'installer-step 'abort))
241 (condition
242 (&installer-step-abort))))
243 ((components=? argument listbox) 241 ((components=? argument listbox)
244 (let ((result (connect-wifi-service listbox service-items))) 242 (let ((result (connect-wifi-service listbox service-items)))
245 (unless result 243 (unless result
diff --git a/gnu/installer/steps.scm b/gnu/installer/steps.scm
index d9b3d6d07ec..8bc38181a7d 100644
--- a/gnu/installer/steps.scm
+++ b/gnu/installer/steps.scm
@@ -28,13 +28,7 @@
28 #:use-module (srfi srfi-34) 28 #:use-module (srfi srfi-34)
29 #:use-module (srfi srfi-35) 29 #:use-module (srfi srfi-35)
30 #:use-module (rnrs io ports) 30 #:use-module (rnrs io ports)
31 #:export (&installer-step-abort 31 #:export (<installer-step>
32 installer-step-abort?
33
34 &installer-step-break
35 installer-step-break?
36
37 <installer-step>
38 installer-step 32 installer-step
39 make-installer-step 33 make-installer-step
40 installer-step? 34 installer-step?
@@ -60,14 +54,6 @@
60;; purposes. 54;; purposes.
61(define %current-result (make-hash-table)) 55(define %current-result (make-hash-table))
62 56
63;; This condition may be raised to abort the current step.
64(define-condition-type &installer-step-abort &condition
65 installer-step-abort?)
66
67;; This condition may be raised to break out from the steps execution.
68(define-condition-type &installer-step-break &condition
69 installer-step-break?)
70
71;; An installer-step record is basically an id associated to a compute 57;; An installer-step record is basically an id associated to a compute
72;; procedure. The COMPUTE procedure takes exactly one argument, an association 58;; procedure. The COMPUTE procedure takes exactly one argument, an association
73;; list containing the results of previously executed installer-steps (see 59;; list containing the results of previously executed installer-steps (see
@@ -94,8 +80,10 @@
94 (rewind-strategy 'previous) 80 (rewind-strategy 'previous)
95 (menu-proc (const #f))) 81 (menu-proc (const #f)))
96 "Run the COMPUTE procedure of all <installer-step> records in STEPS 82 "Run the COMPUTE procedure of all <installer-step> records in STEPS
97sequentially. If the &installer-step-abort condition is raised, fallback to a 83sequentially, inside a the 'installer-step prompt. When aborted to with a
98previous install-step, accordingly to the specified REWIND-STRATEGY. 84parameter of 'abort, fallback to a previous install-step, accordingly to the
85specified REWIND-STRATEGY. When aborted to with a parameter of 'break, stop
86the computation and return the accumalated result so far.
99 87
100REWIND-STRATEGY possible values are 'previous, 'menu and 'start. If 'previous 88REWIND-STRATEGY possible values are 'previous, 'menu and 'start. If 'previous
101is selected, the execution will resume at the previous installer-step. If 89is selected, the execution will resume at the previous installer-step. If
@@ -112,10 +100,7 @@ the form:
112where STEP-ID is the ID field of the installer-step and COMPUTE-RESULT the 100where STEP-ID is the ID field of the installer-step and COMPUTE-RESULT the
113result of the associated COMPUTE procedure. This result association list is 101result of the associated COMPUTE procedure. This result association list is
114passed as argument of every COMPUTE procedure. It is finally returned when the 102passed as argument of every COMPUTE procedure. It is finally returned when the
115computation is over. 103computation is over."
116
117If the &installer-step-break condition is raised, stop the computation and
118return the accumalated result so far."
119 (define (pop-result list) 104 (define (pop-result list)
120 (cdr list)) 105 (cdr list))
121 106
@@ -149,63 +134,61 @@ return the accumalated result so far."
149 (match todo-steps 134 (match todo-steps
150 (() (reverse result)) 135 (() (reverse result))
151 ((step . rest-steps) 136 ((step . rest-steps)
152 (guard (c ((installer-step-abort? c) 137 (call-with-prompt 'installer-step
153 (case rewind-strategy 138 (lambda ()
154 ((previous) 139 (installer-log-line "running step '~a'" (installer-step-id step))
155 (match done-steps 140 (let* ((id (installer-step-id step))
156 (() 141 (compute (installer-step-compute step))
157 ;; We cannot go previous the first step. So re-raise 142 (res (compute result done-steps)))
158 ;; the exception. It might be useful in the case of 143 (hash-set! %current-result id res)
159 ;; nested run-installer-steps. Abort to 'raise-above 144 (run (alist-cons id res result)
160 ;; prompt to prevent the condition from being catched 145 #:todo-steps rest-steps
161 ;; by one of the previously installed guard. 146 #:done-steps (append done-steps (list step)))))
162 (abort-to-prompt 'raise-above c)) 147 (lambda (k action)
163 ((prev-done ... last-done) 148 (match action
164 (run (pop-result result) 149 ('abort
165 #:todo-steps (cons last-done todo-steps) 150 (case rewind-strategy
166 #:done-steps prev-done)))) 151 ((previous)
167 ((menu) 152 (match done-steps
168 (let ((goto-step (menu-proc 153 (()
169 (append done-steps (list step))))) 154 ;; We cannot go previous the first step. Abort again to
170 (if (eq? goto-step step) 155 ;; 'installer-step prompt. It might be useful in the case
171 (run result 156 ;; of nested run-installer-steps.
172 #:todo-steps todo-steps 157 (abort-to-prompt 'installer-step action))
173 #:done-steps done-steps) 158 ((prev-done ... last-done)
174 (skip-to-step goto-step result 159 (run (pop-result result)
175 #:todo-steps todo-steps 160 #:todo-steps (cons last-done todo-steps)
176 #:done-steps done-steps)))) 161 #:done-steps prev-done))))
177 ((start) 162 ((menu)
178 (if (null? done-steps) 163 (let ((goto-step (menu-proc
179 ;; Same as above, it makes no sense to jump to start 164 (append done-steps (list step)))))
180 ;; when we are at the first installer-step. Abort to 165 (if (eq? goto-step step)
181 ;; 'raise-above prompt to re-raise the condition. 166 (run result
182 (abort-to-prompt 'raise-above c) 167 #:todo-steps todo-steps
183 (run '() 168 #:done-steps done-steps)
184 #:todo-steps steps 169 (skip-to-step goto-step result
185 #:done-steps '()))))) 170 #:todo-steps todo-steps
186 ((installer-step-break? c) 171 #:done-steps done-steps))))
187 (reverse result))) 172 ((start)
188 (installer-log-line "running step '~a'" (installer-step-id step)) 173 (if (null? done-steps)
189 (let* ((id (installer-step-id step)) 174 ;; Same as above, it makes no sense to jump to start
190 (compute (installer-step-compute step)) 175 ;; when we are at the first installer-step. Abort to
191 (res (compute result done-steps))) 176 ;; 'installer-step prompt again.
192 (hash-set! %current-result id res) 177 (abort-to-prompt 'installer-step action)
193 (run (alist-cons id res result) 178 (run '()
194 #:todo-steps rest-steps 179 #:todo-steps steps
195 #:done-steps (append done-steps (list step)))))))) 180 #:done-steps '())))))
181 ('break
182 (reverse result))))))))
196 183
197 ;; Ignore SIGPIPE so that we don't die if a client closes the connection 184 ;; Ignore SIGPIPE so that we don't die if a client closes the connection
198 ;; prematurely. 185 ;; prematurely.
199 (sigaction SIGPIPE SIG_IGN) 186 (sigaction SIGPIPE SIG_IGN)
200 187
201 (with-server-socket 188 (with-server-socket
202 (call-with-prompt 'raise-above 189 (run '()
203 (lambda () 190 #:todo-steps steps
204 (run '() 191 #:done-steps '())))
205 #:todo-steps steps
206 #:done-steps '()))
207 (lambda (k condition)
208 (raise condition)))))
209 192
210(define (find-step-by-id steps id) 193(define (find-step-by-id steps id)
211 "Find and return the step in STEPS whose id is equal to ID." 194 "Find and return the step in STEPS whose id is equal to ID."