From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KBrqN8Rk+GEwLgAAgWs5BA (envelope-from ) for ; Mon, 31 Jan 2022 23:37:56 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id OCVUNcRk+GGTagAA9RJhRA (envelope-from ) for ; Mon, 31 Jan 2022 23:37:56 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3D0D1F6BB for ; Mon, 31 Jan 2022 23:37:56 +0100 (CET) Received: from localhost ([::1]:33976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEfJ4-0005Wk-TW for larch@yhetil.org; 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643668676; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=RzwyxDWMQSLnaEcrnzDVqMY7duzs4kx7hkZK6iHRzvU=; b=JkMVYq7q1rafQunK6b7HcyslYFxzIKkP+HxNKgW/c0ZkFBBtwD9y2nmVeUCKtlPJ9oUbLG R0597wmDpIiH0cBO0t6RUSlOh3strkL+lRPpWvGuJ6s6tt7tVt+spPwnYflyjyjX81uMUy /Jer+/7b+NwzQIm3GJ9EpdbnOLpIRWw85iNh2adNzr5uEXPamG/8JLodqascwu+jGcwUQq P4c+lbjc9EsUAQQ/teisoOwFtiBBnSKwmafSgNoHeHA5rrK05IbQMuTakSmnjIlFSE48lD wj14Dxf28uXpBOh6cliYofjjER1LSa3+bBToxzqAxG7/Yg2nGcDMnm12UIY++g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643668676; a=rsa-sha256; cv=none; b=XLzCng8HPETZWKH1c431fLAxlfQv4yT4wLEpzKUOFuao0S/qYcSBdYfJkWv+YUbEZymHbd OrqlwJAn2ZFU/VvryxvpkXhRbJ1YX5+pX/Fpj2SqIdHxEgKrxbNnBnEWfVXvgNyE/06iP5 mJvEkfWUAXQ4nATRhWvCCFBqgWhqes2GQYPK41XsA5P/CHCDJ/FvdTb0MB1LivkRicv8en 4kdliyHqbIbCDvQC81m22LTqp9P/8F0VYuRn+A3EISjcpDR43IQo4mgG/SJFMKJjrYIm1W 4sCA0qL8tMSJBoRKYmo9076UXh+LFpt11KVWoP0+U0FBfWMcUtObErpmmoWhSQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=GVvxt8AP; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=GVvxt8AP; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 3D0D1F6BB X-Spam-Score: -3.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: 8QujSN9DCZqz * 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 +;;; 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 base-commit: 27c1d58d901dcf48929bcb6f76d861fc21575dbf -- 2.34.0