From 9679123ce083c69cdfd1505d95a4066d41280394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 31 Jan 2022 23:29:37 +0100 Subject: 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. --- guix/profiles.scm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'guix/profiles.scm') 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 +;;; Copyright © 2013-2022 Ludovic Courtès ;;; Copyright © 2013 Nikita Karetnikov ;;; Copyright © 2014, 2016 Alex Kost ;;; Copyright © 2015 Mark H Weaver @@ -2037,9 +2037,14 @@ paths." (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)) -- cgit v1.2.3