[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#73927] [PATCH 16/16] DRAFT installer: Support dry-run from Guile vi
From: |
Janneke Nieuwenhuizen |
Subject: |
[bug#73927] [PATCH 16/16] DRAFT installer: Support dry-run from Guile via store. |
Date: |
Mon, 21 Oct 2024 10:17:12 +0200 |
This supports running the installer quasi-directly from Guile by only building
a Guile installer-script in the store. Do something like:
./pre-inst-env guile -c '((@ (gnu installer) run-installer) #:dry-run? #t)'
sudo -E ./pre-inst-env guile -c '((@ (gnu installer) run-installer))'
* gnu/installer.scm (installer-script, run-installer): New procedures.
Change-Id: I8cc1746845ec99f738e35fa91bb2342a674cfa88
---
gnu/installer.scm | 84 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 82 insertions(+), 2 deletions(-)
diff --git a/gnu/installer.scm b/gnu/installer.scm
index 64f6273c55..617578665e 100644
--- a/gnu/installer.scm
+++ b/gnu/installer.scm
@@ -21,10 +21,14 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu installer)
+ #:use-module (guix build utils)
+ #:use-module (guix derivations)
#:use-module (guix discovery)
- #:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (guix modules)
+ #:use-module (guix monads)
+ #:use-module (guix packages)
+ #:use-module (guix store)
#:use-module (guix utils)
#:use-module (guix ui)
#:use-module ((guix self) #:select (make-config.scm))
@@ -56,7 +60,9 @@ (define-module (gnu installer)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (web uri)
- #:export (installer-program))
+ #:export (installer-program
+ installer-steps
+ run-installer))
(define module-to-import?
;; Return true for modules that should be imported. For (gnu system …) and
@@ -562,3 +568,77 @@ (define* (installer-program #:key dry-run?)
(execl #$(program-file "installer-real" installer-builder
#:guile guile-3.0-latest)
"installer-real"))))
+
+(define* (installer-script #:key dry-run?
+ (steps (installer-steps #:dry-run? dry-run?)))
+ (program-file
+ "installer-script"
+ #~(begin
+ (use-modules (gnu installer)
+ (gnu installer record)
+ (gnu installer keymap)
+ (gnu installer steps)
+ (gnu installer dump)
+ (gnu installer final)
+ (gnu installer hostname)
+ (gnu installer kernel)
+ (gnu installer locale)
+ (gnu installer parted)
+ (gnu installer services)
+ (gnu installer timezone)
+ (gnu installer user)
+ (gnu installer utils)
+ (gnu installer newt)
+ ((gnu installer newt keymap)
+ #:select (keyboard-layout->configuration))
+ (gnu services herd)
+ (guix i18n)
+ (guix build utils)
+ (guix utils)
+ ((system repl debug)
+ #:select (terminal-width))
+ (ice-9 match)
+ (ice-9 textual-ports))
+ (terminal-width 200)
+ (let* ((current-installer newt-installer)
+ (steps (#$steps current-installer)))
+ (catch #t
+ (lambda _
+ ((installer-init current-installer))
+ (parameterize ((%run-command-in-installer
+ (if #$dry-run?
+ dry-run-command
+ (installer-run-command current-installer)))
+ (%installer-configuration-file
+ (if #$dry-run?
+ "config.scm"
+ (%installer-configuration-file))))
+ (let ((results (run-installer-steps
+ #:rewind-strategy 'menu
+ #:menu-proc
+ (installer-menu-page current-installer)
+ #:steps steps
+ #:dry-run? #$dry-run?)))
+ (result-step results 'final))))
+ (const #f)
+ (lambda (key . args)
+ (sleep 10)
+ ((installer-exit current-installer))
+ (display-backtrace (make-stack #t) (current-error-port))
+ (apply throw key args)))))))
+
+(define* (run-installer #:key dry-run?)
+ "To run the installer from Guile without building it:
+ ./pre-inst-env guile -c '((@ (gnu installer) run-installer) #:dry-run? #t)'
+when using #:dry-run? #t, no root access is required and the LOCALE, KEYMAP,
+and PARTITION pages are skipped."
+ (let* ((script (installer-script #:dry-run? dry-run?))
+ (store (open-connection))
+ (drv (run-with-store store
+ (lower-object script)))
+ (program (match (derivation->output-paths drv)
+ ((("out" . program)) program)))
+ (outputs (build-derivations store (list drv))))
+ (close-connection store)
+ (format #t "running installer: ~a\n" program)
+ (invoke "./pre-inst-env" "guile" program)))
--
2.46.0
- [bug#73927] [PATCH 07/16] maint: Add installer dependencies to the manifest., (continued)
- [bug#73927] [PATCH 07/16] maint: Add installer dependencies to the manifest., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 03/16] hurd-boot: Support system init: Create essential device nodes., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 06/16] hurd-boot: Support second boot., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 04/16] system: hurd: Add swap-services to hurd-default-essential-services., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 11/16] installer: Fix file-name typos., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 09/16] installer: Align comments., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 10/16] installer: Use "partitioning-page" consistently., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 12/16] installer: Use `%' for parameter %run-command-in-installer., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 13/16] installer: Add dry-run?, Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 08/16] installer: Remove unused (newt) imports., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 16/16] DRAFT installer: Support dry-run from Guile via store.,
Janneke Nieuwenhuizen <=
- [bug#73927] [PATCH 15/16] installer: Add static-networking template., Janneke Nieuwenhuizen, 2024/10/21
- [bug#73927] [PATCH 14/16] installer: Add "Kernel" page to select the Hurd., Janneke Nieuwenhuizen, 2024/10/21
[bug#73927] [PATCH v3 00/17] Installer support for (cross) installing the Hurd., Janneke Nieuwenhuizen, 2024/10/25