X-Loop: help-debbugs@HIDDEN Subject: [bug#75414] [PATCH 0/2] Add roll-back action to guix deploy Resent-From: Arun Isaac <arunisaac@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Tue, 07 Jan 2025 00:19:02 +0000 Resent-Message-ID: <handler.75414.B.173620913113738 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 75414 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75414 <at> debbugs.gnu.org Cc: Arun Isaac <arunisaac@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-To: guix-patches@HIDDEN X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.173620913113738 (code B ref -1); Tue, 07 Jan 2025 00:19:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Jan 2025 00:18:51 +0000 Received: from localhost ([127.0.0.1]:41022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tUxJ5-0003ZW-97 for submit <at> debbugs.gnu.org; Mon, 06 Jan 2025 19:18:51 -0500 Received: from lists.gnu.org ([2001:470:142::17]:46776) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <arunisaac@HIDDEN>) id 1tUxJ2-0003ZF-2l for submit <at> debbugs.gnu.org; Mon, 06 Jan 2025 19:18:49 -0500 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 <arunisaac@HIDDEN>) id 1tUxIw-0001DT-Gb for guix-patches@HIDDEN; Mon, 06 Jan 2025 19:18:42 -0500 Received: from mugam.systemreboot.net ([139.59.75.54]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <arunisaac@HIDDEN>) id 1tUxIr-00040M-Ds for guix-patches@HIDDEN; Mon, 06 Jan 2025 19:18:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemreboot.net; s=default; t=1736209102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=kYtgXpIoZt8Mfdb6l/AA0q9L6u0GUBg6nKKgBTzQ0XM=; b=BOyAS7NSKchmS5OtMiws4Dg4y5WoAsxJ+XlK0+OTeyjO1EMpVCG2gn2TlEYa28LW8M5SC3 8zsSIsp8OzlvNkD9/o06PaKSvc2c2Pgi2JEEzOap2T5/zMDOPUkwS/ODQtSRvneqD8ZdpW xd+6Lm/aoemNMkf14Qamn+Qw0oPV2sa1Zm0ZirJvf5YV38wO124DQw1c7unUPHk5MG+7t8 6RyEHPwloTK50Fb7ZYMWohkJAxE3YU2rkz0l3LJ0Mux8CjY2qpVdyF776/wVIdvE1T+hrg 2AhY+rffobYlZgush560peazGocG4Y8QWmsmvLvYbRY6U7cubcG67gbOHKSuwQ== Received: from localhost.localdomain (<unknown> [192.168.2.1]) by mugam.systemreboot.net (OpenSMTPD) with ESMTPSA id edd93c6c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Jan 2025 00:18:21 +0000 (UTC) From: Arun Isaac <arunisaac@HIDDEN> Date: Tue, 7 Jan 2025 00:18:08 +0000 Message-ID: <cover.1736208948.git.arunisaac@HIDDEN> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=139.59.75.54; envelope-from=arunisaac@HIDDEN; helo=mugam.systemreboot.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) Hi, I implement a roll-back action for guix deploy. This is convenient to roll back all machines in a `guix deploy' configuration. By the by, PATCH 1 fixes a bug necessary to make this work. Regards, Arun Arun Isaac (2): machine: ssh: Return monadic value from roll-back-managed-host. deploy: Add roll-back action. doc/guix.texi | 7 ++++ gnu/machine/ssh.scm | 6 ++- guix/scripts/deploy.scm | 90 +++++++++++++++++++++++++++++++++-------- 3 files changed, 84 insertions(+), 19 deletions(-) base-commit: 67a535351f8678969e412e8dba9197a883b524d0 -- 2.47.1
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Arun Isaac <arunisaac@HIDDEN> Subject: bug#75414: Acknowledgement ([PATCH 0/2] Add roll-back action to guix deploy) Message-ID: <handler.75414.B.173620913113738.ack <at> debbugs.gnu.org> References: <cover.1736208948.git.arunisaac@HIDDEN> X-Gnu-PR-Message: ack 75414 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 75414 <at> debbugs.gnu.org Date: Tue, 07 Jan 2025 00:19:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. As you requested using X-Debbugs-CC, your message was also forwarded to Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>,= Ludovic Court=C3=A8s <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, = Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune= @gmail.com>, Tobias Geerinckx-Rice <me@HIDDEN> (after having been given a bug report number, if it did not have one). Your message has been sent to the package maintainer(s): guix-patches@HIDDEN If you wish to submit further information on this problem, please send it to 75414 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 75414: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75414 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: [bug#75414] [PATCH 1/2] machine: ssh: Return monadic value from roll-back-managed-host. Resent-From: Arun Isaac <arunisaac@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: arunisaac@HIDDEN, guix-patches@HIDDEN Resent-Date: Tue, 07 Jan 2025 00:29:02 +0000 Resent-Message-ID: <handler.75414.B75414.173620974115468 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75414 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75414 <at> debbugs.gnu.org Cc: Arun Isaac <arunisaac@HIDDEN>, Arun Isaac <arunisaac@HIDDEN> X-Debbugs-Original-Xcc: Arun Isaac <arunisaac@HIDDEN> Received: via spool by 75414-submit <at> debbugs.gnu.org id=B75414.173620974115468 (code B ref 75414); Tue, 07 Jan 2025 00:29:02 +0000 Received: (at 75414) by debbugs.gnu.org; 7 Jan 2025 00:29:01 +0000 Received: from localhost ([127.0.0.1]:41042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tUxSu-00041M-Qi for submit <at> debbugs.gnu.org; Mon, 06 Jan 2025 19:29:01 -0500 Received: from mugam.systemreboot.net ([139.59.75.54]:50610) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <arunisaac@HIDDEN>) id 1tUxSr-00040q-9W for 75414 <at> debbugs.gnu.org; Mon, 06 Jan 2025 19:28:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemreboot.net; s=default; t=1736209728; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=koPhJjsCT+WcG3YD0Y2UK8kA1x0JuaZMkZWun8KekNg=; b=XW74GDVfyx79iiNfOXtEUdsYaZMYYhZczvSajWZcqV2F0fiVppNLyaWYLPAk21ZIPzOZb5 FqpSscCU0Br48MRtMHzEoZi+RX1Lsziqi+Gj7M533HacCLHWhePwfbCduNRWG/MJIoFvRL 6D2B0TIAV63EIMFHmXNipUKkvJ1+d0JOPQtS4cxZV2dLl6UOYmzMGB4+ZVh8j4COOGJED9 IxJqXg9ExAF+muW68pSd/bjLHomTI4q2e+FvkOUQ12rXdEOVg/4e0ee2wWquhB/i95wzN5 pAyHsFbA0RI1hqykFdY4XXXp5KZWjTIW2h9zor0HlBxnuWQYqD149cjkaBq/og== Received: from localhost.localdomain (<unknown> [192.168.2.1]) by mugam.systemreboot.net (OpenSMTPD) with ESMTPSA id 00ab12d9 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Jan 2025 00:28:47 +0000 (UTC) From: Arun Isaac <arunisaac@HIDDEN> Date: Tue, 7 Jan 2025 00:28:30 +0000 Message-ID: <9d154b115a6a1bb7a7fb0cc24d1bd8c90a1437ab.1736208948.git.arunisaac@HIDDEN> X-Mailer: git-send-email 2.47.1 In-Reply-To: <cover.1736208948.git.arunisaac@HIDDEN> References: <cover.1736208948.git.arunisaac@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Previously, <unspecified> would be returned. That was a bug. Monadic procedures must always return monadic values. * gnu/machine/ssh.scm (roll-back-managed-host): Return monadic value. Change-Id: I3db2879dbfbcab5e9d251fa5ed02c8653adbeafb --- gnu/machine/ssh.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index bc4289ef7d..73d5dc513e 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@HIDDEN> ;;; Copyright © 2020-2024 Ludovic Courtès <ludo@HIDDEN> ;;; Copyright © 2024 Ricardo <rekado@HIDDEN> +;;; Copyright © 2025 Arun Isaac <arunisaac@HIDDEN> ;;; ;;; This file is part of GNU Guix. ;;; @@ -621,8 +622,9 @@ (define (roll-back-managed-host machine) #:store-directory-prefix store-dir #:old-entries old-entries))) (remote-result (machine-remote-eval machine remote-exp))) - (when (eqv? 'error remote-result) - (raise roll-back-failure)))) + (if (eqv? 'error remote-result) + (raise roll-back-failure) + (return remote-result)))) ;;; -- 2.47.1
X-Loop: help-debbugs@HIDDEN Subject: [bug#75414] [PATCH 2/2] deploy: Add roll-back action. Resent-From: Arun Isaac <arunisaac@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: arunisaac@HIDDEN, guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Tue, 07 Jan 2025 00:30:02 +0000 Resent-Message-ID: <handler.75414.B75414.173620974415514 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75414 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75414 <at> debbugs.gnu.org Cc: Arun Isaac <arunisaac@HIDDEN>, Arun Isaac <arunisaac@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Arun Isaac <arunisaac@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 75414-submit <at> debbugs.gnu.org id=B75414.173620974415514 (code B ref 75414); Tue, 07 Jan 2025 00:30:02 +0000 Received: (at 75414) by debbugs.gnu.org; 7 Jan 2025 00:29:04 +0000 Received: from localhost ([127.0.0.1]:41048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tUxSy-000429-5p for submit <at> debbugs.gnu.org; Mon, 06 Jan 2025 19:29:04 -0500 Received: from mugam.systemreboot.net ([139.59.75.54]:50610) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <arunisaac@HIDDEN>) id 1tUxSu-00040q-PC for 75414 <at> debbugs.gnu.org; Mon, 06 Jan 2025 19:29:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemreboot.net; s=default; t=1736209734; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=LitUQhQBPxqsOjhPgEiWuvKtbleA5haieRyDQkfxRvs=; b=LJPrLMMEZOok0tLT8WXy+YOsey1Q6a4rVLtw2ElPiXhP+lm+gBRFItRkaToPztkPO2OpLJ MJ1wCGmZAstP8aTcG1U0z+nK2Z73OxpkDxqQyVh+HK5SBRT9cYHHV6OT9jP9LlWoG2me9O sUWYE4o3cfash9LUY5IgimrC6vBIkEDSkdKW9ETW+VHhHIMtkYNmvP7uNhTABFnKuA4249 kak2bVdJ+L1L+cqWWBIEvLchWQP2nOuJrYkBFor5cVG3CGOKlcMwoPPhFAote++ZX2RdC1 YeXcK6N0StOsrWCTd+TJD1EWgMDzvGe3owt4cfGyZKAsUlkTC3HPhUt2ZmXg5w== Received: from localhost.localdomain (<unknown> [192.168.2.1]) by mugam.systemreboot.net (OpenSMTPD) with ESMTPSA id 9a4feff6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Jan 2025 00:28:53 +0000 (UTC) From: Arun Isaac <arunisaac@HIDDEN> Date: Tue, 7 Jan 2025 00:28:31 +0000 Message-ID: <48a1e0e70b6e9aef50c847e5882fd996c0a5476d.1736208948.git.arunisaac@HIDDEN> X-Mailer: git-send-email 2.47.1 In-Reply-To: <cover.1736208948.git.arunisaac@HIDDEN> References: <cover.1736208948.git.arunisaac@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/scripts/deploy.scm (guix-deploy): Add the roll-back action. (show-what-to-deploy): Optionally support the roll-back action. (roll-back-machine*): New function. (show-help): Document the roll-back action. * doc/guix.texi (Invoking guix deploy): Document the roll-back action. Change-Id: Ic5084f287aefb2d1d28380ca4ba1c6971cb913e7 --- doc/guix.texi | 7 ++++ guix/scripts/deploy.scm | 90 +++++++++++++++++++++++++++++++++-------- 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index b2bcab8791..c08c2c70ef 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -44354,6 +44354,13 @@ Invoking guix deploy The @command{guix deploy -x} command returns zero if and only if the command succeeded on all the machines. +You may also wish to roll back configurations on machines to a previous +generation. You can do that using + +@example +guix deploy roll-back @var{file} +@end example + @c FIXME/TODO: Separate the API doc from the CLI doc. Below are the data types you need to know about when writing a diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm index 941ee199f0..3f1b8b27a7 100644 --- a/guix/scripts/deploy.scm +++ b/guix/scripts/deploy.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@HIDDEN> ;;; Copyright © 2020-2022 Ludovic Courtès <ludo@HIDDEN> ;;; Copyright © 2024 Richard Sent <richard@HIDDEN> +;;; Copyright © 2025 Arun Isaac <arunisaac@HIDDEN> ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,8 +51,13 @@ (define-module (guix scripts deploy) (define (show-help) - (display (G_ "Usage: guix deploy [OPTION] FILE... -Perform the deployment specified by FILE.\n")) + (display (G_ "Usage: guix deploy [OPTION] [ACTION] FILE... +Perform the deployment specified by FILE. +Optionally, perform ACTION.\n\n")) + (display (G_ "The valid values for ACTION are:\n")) + (newline) + (display (G_ "\ + roll-back switch to the previous operating system configuration\n")) (show-build-options-help) (newline) (display (G_ " @@ -118,20 +124,32 @@ (define (load-source-file file) environment-modules)))) (load* file module))) -(define* (show-what-to-deploy machines #:key (dry-run? #f)) - "Show the list of machines to deploy, MACHINES." +(define* (show-what-to-deploy machines #:key (dry-run? #f) (roll-back? #f)) + "Show the list of machines in MACHINES to deploy or roll back." (let ((count (length machines))) (if dry-run? - (format (current-error-port) - (N_ "The following ~d machine would be deployed:~%" - "The following ~d machines would be deployed:~%" + (if roll-back? + (format (current-error-port) + (N_ "The following ~d machine would be rolled back:~%" + "The following ~d machines would be rolled back:~%" count) count) - (format (current-error-port) - (N_ "The following ~d machine will be deployed:~%" - "The following ~d machines will be deployed:~%" + (format (current-error-port) + (N_ "The following ~d machine would be deployed:~%" + "The following ~d machines would be deployed:~%" + count) + count)) + (if roll-back? + (format (current-error-port) + (N_ "The following ~d machine will be rolled back:~%" + "The following ~d machines will be rolled back:~%" + count) count) - count)) + (format (current-error-port) + (N_ "The following ~d machine will be deployed:~%" + "The following ~d machines will be deployed:~%" + count) + count))) (display (indented-string (fill-paragraph (string-join (map machine-display-name machines) ", ") @@ -175,6 +193,35 @@ (define (deploy-machine* store machine) (info (G_ "successfully deployed ~a~%") (machine-display-name machine)))) +(define (roll-back-machine* store machine) + "Roll back MACHINE, taking care of error handling." + (info (G_ "rolling back ~a...~%") + (machine-display-name machine)) + + (guard* (c + ;; On Guile 3.0, exceptions such as 'unbound-variable' are compound + ;; and include a '&message'. However, that message only contains + ;; the format string. Thus, special-case it here to avoid + ;; displaying a bare format string. + (((exception-predicate &exception-with-kind-and-args) c) + (raise c)) + + ((message-condition? c) + (leave (G_ "failed to roll back ~a: ~a~%") + (machine-display-name machine) + (condition-message c))) + ((formatted-message? c) + (leave (G_ "failed to roll back ~a: ~a~%") + (machine-display-name machine) + (apply format #f + (gettext (formatted-message-string c) + %gettext-domain) + (formatted-message-arguments c))))) + (run-with-store store (roll-back-machine machine))) + + (info (G_ "successfully rolled back ~a~%") + (machine-display-name machine))) + (define (invoke-command store machine command) "Invoke COMMAND, a list of strings, on MACHINE. Display its output (if any) and its error code if it's non-zero. Return true if COMMAND succeeded, false @@ -291,9 +338,18 @@ (define-command (guix-deploy . args) machines))) (_ (leave (G_ "'-x' specified but no command given~%")))) - (begin - (show-what-to-deploy machines #:dry-run? dry-run?) - (unless dry-run? - (map/accumulate-builds store - (cut deploy-machine* store <>) - machines))))))))))) + (match args + (("roll-back" _ ...) + (show-what-to-deploy machines + #:dry-run? dry-run? + #:roll-back? #t) + (unless dry-run? + (map/accumulate-builds store + (cut roll-back-machine* store <>) + machines))) + (_ + (show-what-to-deploy machines #:dry-run? dry-run?) + (unless dry-run? + (map/accumulate-builds store + (cut deploy-machine* store <>) + machines)))))))))))) -- 2.47.1
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.