guix system: 'describe' shows the running system, not the current one.
* 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.
This commit is contained in:
parent
62e3ba78af
commit
9679123ce0
|
@ -35811,9 +35811,21 @@ bootloader boot menu:
|
||||||
@table @code
|
@table @code
|
||||||
|
|
||||||
@item describe
|
@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.
|
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
|
@item list-generations
|
||||||
List a summary of each generation of the operating system available on
|
List a summary of each generation of the operating system available on
|
||||||
disk, in a human-readable way. This is similar to the
|
disk, in a human-readable way. This is similar to the
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2013-2022 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
||||||
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
|
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
|
||||||
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
|
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
|
||||||
|
@ -2037,9 +2037,14 @@ (define (profile-regexp profile)
|
||||||
(make-regexp (string-append "^" (regexp-quote (basename profile))
|
(make-regexp (string-append "^" (regexp-quote (basename profile))
|
||||||
"-([0-9]+)")))
|
"-([0-9]+)")))
|
||||||
|
|
||||||
(define (generation-number profile)
|
(define* (generation-number profile
|
||||||
"Return PROFILE's number or 0. An absolute file name must be used."
|
#:optional (base-profile profile))
|
||||||
(or (and=> (false-if-exception (regexp-exec (profile-regexp 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))))
|
(basename (readlink profile))))
|
||||||
(compose string->number (cut match:substring <> 1)))
|
(compose string->number (cut match:substring <> 1)))
|
||||||
0))
|
0))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
|
;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
|
||||||
;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com>
|
;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com>
|
||||||
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
|
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
|
||||||
|
@ -1328,7 +1328,7 @@ (define-syntax-rule (with-store* store exp ...)
|
||||||
(x (leave (G_ "wrong number of arguments~%"))))))
|
(x (leave (G_ "wrong number of arguments~%"))))))
|
||||||
(list-generations pattern)))
|
(list-generations pattern)))
|
||||||
((describe)
|
((describe)
|
||||||
(match (generation-number %system-profile)
|
(match (generation-number "/run/current-system" %system-profile)
|
||||||
(0
|
(0
|
||||||
(leave (G_ "no system generation, nothing to describe~%")))
|
(leave (G_ "no system generation, nothing to describe~%")))
|
||||||
(generation
|
(generation
|
||||||
|
|
Loading…
Reference in a new issue