unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25100: 'guix system reconfigure' fails when new generation already exists
@ 2016-12-03 10:24 Chris Marusich
  2016-12-05 20:35 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Marusich @ 2016-12-03 10:24 UTC (permalink / raw)
  To: 25100


[-- Attachment #1.1: Type: text/plain, Size: 737 bytes --]

Hi,

I've noticed that, in GuixSD, if one rolls back the system with 'guix
system roll-back' or switches to a previous generation with 'guix system
switch-generation', and then one tries to run 'guix system reconfigure',
the operation fails because the symlink for the new generation already
exists.  I expected the operation to succeed and overwrite the existing
generation, since that mirrors the behavior of 'guix package'.

Specifically, if the current generation is N and generation N+1 exists,
then running 'guix system reconfigure' should overwrite generation N+1
with the new system.  Currently, it fails to create the symlink.  I've
attached a patch which modifies the behavior to be what I expected.

-- 
Chris

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-system-If-the-new-system-generation-already-exists-o.patch --]
[-- Type: text/x-patch, Size: 2965 bytes --]

From 526f78a38dabeb12196a21cebe174f073c217c12 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Fri, 2 Dec 2016 01:52:04 -0800
Subject: [PATCH] system: If the new system generation already exists,
 overwrite it.

* guix/scripts/system.scm (switch-to-system): Create the symlink to the new
  system generation using the procedure "switch-symlink" instead of "symlink".
  That way, if the link already exists, we update it instead of failing.

* doc/guix.texi (Using the Configuration System, Invoking guix system):
  Document the behavior.
---
 doc/guix.texi           | 16 +++++++++++++++-
 guix/scripts/system.scm |  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3b4ba48..45d8dfe 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7155,7 +7155,15 @@ modifying or deleting previous generations.  Old system generations get
 an entry in the GRUB boot menu, allowing you to boot them in case
 something went wrong with the latest generation.  Reassuring, no?  The
 @command{guix system list-generations} command lists the system
-generations available on disk.
+generations available on disk.  It is also possible to roll back the
+system via the commands @command{guix system roll-back} and
+@command{guix system switch-generation}.
+
+Although the command @command{guix system reconfigure} will not modify
+previous generations, must take care when the current generation is not
+the latest (e.g., after invoking @command{guix system roll-back}), since
+the operation might overwrite a later generation @pxref{Invoking guix
+system}.
 
 @unnumberedsubsubsec The Programming Interface
 
@@ -12487,6 +12495,12 @@ currently running; if a service is currently running, it does not
 attempt to upgrade it since this would not be possible without stopping it
 first.
 
+This command creates a new generation whose number is one greater than
+the current generation (as reported by @command{guix system
+list-generations}).  If that generation already exists, it will be
+overwritten.  This behavior mirrors that of @command{guix package}
+@pxref{Invoking guix package}.
+
 It also adds a GRUB menu entry for the new OS configuration, and moves
 entries for older configurations to a submenu---unless
 @option{--no-grub} is passed.
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index bb373a6..144a7fd 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -326,7 +326,7 @@ it atomically, and then run OS's activation script."
     (let* ((system     (derivation->output-path drv))
            (number     (+ 1 (generation-number profile)))
            (generation (generation-file-name profile number)))
-      (symlink system generation)
+      (switch-symlinks generation system)
       (switch-symlinks profile generation)
 
       (format #t (_ "activating system...~%"))
-- 
2.10.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#25100: 'guix system reconfigure' fails when new generation already exists
  2016-12-03 10:24 bug#25100: 'guix system reconfigure' fails when new generation already exists Chris Marusich
@ 2016-12-05 20:35 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2016-12-05 20:35 UTC (permalink / raw)
  To: Chris Marusich; +Cc: 25100-done

Hi!

Chris Marusich <cmmarusich@gmail.com> skribis:

> I've noticed that, in GuixSD, if one rolls back the system with 'guix
> system roll-back' or switches to a previous generation with 'guix system
> switch-generation', and then one tries to run 'guix system reconfigure',
> the operation fails because the symlink for the new generation already
> exists.  I expected the operation to succeed and overwrite the existing
> generation, since that mirrors the behavior of 'guix package'.
>
> Specifically, if the current generation is N and generation N+1 exists,
> then running 'guix system reconfigure' should overwrite generation N+1
> with the new system.  Currently, it fails to create the symlink.  I've
> attached a patch which modifies the behavior to be what I expected.

Indeed.

> From 526f78a38dabeb12196a21cebe174f073c217c12 Mon Sep 17 00:00:00 2001
> From: Chris Marusich <cmmarusich@gmail.com>
> Date: Fri, 2 Dec 2016 01:52:04 -0800
> Subject: [PATCH] system: If the new system generation already exists,
>  overwrite it.
>
> * guix/scripts/system.scm (switch-to-system): Create the symlink to the new
>   system generation using the procedure "switch-symlink" instead of "symlink".
>   That way, if the link already exists, we update it instead of failing.
>
> * doc/guix.texi (Using the Configuration System, Invoking guix system):
>   Document the behavior.

[...]

> +overwritten.  This behavior mirrors that of @command{guix package}
> +@pxref{Invoking guix package}.

Note: @pxref is for parenthetical expressions (info "(texinfo) pxref").

I adjusted this and the commit log and committed.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-05 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-03 10:24 bug#25100: 'guix system reconfigure' fails when new generation already exists Chris Marusich
2016-12-05 20:35 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).