From patchwork Wed Oct 30 14:30:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 69649 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CA3C427BBEA; Wed, 30 Oct 2024 14:35:50 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 32E9227BBE2 for ; Wed, 30 Oct 2024 14:35:50 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t69nP-0003IW-5P; Wed, 30 Oct 2024 10:35:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t69n1-0002yg-PB for guix-patches@gnu.org; Wed, 30 Oct 2024 10:35:16 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t69mq-00042a-TF; Wed, 30 Oct 2024 10:35:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=cRBY4LgF3AgTp2HN0SD4ISm+rNUXqPHZ8tC+HAS+IRU=; b=t0FRz+x7gtvdjYhJHfMKZVCIyqSOGd4Zhu8dVE107n6/yU0BAS++SEy/nlimr+IrOCoHNlGCdqw2Retlvvejuh7Mau+9YN/XUQ2qIMovbyfI9FdFZfpBf/2vyEPvZhiqZNwh/D75oH7E2hcLsHF3jDh6EcEXyjFoFP/XD8RNZohs6el0u8W9xujUHn9wvpGu1NgRtEWzHHFHRHqGW+xPPZl4DI9dpuDp+anw+f2aNE4XpVpA8AYAHrceWYmAdIGJksGLLvUpZNbeOfaCADNtSdbrNZeK3hYWGyJKZo3PNdLud3y+YWokMMKjVMXQJ7G7eO/5wfDq+DyFi7tE5YdL2g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t69mq-00041q-ND; Wed, 30 Oct 2024 10:35:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73927] [PATCH v4 18/18] installer: Support dry-run from Guile via store. Resent-From: Janneke Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, guix-patches@gnu.org Resent-Date: Wed, 30 Oct 2024 14:35:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73927 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73927@debbugs.gnu.org Cc: Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe X-Debbugs-Original-Xcc: Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe Received: via spool by 73927-submit@debbugs.gnu.org id=B73927.173029885915394 (code B ref 73927); Wed, 30 Oct 2024 14:35:04 +0000 Received: (at 73927) by debbugs.gnu.org; 30 Oct 2024 14:34:19 +0000 Received: from localhost ([127.0.0.1]:35388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t69m6-000409-KH for submit@debbugs.gnu.org; Wed, 30 Oct 2024 10:34:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39278) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t69lo-0003x3-6R for 73927@debbugs.gnu.org; Wed, 30 Oct 2024 10:34:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t69jc-0003P1-Ek; Wed, 30 Oct 2024 10:31:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=cRBY4LgF3AgTp2HN0SD4ISm+rNUXqPHZ8tC+HAS+IRU=; b=gEbItm3EbsB0NAmv45LE e11kBXaPePL0VFegEUMeRvhTjMhQW78woU+4WjenzqpXK9hkHehwV82G+18f+f8tDz2HiC6i1n0vY dNqtlX4Ya/JSrlqVcGVq5UBwd+qK3UKGjjJtdFmdMVHIhORypNPUVr/Xz6meA+I8owGULvYG7zKSy LCMCSG8REVsDgUhYhjHpqT9msAjS99Gd+0GRBaEMj7gYnhTVFOIvRlQToimIGj46smbKBuYLT2MxF /VddAc2gBZsmWVvhn9UH1Bn4XDXsROwg0KGHXn/ZfI2j0Fw5+OvpEN4R9iSvXd5G1Bm348pl8AL7K B+zePc2fmeJHWQ==; From: Janneke Nieuwenhuizen Date: Wed, 30 Oct 2024 15:30:47 +0100 Message-ID: <063f684df97b70d01e76591d4f214c1a9924b531.1730296564.git.janneke@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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)' or and BE VERY CAREFUL WHEN NOT USING #:DRY-RUN #T! sudo -E ./pre-inst-env guile -c '((@ (gnu installer) run-installer))' for this to work, you also need connman. * gnu/installer.scm (installer-script, run-installer): New procedures. Change-Id: I8cc1746845ec99f738e35fa91bb2342a674cfa88 --- gnu/installer.scm | 85 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/gnu/installer.scm b/gnu/installer.scm index 31c0ff7ff4..0a36f1f67b 100644 --- a/gnu/installer.scm +++ b/gnu/installer.scm @@ -21,10 +21,14 @@ ;;; along with GNU Guix. If not, see . (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,78 @@ (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) + ((installer-exit current-installer))))) + (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)))