From patchwork Mon Jan 31 22:36:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 36915 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 80B7927BBEA; Mon, 31 Jan 2022 22:37:55 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EEFD127BBE9 for ; Mon, 31 Jan 2022 22:37:54 +0000 (GMT) Received: from localhost ([::1]:33976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEfJ4-0005Wk-2a for patchwork@mira.cbaines.net; Mon, 31 Jan 2022 17:37:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEfIf-0005IS-Lb for guix-patches@gnu.org; Mon, 31 Jan 2022 17:37:29 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:48211) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEfIE-0000zd-2Q for guix-patches@gnu.org; Mon, 31 Jan 2022 17:37:29 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nEfID-0006Hl-R6 for guix-patches@gnu.org; Mon, 31 Jan 2022 17:37:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53672] [PATCH] guix system: 'describe' shows the running system, not the current one. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 31 Jan 2022 22:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53672 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53672@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164366859924123 (code B ref -1); Mon, 31 Jan 2022 22:37:01 +0000 Received: (at submit) by debbugs.gnu.org; 31 Jan 2022 22:36:39 +0000 Received: from localhost ([127.0.0.1]:41114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nEfHr-0006H0-1S for submit@debbugs.gnu.org; Mon, 31 Jan 2022 17:36:39 -0500 Received: from lists.gnu.org ([209.51.188.17]:35152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nEfHo-0006Gs-J4 for submit@debbugs.gnu.org; Mon, 31 Jan 2022 17:36:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEfHm-0004qI-Km for guix-patches@gnu.org; Mon, 31 Jan 2022 17:36:36 -0500 Received: from [2001:470:142:3::e] (port=57486 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEfHd-0000rc-Po; Mon, 31 Jan 2022 17:36:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=RzwyxDWMQSLnaEcrnzDVqMY7duzs4kx7hkZK6iHRzvU=; b=GVvxt8APk4lKZf sgi/xZCQlCspl92NO87usfIGF0bnL0M61JV77sa3pnS2CpbWmVSSGhJ3cpXl73sTdh3I6Zwndk2ML Bc52c1F02182SW2d1dJrLmfNrMpWGlbKERycQy7mVNHdKv4cROxjrLB28P/qy1Zsg5RUR217LpGgN UyFQorgE+d0b/jdoLXqhdRTjERnfU2OZLDhP1AaD092b+ql4wyzIA+D+Sm2wJJ/GPLkB2Tv3TBsXO MGesjTb8Qal/+RjaBnyQDVUtz5FeD0vbyMMJCBk1xCWYhsMTLO7lcCngZFAN9hvlrWYO+zMFwUuvf ErhcS3RBTl9mfwt+1iRg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:56714 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEfHc-0001oZ-IM; Mon, 31 Jan 2022 17:36:25 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 31 Jan 2022 23:36:18 +0100 Message-Id: <20220131223618.30022-1-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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’. base-commit: 27c1d58d901dcf48929bcb6f76d861fc21575dbf 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 +;;; Copyright © 2013-2022 Ludovic Courtès ;;; Copyright © 2013 Nikita Karetnikov ;;; Copyright © 2014, 2016 Alex Kost ;;; Copyright © 2015 Mark H Weaver @@ -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 +;;; Copyright © 2014-2022 Ludovic Courtès ;;; Copyright © 2016 Alex Kost ;;; Copyright © 2016, 2017, 2018 Chris Marusich ;;; Copyright © 2017, 2019 Mathieu Othacehe @@ -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