summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorJanneke Nieuwenhuizen <janneke@gnu.org>2024-10-15 23:27:17 +0200
committerJan (janneke) Nieuwenhuizen <janneke@gnu.org>2024-11-11 07:28:35 +0100
commit9aeb8e3dee32254a19a68971f26e214c7b717e5b (patch)
treecb8481b13c3b9a1a3ffd4692709c46371dcf631c /gnu
parentcca544513b7c01e1cff33ac0c690031406dceac6 (diff)
installer: Add dry-run?
This allows running the installer without root privileges. Do something like ./pre-inst-env guix repl ,use (guix) ,use (gnu installer) (installer-program #:dry-run? #t) ,build $1 => "/gnu/store/...-installer-program" and run /gnu/store/...-installer-program * gnu/installer/newt.scm (locale-page): Add #:dry-run? parameter. (keymap-page): Likewise. * gnu/installer/newt/keymap.scm (run-keymap-page): Likewise. * gnu/installer/steps.scm (run-installer-steps): Likewise. Use it to skip writing to socket. * gnu/installer/newt/final.scm (run-final-page): Rename to... (run-final-page-install): ...this. (dry-run-final-page, run-final-page): New procedures. * gnu/installer/parted.scm (bootloader-configuration): Cater for empty user partitions. * gnu/installer/utils.scm (dry-run-command): New procedure. * gnu/installer.scm (compute-locale-step): Add #:dry-run? parameter. Use it to avoid actually applying locale. (compute-keymap-step): Add dry-run? parameter. Pass it to keymap-page. (installer-program): Add #:dry-run? parameter. If #:true avoid writing to /proc, use dry-run-command, skip sync and reboot, and pass dry-run? to... (installer-steps): ...here. Add #:dry-run? parameter. Use it to disable skip network, substitutes, partitioning pages, and pass it to... compute-locale-step, compute-keymap-step, and final-page. Change-Id: I0ff4c3b0a0c69539af617c27ba37654beed44619
Diffstat (limited to 'gnu')
-rw-r--r--gnu/installer.scm81
-rw-r--r--gnu/installer/newt.scm14
-rw-r--r--gnu/installer/newt/final.scm20
-rw-r--r--gnu/installer/newt/keymap.scm5
-rw-r--r--gnu/installer/newt/locale.scm6
-rw-r--r--gnu/installer/newt/partition.scm1
-rw-r--r--gnu/installer/parted.scm29
-rw-r--r--gnu/installer/steps.scm16
-rw-r--r--gnu/installer/utils.scm4
9 files changed, 116 insertions, 60 deletions
diff --git a/gnu/installer.scm b/gnu/installer.scm
index 21809e4259a..39a83c44557 100644
--- a/gnu/installer.scm
+++ b/gnu/installer.scm
@@ -134,7 +134,8 @@ version of this file."
134(define* (compute-locale-step #:key 134(define* (compute-locale-step #:key
135 locales-name 135 locales-name
136 iso639-languages-name 136 iso639-languages-name
137 iso3166-territories-name) 137 iso3166-territories-name
138 dry-run?)
138 "Return a gexp that run the locale-page of INSTALLER, and install the 139 "Return a gexp that run the locale-page of INSTALLER, and install the
139selected locale. The list of locales, languages and territories passed to 140selected locale. The list of locales, languages and territories passed to
140locale-page are computed in derivations named respectively LOCALES-NAME, 141locale-page are computed in derivations named respectively LOCALES-NAME,
@@ -177,8 +178,11 @@ been performed at build time."
177 ((installer-locale-page current-installer) 178 ((installer-locale-page current-installer)
178 #:supported-locales #$locales-loader 179 #:supported-locales #$locales-loader
179 #:iso639-languages #$iso639-loader 180 #:iso639-languages #$iso639-loader
180 #:iso3166-territories #$iso3166-loader))) 181 #:iso3166-territories #$iso3166-loader
181 (#$apply-locale result) 182 #:dry-run? #$dry-run?)))
183 (if #$dry-run?
184 '()
185 (#$apply-locale result))
182 result)))) 186 result))))
183 187
184(define apply-keymap 188(define apply-keymap
@@ -188,7 +192,7 @@ been performed at build time."
188 (kmscon-update-keymap (default-keyboard-model) 192 (kmscon-update-keymap (default-keyboard-model)
189 layout variant options)))) 193 layout variant options))))
190 194
191(define* (compute-keymap-step context) 195(define (compute-keymap-step context dry-run?)
192 "Return a gexp that runs the keymap-page of INSTALLER and install the 196 "Return a gexp that runs the keymap-page of INSTALLER and install the
193selected keymap." 197selected keymap."
194 #~(lambda (current-installer) 198 #~(lambda (current-installer)
@@ -200,15 +204,16 @@ selected keymap."
200 "/share/X11/xkb/rules/base.xml"))) 204 "/share/X11/xkb/rules/base.xml")))
201 (lambda (models layouts) 205 (lambda (models layouts)
202 ((installer-keymap-page current-installer) 206 ((installer-keymap-page current-installer)
203 layouts '#$context))))) 207 layouts '#$context #$dry-run?)))))
204 (and result (#$apply-keymap result)) 208 (and result (#$apply-keymap result))
205 result))) 209 result)))
206 210
207(define (installer-steps) 211(define* (installer-steps #:key dry-run?)
208 (let ((locale-step (compute-locale-step 212 (let ((locale-step (compute-locale-step
209 #:locales-name "locales" 213 #:locales-name "locales"
210 #:iso639-languages-name "iso639-languages" 214 #:iso639-languages-name "iso639-languages"
211 #:iso3166-territories-name "iso3166-territories")) 215 #:iso3166-territories-name "iso3166-territories"
216 #:dry-run? dry-run?))
212 (timezone-data #~(string-append #$tzdata 217 (timezone-data #~(string-append #$tzdata
213 "/share/zoneinfo/zone.tab"))) 218 "/share/zoneinfo/zone.tab")))
214 #~(lambda (current-installer) 219 #~(lambda (current-installer)
@@ -216,7 +221,7 @@ selected keymap."
216 (lambda () 221 (lambda ()
217 ((installer-parameters-page current-installer) 222 ((installer-parameters-page current-installer)
218 (lambda _ 223 (lambda _
219 (#$(compute-keymap-step 'param) 224 (#$(compute-keymap-step 'param dry-run?)
220 current-installer))))) 225 current-installer)))))
221 (list 226 (list
222 ;; Ask the user to choose a locale among those supported by 227 ;; Ask the user to choose a locale among those supported by
@@ -262,8 +267,10 @@ selected keymap."
262 (id 'keymap) 267 (id 'keymap)
263 (description (G_ "Keyboard mapping selection")) 268 (description (G_ "Keyboard mapping selection"))
264 (compute (lambda _ 269 (compute (lambda _
265 (#$(compute-keymap-step 'default) 270 (if #$dry-run?
266 current-installer))) 271 '("en" "US" #f)
272 (#$(compute-keymap-step 'default dry-run?)
273 current-installer))))
267 (configuration-formatter keyboard-layout->configuration)) 274 (configuration-formatter keyboard-layout->configuration))
268 275
269 ;; Ask the user to input a hostname for the system. 276 ;; Ask the user to input a hostname for the system.
@@ -280,14 +287,18 @@ selected keymap."
280 (id 'network) 287 (id 'network)
281 (description (G_ "Network selection")) 288 (description (G_ "Network selection"))
282 (compute (lambda _ 289 (compute (lambda _
283 ((installer-network-page current-installer))))) 290 (if #$dry-run?
291 '()
292 ((installer-network-page current-installer))))))
284 293
285 ;; Ask whether to enable substitute server discovery. 294 ;; Ask whether to enable substitute server discovery.
286 (installer-step 295 (installer-step
287 (id 'substitutes) 296 (id 'substitutes)
288 (description (G_ "Substitute server discovery")) 297 (description (G_ "Substitute server discovery"))
289 (compute (lambda _ 298 (compute (lambda _
290 ((installer-substitutes-page current-installer))))) 299 (if #$dry-run?
300 '()
301 ((installer-substitutes-page current-installer))))))
291 302
292 ;; Prompt for users (name, group and home directory). 303 ;; Prompt for users (name, group and home directory).
293 (installer-step 304 (installer-step
@@ -313,7 +324,9 @@ selected keymap."
313 (id 'partition) 324 (id 'partition)
314 (description (G_ "Partitioning")) 325 (description (G_ "Partitioning"))
315 (compute (lambda _ 326 (compute (lambda _
316 ((installer-partitioning-page current-installer)))) 327 (if #$dry-run?
328 '()
329 ((installer-partitioning-page current-installer)))))
317 (configuration-formatter user-partitions->configuration)) 330 (configuration-formatter user-partitions->configuration))
318 331
319 (installer-step 332 (installer-step
@@ -322,7 +335,7 @@ selected keymap."
322 (compute 335 (compute
323 (lambda (result prev-steps) 336 (lambda (result prev-steps)
324 ((installer-final-page current-installer) 337 ((installer-final-page current-installer)
325 result prev-steps)))))))) 338 result prev-steps #$dry-run?))))))))
326 339
327(define (provenance-sexp) 340(define (provenance-sexp)
328 "Return an sexp representing the currently-used channels, for logging 341 "Return an sexp representing the currently-used channels, for logging
@@ -343,7 +356,7 @@ purposes."
343 `(channel ,(channel-name channel) ,url ,(channel-commit channel)))) 356 `(channel ,(channel-name channel) ,url ,(channel-commit channel))))
344 channels)))) 357 channels))))
345 358
346(define (installer-program) 359(define* (installer-program #:key dry-run?)
347 "Return a file-like object that runs the given INSTALLER." 360 "Return a file-like object that runs the given INSTALLER."
348 (define init-gettext 361 (define init-gettext
349 ;; Initialize gettext support, so that installer messages can be 362 ;; Initialize gettext support, so that installer messages can be
@@ -377,7 +390,7 @@ purposes."
377 (lambda () 390 (lambda ()
378 (set-path-environment-variable "PATH" '("bin" "sbin") inputs))))) 391 (set-path-environment-variable "PATH" '("bin" "sbin") inputs)))))
379 392
380 (define steps (installer-steps)) 393 (define steps (installer-steps #:dry-run? dry-run?))
381 (define modules 394 (define modules
382 (scheme-modules* 395 (scheme-modules*
383 (string-append (current-source-directory) "/..") 396 (string-append (current-source-directory) "/..")
@@ -425,9 +438,10 @@ purposes."
425 438
426 ;; Enable core dump generation. 439 ;; Enable core dump generation.
427 (setrlimit 'core #f #f) 440 (setrlimit 'core #f #f)
428 (call-with-output-file "/proc/sys/kernel/core_pattern" 441 (unless #$dry-run?
429 (lambda (port) 442 (call-with-output-file "/proc/sys/kernel/core_pattern"
430 (format port %core-dump))) 443 (lambda (port)
444 (format port %core-dump))))
431 445
432 ;; Initialize gettext support so that installers can use 446 ;; Initialize gettext support so that installers can use
433 ;; (guix i18n) module. 447 ;; (guix i18n) module.
@@ -466,24 +480,29 @@ purposes."
466 (lambda () 480 (lambda ()
467 (parameterize 481 (parameterize
468 ((%run-command-in-installer 482 ((%run-command-in-installer
469 (installer-run-command current-installer))) 483 (if #$dry-run?
484 dry-run-command
485 (installer-run-command current-installer))))
470 (catch #t 486 (catch #t
471 (lambda () 487 (lambda ()
472 (define results 488 (define results
473 (run-installer-steps 489 (run-installer-steps
474 #:rewind-strategy 'menu 490 #:rewind-strategy 'menu
475 #:menu-proc (installer-menu-page current-installer) 491 #:menu-proc (installer-menu-page current-installer)
476 #:steps steps)) 492 #:steps steps
477 493 #:dry-run? #$dry-run?))
478 (match (result-step results 'final) 494
479 ('success 495 (let ((result (result-step results 'final)))
480 ;; We did it! Let's reboot! 496 (unless #$dry-run?
481 (sync) 497 (match (result-step results 'final)
482 (stop-service 'root)) 498 ('success
483 (_ 499 ;; We did it! Let's reboot!
484 ;; The installation failed, exit so that it is 500 (sync)
485 ;; restarted by login. 501 (stop-service 'root))
486 #f))) 502 (_
503 ;; The installation failed, exit so that it is
504 ;; restarted by login.
505 #f)))))
487 (const #f) 506 (const #f)
488 (lambda (key . args) 507 (lambda (key . args)
489 (installer-log-line "crashing due to uncaught exception: ~s ~s" 508 (installer-log-line "crashing due to uncaught exception: ~s ~s"
diff --git a/gnu/installer/newt.scm b/gnu/installer/newt.scm
index 6d8ea35fff4..d53bc058b3c 100644
--- a/gnu/installer/newt.scm
+++ b/gnu/installer/newt.scm
@@ -158,17 +158,19 @@ report it by email to ~a.") uploaded-name %guix-bug-report-address)
158 (term-signal term-sig) 158 (term-signal term-sig)
159 (stop-signal stop-sig))))))))))) 159 (stop-signal stop-sig)))))))))))
160 160
161(define (final-page result prev-steps) 161(define (final-page result prev-steps dry-run?)
162 (run-final-page result prev-steps)) 162 (run-final-page result prev-steps dry-run?))
163 163
164(define* (locale-page #:key 164(define* (locale-page #:key
165 supported-locales 165 supported-locales
166 iso639-languages 166 iso639-languages
167 iso3166-territories) 167 iso3166-territories
168 dry-run?)
168 (run-locale-page 169 (run-locale-page
169 #:supported-locales supported-locales 170 #:supported-locales supported-locales
170 #:iso639-languages iso639-languages 171 #:iso639-languages iso639-languages
171 #:iso3166-territories iso3166-territories)) 172 #:iso3166-territories iso3166-territories
173 #:dry-run? dry-run?))
172 174
173(define (timezone-page zonetab) 175(define (timezone-page zonetab)
174 (run-timezone-page zonetab)) 176 (run-timezone-page zonetab))
@@ -179,8 +181,8 @@ report it by email to ~a.") uploaded-name %guix-bug-report-address)
179(define (menu-page steps) 181(define (menu-page steps)
180 (run-menu-page steps)) 182 (run-menu-page steps))
181 183
182(define* (keymap-page layouts context) 184(define (keymap-page layouts context dry-run?)
183 (run-keymap-page layouts #:context context)) 185 (run-keymap-page layouts #:context context #:dry-run? dry-run?))
184 186
185(define (network-page) 187(define (network-page)
186 (run-network-page)) 188 (run-network-page))
diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm
index 9f950a0551c..c4e53f6d79c 100644
--- a/gnu/installer/newt/final.scm
+++ b/gnu/installer/newt/final.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com> 2;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
3;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
4;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -106,7 +107,7 @@ a specific step, or restart the installer."))
106 (newt-resume) 107 (newt-resume)
107 install-ok?)) 108 install-ok?))
108 109
109(define (run-final-page result prev-steps) 110(define (run-final-page-install result prev-steps)
110 (define (wait-for-clients) 111 (define (wait-for-clients)
111 (unless (null? (current-clients)) 112 (unless (null? (current-clients))
112 (installer-log-line "waiting with clients before starting final step") 113 (installer-log-line "waiting with clients before starting final step")
@@ -133,3 +134,20 @@ a specific step, or restart the installer."))
133 (if install-ok? 134 (if install-ok?
134 (run-install-success-page) 135 (run-install-success-page)
135 (run-install-failed-page)))) 136 (run-install-failed-page))))
137
138(define (dry-run-final-page result prev-steps)
139 (installer-log-line "proceeding with final step -- dry-run")
140 (let* ((configuration (format-configuration prev-steps result))
141 (user-partitions (result-step result 'partition))
142 (locale (result-step result 'locale))
143 (users (result-step result 'user))
144 (file (configuration->file configuration))
145 (install-ok? (run-config-display-page #:locale locale)))
146 (if install-ok?
147 (run-install-success-page)
148 (run-install-failed-page))))
149
150(define (run-final-page result prev-steps dry-run?)
151 (if dry-run?
152 (dry-run-final-page result prev-steps)
153 (run-final-page-install result prev-steps)))
diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.scm
index 109ec55e0ad..57f6d6530cf 100644
--- a/gnu/installer/newt/keymap.scm
+++ b/gnu/installer/newt/keymap.scm
@@ -2,6 +2,7 @@
2;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com> 2;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
3;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
4;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de> 4;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
5;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
5;;; 6;;;
6;;; This file is part of GNU Guix. 7;;; This file is part of GNU Guix.
7;;; 8;;;
@@ -153,7 +154,7 @@ and #f."
153 "grp:alt_shift_toggle")) 154 "grp:alt_shift_toggle"))
154 (list layout variant #f))) 155 (list layout variant #f)))
155 156
156(define* (run-keymap-page layouts #:key (context #f)) 157(define* (run-keymap-page layouts #:key context dry-run?)
157 "Run a page asking the user to select a keyboard layout and variant. LAYOUTS 158 "Run a page asking the user to select a keyboard layout and variant. LAYOUTS
158is a list of supported X11-KEYMAP-LAYOUT. For non-Latin keyboard layouts, a 159is a list of supported X11-KEYMAP-LAYOUT. For non-Latin keyboard layouts, a
159second layout and toggle options will be added automatically. Return a list 160second layout and toggle options will be added automatically. Return a list
@@ -201,7 +202,7 @@ options."
201 "xkeyboard-config"))))) 202 "xkeyboard-config")))))
202 (toggleable-latin-layout layout variant))) 203 (toggleable-latin-layout layout variant)))
203 204
204 (let* ((result (run-installer-steps #:steps keymap-steps)) 205 (let* ((result (run-installer-steps #:steps keymap-steps #:dry-run? dry-run?))
205 (layout (result-step result 'layout)) 206 (layout (result-step result 'layout))
206 (variant (result-step result 'variant))) 207 (variant (result-step result 'variant)))
207 (and layout 208 (and layout
diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm
index a226b39ba68..0be9db449e9 100644
--- a/gnu/installer/newt/locale.scm
+++ b/gnu/installer/newt/locale.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com> 2;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
3;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
4;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -92,7 +93,8 @@ symbol.")
92(define* (run-locale-page #:key 93(define* (run-locale-page #:key
93 supported-locales 94 supported-locales
94 iso639-languages 95 iso639-languages
95 iso3166-territories) 96 iso3166-territories
97 dry-run?)
96 "Run a page asking the user to select a locale language and possibly 98 "Run a page asking the user to select a locale language and possibly
97territory, codeset and modifier. Use SUPPORTED-LOCALES as the list of glibc 99territory, codeset and modifier. Use SUPPORTED-LOCALES as the list of glibc
98available locales. ISO639-LANGUAGES is an association list associating a 100available locales. ISO639-LANGUAGES is an association list associating a
@@ -212,4 +214,4 @@ glibc locale string and return it."
212 ;; step, turn the result into a glibc locale string and return it. 214 ;; step, turn the result into a glibc locale string and return it.
213 (result->locale-string 215 (result->locale-string
214 supported-locales 216 supported-locales
215 (run-installer-steps #:steps locale-steps))) 217 (run-installer-steps #:steps locale-steps #:dry-run? dry-run?)))
diff --git a/gnu/installer/newt/partition.scm b/gnu/installer/newt/partition.scm
index 37656696c19..48dd3060809 100644
--- a/gnu/installer/newt/partition.scm
+++ b/gnu/installer/newt/partition.scm
@@ -2,6 +2,7 @@
2;;; Copyright © 2018, 2019, 2022 Mathieu Othacehe <m.othacehe@gmail.com> 2;;; Copyright © 2018, 2019, 2022 Mathieu Othacehe <m.othacehe@gmail.com>
3;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
4;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr> 4;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
5;;; 6;;;
6;;; This file is part of GNU Guix. 7;;; This file is part of GNU Guix.
7;;; 8;;;
diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index e59df3d8e63..b36b238d8be 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -1461,19 +1461,22 @@ from (gnu system mapped-devices) and return it."
1461 1461
1462(define (bootloader-configuration user-partitions) 1462(define (bootloader-configuration user-partitions)
1463 "Return the bootloader configuration field for USER-PARTITIONS." 1463 "Return the bootloader configuration field for USER-PARTITIONS."
1464 (let* ((root-partition (find root-user-partition? 1464 (let ((root-partition (find root-user-partition? user-partitions)))
1465 user-partitions)) 1465 (match user-partitions
1466 (root-partition-disk (user-partition-disk-file-name root-partition))) 1466 (() '())
1467 `((bootloader-configuration 1467 (_
1468 ,@(if (efi-installation?) 1468 (let ((root-partition-disk (user-partition-disk-file-name
1469 `((bootloader grub-efi-bootloader) 1469 root-partition)))
1470 (targets (list ,(default-esp-mount-point)))) 1470 `((bootloader-configuration
1471 `((bootloader grub-bootloader) 1471 ,@(if (efi-installation?)
1472 (targets (list ,root-partition-disk)))) 1472 `((bootloader grub-efi-bootloader)
1473 1473 (targets (list ,(default-esp-mount-point))))
1474 ;; XXX: Assume we defined the 'keyboard-layout' field of 1474 `((bootloader grub-bootloader)
1475 ;; <operating-system> right above. 1475 (targets (list ,root-partition-disk))))
1476 (keyboard-layout keyboard-layout))))) 1476
1477 ;; XXX: Assume we defined the 'keyboard-layout' field of
1478 ;; <operating-system> right above.
1479 (keyboard-layout keyboard-layout))))))))
1477 1480
1478(define (user-partition-missing-modules user-partitions) 1481(define (user-partition-missing-modules user-partitions)
1479 "Return the list of kernel modules missing from the default set of kernel 1482 "Return the list of kernel modules missing from the default set of kernel
diff --git a/gnu/installer/steps.scm b/gnu/installer/steps.scm
index 0c505e40e4e..de0a852f02a 100644
--- a/gnu/installer/steps.scm
+++ b/gnu/installer/steps.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018, 2019 Mathieu Othacehe <m.othacehe@gmail.com> 2;;; Copyright © 2018, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
3;;; Copyright © 2020-2022 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2020-2022 Ludovic Courtès <ludo@gnu.org>
4;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -84,7 +85,8 @@
84(define* (run-installer-steps #:key 85(define* (run-installer-steps #:key
85 steps 86 steps
86 (rewind-strategy 'previous) 87 (rewind-strategy 'previous)
87 (menu-proc (const #f))) 88 (menu-proc (const #f))
89 dry-run?)
88 "Run the COMPUTE procedure of all <installer-step> records in STEPS 90 "Run the COMPUTE procedure of all <installer-step> records in STEPS
89sequentially, inside a the 'installer-step prompt. When aborted to with a 91sequentially, inside a the 'installer-step prompt. When aborted to with a
90parameter of 'abort, fallback to a previous install-step, accordingly to the 92parameter of 'abort, fallback to a previous install-step, accordingly to the
@@ -191,10 +193,14 @@ computation is over."
191 ;; prematurely. 193 ;; prematurely.
192 (sigaction SIGPIPE SIG_IGN) 194 (sigaction SIGPIPE SIG_IGN)
193 195
194 (with-server-socket 196 (if dry-run?
195 (run '() 197 (run '()
196 #:todo-steps steps 198 #:todo-steps steps
197 #:done-steps '()))) 199 #:done-steps '())
200 (with-server-socket
201 (run '()
202 #:todo-steps steps
203 #:done-steps '()))))
198 204
199(define (find-step-by-id steps id) 205(define (find-step-by-id steps id)
200 "Find and return the step in STEPS whose id is equal to ID." 206 "Find and return the step in STEPS whose id is equal to ID."
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index 170f036537f..a8eb6cee831 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -49,6 +49,7 @@
49 run-external-command-with-handler 49 run-external-command-with-handler
50 run-external-command-with-handler/tty 50 run-external-command-with-handler/tty
51 run-external-command-with-line-hooks 51 run-external-command-with-line-hooks
52 dry-run-command
52 run-command 53 run-command
53 %run-command-in-installer 54 %run-command-in-installer
54 55
@@ -222,6 +223,9 @@ in a pseudoterminal."
222 (pause) 223 (pause)
223 succeeded?) 224 succeeded?)
224 225
226(define (dry-run-command . args)
227 (format #t "dry-run-command: skipping: ~a\n" args))
228
225(define %run-command-in-installer 229(define %run-command-in-installer
226 (make-parameter 230 (make-parameter
227 (lambda (. args) 231 (lambda (. args)