From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id kGvhBNfyrmY36QAA62LTzQ:P1 (envelope-from ) for ; Sun, 04 Aug 2024 03:17:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id kGvhBNfyrmY36QAA62LTzQ (envelope-from ) for ; Sun, 04 Aug 2024 05:17:43 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=JMHfMoq7; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail2 header.b="odvQ/3TZ"; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail2 header.b=Y2TFPijt; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1722741462; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=qwGZKiXieyigE1Z6gQ2W21+mcjAALtB7u2ZYs2VSv4E=; b=qao4EWIPMldsabVc5qGz1BO+HMuIV3JBBZsaK65Ybj8MQDmV/rzPqtuuCr2cp2LCwHLnu1 2Oc7Vsh3pE9m2a6E8dEgjofdPbLlR3eNPUR/a5B6V90HwJWgMGKa8xDjyYLdx4hDwoHqjQ md1bDrIjamCKhivfiv5BPuB0/tzOBNpDSJsWkuXVENkkDKiUR05daLeKvzVIWLGOJHk+fS GpzAUSyV53kCBEm34PdleKE8Fufu3OWgbSD+i4l52E8VyGhUOEFZYd3lO1jYKurG/gzeI1 HXCNuULO2UWKJeb9D3CTkkzU8GSnopQeMRPGnCUzbzpersC4dN36vPqHCEdq8w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=JMHfMoq7; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail2 header.b="odvQ/3TZ"; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail2 header.b=Y2TFPijt; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1722741462; a=rsa-sha256; cv=none; b=U96Ibp5evGmsNsInlm4biYttLdNt0SDMVWNX2rDeXSv+SO931neJsY2EseX++fyIHvlYIW fz3qlbiDHM7h6fqvzbRjL7S136KbVJjZ0go9sRHGVVGo0pUjIhyYF63M88xkY774Kvoi5R bPRWWPv6WI5OR2KuaRFp/mG0/60+6Kh+8USbGl2iyACUcH3YtWUSax+qFddHlPrdQIhHBD ugecr0GlFw2Y0ON3SXJXwluulP1aQOnnLDGCwC+ZOPGPieSGucHa4buvgfPmh9mc61dE3t B3ytq0m/nTf8IOsuo5kSTelmXt7Ij851Ss+7xTnsXHkX0NNEZ5rrwXHgeekIEg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CACA36DB47 for ; Sun, 4 Aug 2024 05:17:42 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1saRjx-0003mV-G4; Sat, 03 Aug 2024 23:17:01 -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 1saRjn-0003km-79 for guix-patches@gnu.org; Sat, 03 Aug 2024 23:16:51 -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 1saRjl-0002RT-IH; Sat, 03 Aug 2024 23:16:50 -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=qwGZKiXieyigE1Z6gQ2W21+mcjAALtB7u2ZYs2VSv4E=; b=JMHfMoq7Ft/NY37vDRkNqQwZIbFf63A18T26LVcj/Tz1l0Hk3q/Bt7rLzUsZqkioihjRP3uO83WXQA6mPcD3CqHjTMLSUWg/YOpVNOUVg1ycI+ulxV9GfLpold1c3Iqf2nllThu/y2XQE0Hv8HFW0t5DT2YwJljYTsZwNF46m2KC2Nvv4CkAOEL86Ubd0aoDuP3/cF4O7G3e3vs9s061Ptni/wuv5J7nHwPlcvbNS6PkbIH1LxjxIDt6T+N2h/CQ+WHuh0yChE51X0oB24gGZmjUjUu2X0HvvUyHhlXDMthLaDj1KPCWkUx9+hDpjgg7zzOPAzPfIHB9r0EQrP7WSA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1saRk4-0007pA-PR; Sat, 03 Aug 2024 23:17:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69343] [PATCH v3 12/12] Encapsulate to retain generation, system-path and epoch. Resent-From: Lilah Tascheter Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 04 Aug 2024 03:17:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69343 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69343@debbugs.gnu.org Cc: Felix Lechner , Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69343-submit@debbugs.gnu.org id=B69343.172274142229942 (code B ref 69343); Sun, 04 Aug 2024 03:17:08 +0000 Received: (at 69343) by debbugs.gnu.org; 4 Aug 2024 03:17:02 +0000 Received: from localhost ([127.0.0.1]:55037 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saRjx-0007mc-Ot for submit@debbugs.gnu.org; Sat, 03 Aug 2024 23:17:02 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:56606) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saRjv-0007m6-Hj for 69343@debbugs.gnu.org; Sat, 03 Aug 2024 23:17:00 -0400 DKIM-Signature: a=rsa-sha256; b=odvQ/3TZNBWJWPETPFKX8H9JoeOVd+QfA7ZLfcVJk3zsM+319FkrIhyndA8feBBv0Br4vv83oM6ZN0fjCydl0PmCQkKimj/kUXKj1kjIeAqxqyL8OkOafuaIAM1Avdc/fB9CVnlsDViiOdg6+j8JZG37VVi6kBpE3HN2vrUFihqYmPpdzbwICK1pS2Dtqeu7xS4TOE02sh8KozV1h2EIwLalqKo+ApMTQ8S6OhndTvimq7UW8ZvtDgoiSo3n5SCdjKEF0nSZjJy7A4JcreW3SpaRPWknQ+gBYoR4UOXCx5TeqsAbysjOHycP0NdN0cQTznxR8LcL53FSMgnOKIQcXQ==; s=purelymail2; d=lunabee.space; v=1; bh=RUHmSuhS5uGJenfJXJKaEJCl2J6PvkMjfkqxRW4ZKHI=; h=Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=Y2TFPijtjktrmsFyWkzw+S9QsO2mFSUvVdMlzt5B/cX8FP8MNJEG3OaDCaM8SRftBnKvZnLu5aMiQQ6g2Ud4DT/pk/CCB5s6QHpprdHhoxdMu5Vhadlwr8LIshBIrXrLWRV900P+w5uLJLbP/R1ErBdhp7EdB+RyKllaYJ4isLmP7ovtSNHBZaGXw+nzDkcxTH/SFKxmXeNwzM/T+jjDz7R6WOvw6uqaVNgxzCWiLRLYsN+t4vW3aqX+oHLK9U9BQfiBNp3EYvxyWWPBaBpdV6vyQpPxyqWVkQrjbDgmOrDam1CaXGL9Vj7nZozsuIdh2SHTBQjHJ3vGtkTYb6EAQA==; s=purelymail2; d=purelymail.com; v=1; bh=RUHmSuhS5uGJenfJXJKaEJCl2J6PvkMjfkqxRW4ZKHI=; h=Feedback-ID:Received:From:To:Subject:Date; Feedback-ID: 8937:2070:null:purelymail X-Pm-Original-To: 69343@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -2124817350; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 04 Aug 2024 03:15:42 +0000 (UTC) Date: Sat, 3 Aug 2024 22:13:34 -0500 Message-ID: <7d781027c78bdea5fdb3f1c9c9ec432b9606d2b5.1722741214.git.lilah@lunabee.space> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail Content-Type: text/plain; charset=UTF-8 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: , From: Lilah Tascheter via Guix-patches Reply-To: Lilah Tascheter Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -5.44 X-Migadu-Queue-Id: CACA36DB47 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -5.44 X-TUID: 2HCb++Pdjhi1 From: Felix Lechner * gnu/system/boot.scm (): New record. * gnu/machine/ssh.scm (machine->boot-alternatives): Return a boot-alternative encapsulating previous return value. (with-roll-back, roll-back-managed-host): Get parameters from boot-alternatives. * guix/scripts/system.scm (generation->boot-parameters): Rename to... (generation->boot-alternative): ...this. Return a boot-alternative encapsulating previous return value. (profile->boot-alternatives): Rename uses as above. (reinstall-bootloader, perform-action): Get parameters from boot-alternatives. Change-Id: Iaef0b0a3fa9240ca8315a9699bcf4a7bfe908e33 --- gnu/machine/ssh.scm | 32 ++++++++++++++++++++------------ gnu/system/boot.scm | 14 ++++++++++++++ guix/scripts/system.scm | 32 +++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index fa1066b27b..8dd8c342a0 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -416,8 +416,8 @@ (define not-config? (_ #f))) =20 (define (machine->boot-alternatives machine) - "Monadic procedure returning a list of 'boot-parameters' for the generat= ions -of MACHINE's system profile, ordered from most recent to oldest." + "Monadic procedure returning a list of records for th= e +generations of MACHINE's system profile, ordered from most recent to oldes= t." (define remote-exp (with-extensions (list guile-gcrypt) (with-imported-modules `(((guix config) =3D> ,(make-config.scm)) @@ -458,13 +458,18 @@ (define (machine->boot-alternatives machine) read-boot-parameters)) (root (boot-parameters-root-device params)) (text (boot-parameters-label params)) - (version (boot-parameters-version params))) - (boot-parameters - (inherit params) - (label (decorated-boot-label text generation epoch)) - (kernel-arguments - (append (bootable-kernel-arguments system-path root ver= sion) - (boot-parameters-kernel-arguments params)))))))= ) + (version (boot-parameters-version params)) + (parameters (boot-parameters + (inherit params) + (label (decorated-boot-label text gener= ation epoch)) + (kernel-arguments + (append (bootable-kernel-arguments sys= tem-path root version) + (boot-parameters-kernel-argume= nts params)))))) + (boot-alternative + (generation generation) + (system-path system-path) + (epoch epoch) + (parameters parameters)))))) remote-results)))) =20 (define-syntax-rule (with-roll-back should-roll-back? mbody ...) @@ -508,7 +513,8 @@ (define (deploy-managed-host machine) (%current-target-system #f)) (let* ((os (machine-operating-system machine)) (eval (cut machine-remote-eval machine <>)) - (menu-entries (map boot-parameters->menu-entry boot-alternati= ves)) + (menu-entries (map boot-parameters->menu-entry + (map boot-alternative-parameters boot-alte= rnatives))) (bootloader-configuration (operating-system-bootloader os)) (bootcfg (operating-system-bootcfg os menu-entries))) (define-syntax-rule (eval/error-handling condition handler ...) @@ -582,13 +588,15 @@ (define (roll-back-managed-host machine) (mlet* %store-monad ((boot-alternatives (machine->boot-alternatives mach= ine)) (_ -> (if (< (length boot-alternatives) 2) (raise roll-back-failure))) - (parameters (second boot-alternatives)) + (chosen-alternative (second boot-alternatives)) + (parameters (boot-alternative-parameters chosen-alt= ernative)) (entries -> (list (boot-parameters->menu-entry para= meters))) (locale -> (boot-parameters-locale parameters)) (crypto-dev -> (boot-parameters-store-crypto-device= s parameters)) (store-dir -> (boot-parameters-store-directory-pref= ix parameters)) (old-entries -> (map boot-parameters->menu-entry - (drop boot-alternatives 2))) + (map boot-alternative-paramete= rs + (drop boot-alternatives 2= )))) (bootloader -> (operating-system-bootloader (machine-operating-system machine))= ) (bootcfg (lower-object diff --git a/gnu/system/boot.scm b/gnu/system/boot.scm index b1302b8786..833caef496 100644 --- a/gnu/system/boot.scm +++ b/gnu/system/boot.scm @@ -71,6 +71,13 @@ (define-module (gnu system boot) read-boot-parameters-file bootable-kernel-arguments =20 + boot-alternative + boot-alternative? + boot-alternative-generation + boot-alternative-system-path + boot-alternative-epoch + boot-alternative-parameters + epoch->date-string decorated-boot-label boot-parameters->menu-entry @@ -299,6 +306,13 @@ (define* (bootable-kernel-arguments system root-device= version) #~(string-append (if #$version>0? "gnu.load=3D" "--load=3D") #$system "/boot"))))) =20 +(define-record-type* + boot-alternative make-boot-alternative boot-alternative? + (generation boot-alternative-generation) + (system-path boot-alternative-system-path) + (epoch boot-alternative-epoch) + (parameters boot-alternative-parameters)) + (define (epoch->date-string epoch) "Return a string representing the date for EPOCH seconds." (let ((time (make-time time-utc 0 epoch))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 0c69f6d90b..0f7d864e06 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -328,26 +328,31 @@ (define-syntax-rule (unless-file-not-found exp) #f (apply throw args))))) =20 -(define (generation->boot-parameters profile number) - "Return the 'boot-parameters' for the generation of PROFILE specified +(define (generation->boot-alternative profile number) + "Return the 'boot-alternative' for the generation of PROFILE specified by NUMBER." (unless-file-not-found (let* ((system (generation-file-name profile number)) (params (read-boot-parameters-file system)) (epoch (stat:mtime (lstat system))) - (text (boot-parameters-label params))) - (boot-parameters - (inherit params) - (label (decorated-boot-label text number epoch)))))) + (text (boot-parameters-label params)) + (parameters (boot-parameters + (inherit params) + (label (decorated-boot-label text number epoch))))) + (boot-alternative + (generation number) + (system-path system) + (epoch epoch) + (parameters parameters))))) =20 (define* (profile->boot-alternatives #:optional (profile %system-profile) (numbers (reverse (generation-numbers profile= )))) - "Return a list of 'boot-parameters' for the generations of PROFILE speci= fied + "Return a list of 'boot-alternative' for the generations of PROFILE spec= ified by NUMBERS, which is a list of generation numbers. The list is ordered fro= m the most recent to the oldest profiles." (filter-map (lambda (number) - (generation->boot-parameters profile number)) + (generation->boot-alternative profile number)) numbers)) =20 =0C @@ -396,7 +401,9 @@ (define (reinstall-bootloader store number) (bootloader bootloader))) =20 ;; Make the specified system generation the default entry. - (params (generation->boot-parameters %system-profile number)) + (chosen-alternative (generation->boot-alternative + %system-profile number)) + (params (boot-alternative-parameters chosen-alternative)) (locale (boot-parameters-locale params)) (store-crypto-devices (boot-parameters-store-crypto-devices param= s)) (store-directory-prefix @@ -407,7 +414,8 @@ (define (reinstall-bootloader store number) %system-profile old-generations)) (entries (list (boot-parameters->menu-entry params))) (old-entries (map boot-parameters->menu-entry - previous-boot-alternatives))) + (map boot-alternative-parameters + previous-boot-alternatives)))) (run-with-store store (mlet* %store-monad ((bootcfg (lower-object @@ -824,7 +832,9 @@ (define* (perform-action action image os (if (eq? action 'init) '() - (map boot-parameters->menu-entry (profile->boot-alternatives= )))))) + (map boot-parameters->menu-entry + (map boot-alternative-parameters + (profile->boot-alternatives))))))) =20 (when (eq? action 'reconfigure) (maybe-suggest-running-guix-pull) --=20 2.45.2