From patchwork Fri Oct 25 09:40:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 69455 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 DFDDE27BBEA; Fri, 25 Oct 2024 10:42:43 +0100 (BST) 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 58FBB27BBE2 for ; Fri, 25 Oct 2024 10:42:43 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4GpA-0002VQ-03; Fri, 25 Oct 2024 05:41: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 1t4Gp8-0002UH-Uu for guix-patches@gnu.org; Fri, 25 Oct 2024 05:41:38 -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 1t4Gp8-0003uT-Fe for guix-patches@gnu.org; Fri, 25 Oct 2024 05:41:38 -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=+STQwkKh3SyvccoJDqQkts7U4WNa17HyCQ6CzqURmME=; b=JJxksrWNt+hd6DQdJvyE+TsALCGIymeeH9zE5Iiq2rcLRPovTYuagxZ228jkurKswi/2UA9pSsEGsxs5fMwwiSDqtpIuvec386a8HLnAkLnCGeGSRu+9uP6zpkf4vJJzciLAT3+qfKEA97fVsTYVOgPhbH7NhEP1D3eNR9qQGq7JZ8H+tyNeXz3iR80nj6vraZeIKGA0LeCqNR8piPY1YsTiquJY+qxYg/OM3PbTD1wGEYhL1yvwgIsP0PTDVDfLDK+mzp2sJtl1rXMF8VsOmIy6lP7fivKwMU4VnZhrNPxVZKOt5z67HXvqg9yTo9sw3WZkJOTOezKnRq28x+jmiw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t4Gpe-00027e-7T for guix-patches@gnu.org; Fri, 25 Oct 2024 05:42:10 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73927] [PATCH v3 17/17] installer: Support dry-run from Guile via store. Resent-From: Janneke Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Oct 2024 09:42:10 +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 Received: via spool by 73927-submit@debbugs.gnu.org id=B73927.17298492947978 (code B ref 73927); Fri, 25 Oct 2024 09:42:10 +0000 Received: (at 73927) by debbugs.gnu.org; 25 Oct 2024 09:41:34 +0000 Received: from localhost ([127.0.0.1]:37349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4Gp3-00024X-DO for submit@debbugs.gnu.org; Fri, 25 Oct 2024 05:41:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4Gou-00022N-Je for 73927@debbugs.gnu.org; Fri, 25 Oct 2024 05:41:25 -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 1t4GoJ-0003pg-Gi; Fri, 25 Oct 2024 05:40:47 -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=+STQwkKh3SyvccoJDqQkts7U4WNa17HyCQ6CzqURmME=; b=OQehZTuTw7uxEuBS48+D nwHksk2R5cQodiWMNecm4VmGEXSe6c4wyv+roLPO0MN563lXS2gDCHWjC/26eQlOn50oqiXBIjbrp GTxZw2HbEhp3N/PTg5QJugtQBt92u4xAlvKYSavd5qcwoNqlRNWvSWF1QzstcPrf8rQxgcHW5o2Oh TrdO7CL8mJiVA7xfF9DeXWozHXqFB71YadS+EDFLLJb7lo/VA4PChPHj7GgKnw51wv/bN09lY+JIN ILc4fiQdBQgSZQyVRzQuoDx1ij1SGPdWu4rNxeUOZoI1NaBLJqjijJ2IEVm18o6hbGe2qC8xtgIAl 5UAbD6gHRC2ymA==; From: Janneke Nieuwenhuizen Date: Fri, 25 Oct 2024 11:40:09 +0200 Message-ID: <20241025094011.8540-18-janneke@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241025094011.8540-1-janneke@gnu.org> References: <20241025094011.8540-1-janneke@gnu.org> 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 | 84 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/gnu/installer.scm b/gnu/installer.scm index 31c0ff7ff4..981687990a 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,77 @@ (define action (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)))