GNU bug report logs - #53672
[PATCH] guix system: 'describe' shows the running system, not the current one.

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Mon, 31 Jan 2022 22:37:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 53672 in the body.
You can then email your comments to 53672 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#53672; Package guix-patches. (Mon, 31 Jan 2022 22:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 31 Jan 2022 22:37:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH] guix system: 'describe' shows the running system,
 not the current one.
Date: Mon, 31 Jan 2022 23:36:18 +0100
* guix/profiles.scm (generation-number): Add optional 'base-profile'
parameter and use it.
* guix/scripts/system.scm (process-command): Add "/run/current-system"
as first argument to 'generation-number'.
* doc/guix.texi (Invoking guix system): Clarify that 'guix system
describe' shows the running system.
---
 doc/guix.texi           | 14 +++++++++++++-
 guix/profiles.scm       | 13 +++++++++----
 guix/scripts/system.scm |  4 ++--
 3 files changed, 24 insertions(+), 7 deletions(-)

Hello!

Having reconfigured my system, generation N was “current”.  I booted
into generation N-1 and noticed that ‘guix system describe’ would
still display generation N—the “current” generation, but not the one
I’m actually running.

I think it’s counter-intuitive so this patch changes that so that
‘guix system describe’ shows the “running” generation—which, in this
case, is N-1.

Objections? Thoughts?

Ludo’.

diff --git a/doc/guix.texi b/doc/guix.texi
index 94f8e5e481..8f5312217f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -35724,9 +35724,21 @@ bootloader boot menu:
 @table @code
 
 @item describe
-Describe the current system generation: its file name, the kernel and
+Describe the running system generation: its file name, the kernel and
 bootloader used, etc., as well as provenance information when available.
 
+@quotation Note
+The @emph{running} system generation---referred to by
+@file{/run/current-system}---is not necessarily the @emph{current}
+system generation---referred to by @file{/var/guix/profiles/system}: it
+differs when, for instance, you chose from the bootloader menu to boot
+an older generation.
+
+It can also differ from the @emph{booted} system generation---referred
+to by @file{/run/booted-system}---for instance because you reconfigured
+the system in the meantime.
+@end quotation
+
 @item list-generations
 List a summary of each generation of the operating system available on
 disk, in a human-readable way.  This is similar to the
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 1d354ecb78..96be421727 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2013-2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita <at> karetnikov.org>
 ;;; Copyright © 2014, 2016 Alex Kost <alezost <at> gmail.com>
 ;;; Copyright © 2015 Mark H Weaver <mhw <at> netris.org>
@@ -2037,9 +2037,14 @@ (define (profile-regexp profile)
   (make-regexp (string-append "^" (regexp-quote (basename profile))
                               "-([0-9]+)")))
 
-(define (generation-number profile)
-  "Return PROFILE's number or 0.  An absolute file name must be used."
-  (or (and=> (false-if-exception (regexp-exec (profile-regexp profile)
+(define* (generation-number profile
+                            #:optional (base-profile profile))
+  "Return PROFILE's number or 0.  An absolute file name must be used.
+
+Optionally, if BASE-PROFILE is provided, use it instead of PROFILE to
+construct the regexp matching generations.  This is useful in special cases
+like: (generation-number \"/run/current-system\" %system-profile)."
+  (or (and=> (false-if-exception (regexp-exec (profile-regexp base-profile)
                                               (basename (readlink profile))))
              (compose string->number (cut match:substring <> 1)))
       0))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 414e931c8a..430815902d 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2014-2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2016 Alex Kost <alezost <at> gmail.com>
 ;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe <at> gmail.com>
@@ -1328,7 +1328,7 @@ (define-syntax-rule (with-store* store exp ...)
                       (x (leave (G_ "wrong number of arguments~%"))))))
        (list-generations pattern)))
     ((describe)
-     (match (generation-number %system-profile)
+     (match (generation-number "/run/current-system" %system-profile)
        (0
         (leave (G_ "no system generation, nothing to describe~%")))
        (generation

base-commit: 27c1d58d901dcf48929bcb6f76d861fc21575dbf
-- 
2.34.0





Information forwarded to guix-patches <at> gnu.org:
bug#53672; Package guix-patches. (Tue, 01 Feb 2022 09:55:01 GMT) Full text and rfc822 format available.

Message #8 received at 53672 <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> outlook.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 53672 <at> debbugs.gnu.org
Subject: Re: bug#53672: [PATCH] guix system: 'describe' shows the running
 system, not the current one.
Date: Tue, 01 Feb 2022 17:54:08 +0800
Ludovic Courtès <ludo <at> gnu.org> writes:

> * guix/profiles.scm (generation-number): Add optional 'base-profile'
> parameter and use it.
> * guix/scripts/system.scm (process-command): Add "/run/current-system"
> as first argument to 'generation-number'.
> * doc/guix.texi (Invoking guix system): Clarify that 'guix system
> describe' shows the running system.
> ---
>  doc/guix.texi           | 14 +++++++++++++-
>  guix/profiles.scm       | 13 +++++++++----
>  guix/scripts/system.scm |  4 ++--
>  3 files changed, 24 insertions(+), 7 deletions(-)
>
> Hello!
>
> Having reconfigured my system, generation N was “current”.  I booted
> into generation N-1 and noticed that ‘guix system describe’ would
> still display generation N—the “current” generation, but not the one
> I’m actually running.
>
> I think it’s counter-intuitive so this patch changes that so that
> ‘guix system describe’ shows the “running” generation—which, in this
> case, is N-1.
>
> Objections? Thoughts?

Sound good to me!  Well, I think "current" and "running" are the same
thing, I'd call the 'profiles/system' one "latest", so my understand is:

1. /run/booted-system: the system generation booted by bootloader.

2. /run/current-system: the system generation current running, same as
   booted until we do a system 'reconfigure' or 'roll-back'.

3. /var/guix/profiles/system: always point to the latest system-*-link,
   the default one in the bootloader, changed by a system 'reconfigure'
   or 'roll-back'.

Please correct me if it's wrong, thank you!




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 02 Feb 2022 17:14:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Wed, 02 Feb 2022 17:14:02 GMT) Full text and rfc822 format available.

Message #13 received at 53672-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 宋文武 <iyzsong <at> outlook.com>
Cc: 53672-done <at> debbugs.gnu.org
Subject: Re: bug#53672: [PATCH] guix system: 'describe' shows the running
 system, not the current one.
Date: Wed, 02 Feb 2022 18:13:03 +0100
Hello!

宋文武 <iyzsong <at> outlook.com> skribis:

> Sound good to me!  Well, I think "current" and "running" are the same
> thing, I'd call the 'profiles/system' one "latest", so my understand is:
>
> 1. /run/booted-system: the system generation booted by bootloader.
>
> 2. /run/current-system: the system generation current running, same as
>    booted until we do a system 'reconfigure' or 'roll-back'.
>
> 3. /var/guix/profiles/system: always point to the latest system-*-link,
>    the default one in the bootloader, changed by a system 'reconfigure'
>    or 'roll-back'.
>
> Please correct me if it's wrong, thank you!

You’re right, except for #3: if you do ‘guix system roll-back’ and
reboot, then /var/guix/profiles/system points to a generation that’s not
the latest system-*-link but that is the currently running one.

It sounds super confusing but it’s quite intuitive I think (I hope?).

Applied now, thanks for taking a look!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Mar 2022 12:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 113 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.