From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id GOXmKov37GakOgAAe85BDQ:P1 (envelope-from ) for ; Fri, 20 Sep 2024 04:18:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id GOXmKov37GakOgAAe85BDQ (envelope-from ) for ; Fri, 20 Sep 2024 06:18:19 +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=PUC+BIvB; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail3 header.b=DibIcuQE; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail3 header.b=jjjxJhFB; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726805899; 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=CVCi42lFimSRcTBveBAN2e7asJDrqVnuPKZEwLFRcJE=; b=llGtfUJmDvpVJDgbnnPS6LX9muvTTcGzGgL65HDAzXZowkpzNkU9PVpUNGIKKS4LI7xQkG s+9iHXyXpsl6Cv8ciAr+El8APBW7SWCDKdEgRW9HeHPwPUwsr+oJFFaPK9Px8TFKaNkebx zLQZFm0BVddSLoACAt91/IuCxj6uS10vnzmWbZgM+YUkaggC8vqyqKxWXQmWfjt4EbSQ4u aL2vZILIczNXlgE/EAD6+35lg/kHRFOTQl3akk3L8GWfP7ssWCDa1z91NHm5OQ88LhzEKR sWcMIMhq51rnkwqRF+DQd2qoagpzXnG2WdLgbu1vzOeXtV1uGmLXcQCpeSZKaA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726805899; a=rsa-sha256; cv=none; b=EpJ/PHF/kmTHnKY/XW2J+RvQkolUs+mqbwVAI865VahLWEjX3nZMtY5giadetAF8kXJus6 Qfre1vcQuVJ7v855Q4KNliLBka4MRYNVnu8xTdJRFK5P6eZbbPRSDnBaqj5NGXpC8Zubyt lzloHt8s+moosULv3kRF+qoCvst5fUiwuj7yavMf62YKYOEBGPQpcVtvBgiIV6UlsPD/wL 3wfKi4pjHTAraQVvJYX0z5U5G9xtBTfquHjqOjC5kMbjzjuJIvRehXyBCnG2wTjSICBZqV 2TX353u2wpbKhAtLAck/8xl0ihq8/x2ohbigZhiQ5AoMsxVbL2udRnacG0sNiA== 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=PUC+BIvB; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail3 header.b=DibIcuQE; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail3 header.b=jjjxJhFB; dmarc=pass (policy=none) header.from=gnu.org; 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" 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 7ADB973D87 for ; Fri, 20 Sep 2024 06:18:19 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1srV5g-0008EI-1W; Fri, 20 Sep 2024 00:17:56 -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 1srV5b-0008Ct-BM for guix-patches@gnu.org; Fri, 20 Sep 2024 00:17:52 -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 1srV5b-0006HB-2V; Fri, 20 Sep 2024 00:17:51 -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=CVCi42lFimSRcTBveBAN2e7asJDrqVnuPKZEwLFRcJE=; b=PUC+BIvBVLhJLaguTGnyTVAI+tlFM+zBCFBPCeqR/pPYD4fIj2/OK3p23Ro6bqeqP0dqjlvVbWUKVzSdSPvsfUe/vHGqS7rRsTsHRr3njHYLciv+cpWbPGdMlLrWQViAU6+T1zVWqJLSk/T5lgyn21+W/EMBtK3CTxv90iubnDylIsYXj+QOcy6TAiWAcqCBs1ZrjWsLo9fbg8EvNbSc3u0tXfSr0Jv2IjvhQh+BTBwItG1lkBoJ/Fb2I02yxmkkyNt6A0G6qPZV4igiPq8NRv2yWUApv48FI8IrwgSyD0dSxv4GtGZWQgy0zVwfnRaq6VoykOu5n/JXT8uWVpRT4w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1srV5s-0005V9-Gw; Fri, 20 Sep 2024 00:18:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69343] [PATCH v4 11/11] 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: Fri, 20 Sep 2024 04:18: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: Herman Rimm , 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.172680588621103 (code B ref 69343); Fri, 20 Sep 2024 04:18:08 +0000 Received: (at 69343) by debbugs.gnu.org; 20 Sep 2024 04:18:06 +0000 Received: from localhost ([127.0.0.1]:33785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srV5p-0005Tu-3B for submit@debbugs.gnu.org; Fri, 20 Sep 2024 00:18:06 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:52048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srV5k-0005S7-LB for 69343@debbugs.gnu.org; Fri, 20 Sep 2024 00:18:01 -0400 DKIM-Signature: a=rsa-sha256; b=DibIcuQEXQw7YTzXyFPqPopKEUwmgrll1ZZCjnacTamT2mBRszLQYeNtIzdwamPFcaGAXRAUFG/8rei1WalRFz0WN7pONEXN3UeIoMYbz0cPeUmiwhbrzHpPkJMlQUmnnZsaHlROh4UnwYjSc5N1WaFLx1lm6QFyzS8/Fqm96N3D+8hBxH2vbHXvFGq+fwA4UXY+2AAxxMX6PcLAyFvUbPoIz1jgmv9UWuEPqUT63qCAyRLxpEYYthC1BfnbNPY9O/W8nJTkMfurapYIGpNHHJiRYzUlBcNjbH5MAMozA73AlDYxo9YBVOE5xD4S7yI7yuYrYcHMNQ+4oHk43zxeDg==; s=purelymail3; d=lunabee.space; v=1; bh=Wdaw++7Zd+Ll/cgrIr/flJd7mddXi3SKccGFa4Iyfic=; h=Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=jjjxJhFB7gvW4QvYIzVy5d73/DU21x1JUnPaRjEO430WssxEqEL6o9DnNm9sKxvO3MhA1/Z/GHQjTyPr7HU9oV5czRujCYX/eLdNdBnlr8ab5s7+gx9RhJl2Pz2/3m6fhGAEvRBCMeVQvY+XuPMstnPWF9rGyagwNz+WJ+pHO+xt+K6oXx28ixrVmcTpsl5XS+FRPpKHDxuiG4JhxnUU8SAx/lcRA8tHL9wVE593QODXnT/CPErM34MLcfjTIvGLsYS935E5H/d8LrZuvFxj5gDu0PQGQubBu89Q6popvRg8bb1qHSRMiDfWeHxm+1a8D5IMe5Rnchj92BxR5QQ+aw==; s=purelymail3; d=purelymail.com; v=1; bh=Wdaw++7Zd+Ll/cgrIr/flJd7mddXi3SKccGFa4Iyfic=; 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 -100958845; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Fri, 20 Sep 2024 04:17:21 +0000 (UTC) Date: Thu, 19 Sep 2024 23:16:05 -0500 Message-ID: <5440f547c4fd458acdc327afeded9a6067e98124.1726805765.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-Migadu-Spam-Score: -3.41 X-Spam-Score: -3.41 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Queue-Id: 7ADB973D87 X-TUID: X0B20Y2xttSU 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 | 29 ++++++++++++++++++----------- gnu/system/boot.scm | 14 ++++++++++++++ guix/scripts/system.scm | 32 +++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 37806a2e1b..ca0f3483a4 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)) @@ -459,13 +459,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 ...) @@ -509,7 +514,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 ...) @@ -583,7 +589,8 @@ (define (roll-back-managed-host machine) (mlet* %store-monad ((boot-alternatives (machine->boot-alternatives machine)) (_ -> (if (< (length boot-alternatives) 2) (raise roll-back-fail= ure))) - (parameters (second boot-alternatives)) + (chosen-alternative (second boot-alternatives)) + (parameters (boot-alternative-parameters chosen-alternative)) (entries -> (list (boot-parameters->menu-entry parameters))) (locale -> (boot-parameters-locale parameters)) (crypto-dev -> (boot-parameters-store-crypto-devices parameters)= ) diff --git a/gnu/system/boot.scm b/gnu/system/boot.scm index 82ca353cb3..c29e48d607 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