From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8CsqD5LezmJSYgAAbAwnHQ (envelope-from ) for ; Wed, 13 Jul 2022 17:02:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 2D7pDpLezmLrQgEAauVa8A (envelope-from ) for ; Wed, 13 Jul 2022 17:02:42 +0200 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 AEB89209F9 for ; Wed, 13 Jul 2022 17:02:41 +0200 (CEST) Received: from localhost ([::1]:57250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBdsu-0007hp-I2 for larch@yhetil.org; Wed, 13 Jul 2022 11:02:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBdsJ-00075f-3F for guix-patches@gnu.org; Wed, 13 Jul 2022 11:02:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oBdsI-0005ou-P7 for guix-patches@gnu.org; Wed, 13 Jul 2022 11:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oBdsI-0002My-NA for guix-patches@gnu.org; Wed, 13 Jul 2022 11:02:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56541] [PATCH] system: Add -I, --list-installed option. Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 13 Jul 2022 15:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56541 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56541@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16577245149089 (code B ref -1); Wed, 13 Jul 2022 15:02:02 +0000 Received: (at submit) by debbugs.gnu.org; 13 Jul 2022 15:01:54 +0000 Received: from localhost ([127.0.0.1]:47507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oBds9-0002MW-Gw for submit@debbugs.gnu.org; Wed, 13 Jul 2022 11:01:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:43562) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oBds7-0002MO-94 for submit@debbugs.gnu.org; Wed, 13 Jul 2022 11:01:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBds5-00070H-AV for guix-patches@gnu.org; Wed, 13 Jul 2022 11:01:50 -0400 Received: from mout-p-101.mailbox.org ([2001:67c:2050:0:465::101]:41122) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1oBds1-0005lf-FN for guix-patches@gnu.org; Wed, 13 Jul 2022 11:01:48 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4Ljgn55XDzz9sRk for ; Wed, 13 Jul 2022 17:01:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1657724489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TojUPY3RDO+OzLt3rU0BFc3aHXnn92oA4Q7DfPmBifY=; b=lL4ui1faS8IBf25Dv/60v3du7FCI3a0vrUtmOdg1mBqjilwexxuoqT+JIa10kTeUOdpi53 GXpdP8yrpen2jmiEo94V/NKeMHuARvuGRwTltwNaqDCTuIZoUMg7GwZA+GOe3fIBr6GPjd yD5cdXn+m5LgyCdDunAxt5GJy53CLf1bsWuIuEPVyPuWyHtcrj5V+BYtHWP7JzxEc564dq NpmlPxQudaWMRvxTc7PVFPE/ve9uPK6JKvhM23wMONuUU0ZKlYUE11lEekQEgD9rsXKbQ4 x6+8WPP3LUDyGSz3LG+LtF5lBxDE/c7ODP5s+pqRGysb0CP7nVps9q1LP0iQRg== Date: Wed, 13 Jul 2022 15:01:22 +0000 Message-Id: <20220713150123.5395-1-antero@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MBO-RS-ID: 146af736058ac1e1ce2 X-MBO-RS-META: 7i9f6pt4x4xewp14qbq9gdifodmdo959 X-Rspamd-Queue-Id: 4Ljgn55XDzz9sRk Received-SPF: pass client-ip=2001:67c:2050:0:465::101; envelope-from=antero@mailbox.org; helo=mout-p-101.mailbox.org X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Reply-to: Antero Mejr X-ACL-Warn: , Antero Mejr via Guix-patches From: Antero Mejr via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1657724561; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=TojUPY3RDO+OzLt3rU0BFc3aHXnn92oA4Q7DfPmBifY=; b=AJZKhs6z+FEH3MMkpaJ1BR8Z7eDsnxYX7+JGmq/zrc0RvApQtiR/AKzCXSvRI5HjhnGe5R kXpzmadLumRmEFeEKJOld9p/BnSRWCs5Sa7VHLBocMjdG5aKwzBoFWPkQQdGp55Jibfc/c sLUvWeKQrmDma5fcZw9U/wsdwPdmMYHY/VY5pqxoM3MLmFxEX2U4u93b90Y3MlaLGdNcfF bjY2c5QujF3An29VmjbSpVCa/oOmYK9JGJDBo0vGZqGklMYx+Zzrew7zpbuGoglTb+HK1S WQyT3m5cjhNYVDnOj2+81ea50NlMftcL8ahe+3pVIiuwtKDPSX0X4LbafEW8aw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657724561; a=rsa-sha256; cv=none; b=NlUy189oZlyGVknudot0NxzerXdXdz9hO1hZ+Zv+zcbENDq0OE4Yt6tio0S7YmDloiKzX8 8oMO0pZEqztBjcp1SzvsERHG4aMP4alkJUYDzbdkHfusmwiae0v/8j8JrYQSexVYhsLqY9 kv8aQvl7beqraN+uZ6tYENg1mUAw1WctgCgKmOLJr+ViPDOTdUiABn+8Y2XJOBEsyNlf/j KHN39LUJ/8IzTPyNEjPaGooq4BGaPNc8OxrloLPXeP4BT1kWkp23Wg9Lh+LNtG2z+UB1Dg zgXEsn4MClGgdm8xtVtJcWTLYipE4YkfdFNCuBEsPGO9NWG5CTLcEG+TbJL3Rg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mailbox.org header.s=mail20150812 header.b=lL4ui1fa; 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: -4.24 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mailbox.org header.s=mail20150812 header.b=lL4ui1fa; 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: AEB89209F9 X-Spam-Score: -4.24 X-Migadu-Scanner: scn0.migadu.com X-TUID: XJL8F6Ia0xDl * guix/scripts/system.scm: New flag -I, --list-installed. * doc/guix.texi (Invoking Guix System): Add information for --list-installed flag. --- Depends on patch 56238: https://issues.guix.gnu.org/56428 doc/guix.texi | 12 ++++++++ guix/scripts/system.scm | 61 +++++++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index fc3a2d962d..3f3b480f4e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -37647,6 +37647,13 @@ bootloader boot menu: Describe the running system generation: its file name, the kernel and bootloader used, etc., as well as provenance information when available. +The @code{--list-installed} flag is available, with the same +syntax that is used in @command{guix package --list-installed} +(@pxref{Invoking guix package}). When the flag is used, +the description will include a list of packages that are currently +installed in the system profile, with optional filtering based on a +regular expression. + @quotation Note The @emph{running} system generation---referred to by @file{/run/current-system}---is not necessarily the @emph{current} @@ -37674,6 +37681,11 @@ generations that are up to 10 days old: $ guix system list-generations 10d @end example +The @code{--list-installed} flag may also be specified, with the same +syntax that is used in @command{guix package --list-installed}. This +may be helpful if trying to determine when a package was added to the +system. + @end table The @command{guix system} command has even more to offer! The following diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index b9084a401c..91a0a5302b 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -50,7 +50,8 @@ (define-module (guix scripts system) #:use-module (guix channels) #:use-module (guix scripts build) #:autoload (guix scripts package) (delete-generations - delete-matching-generations) + delete-matching-generations + list-installed) #:autoload (guix scripts pull) (channel-commit-hyperlink) #:autoload (guix graph) (export-graph node-type graph-backend-name lookup-backend) @@ -480,7 +481,8 @@ (define (shepherd-service-node-type services) ;;; (define* (display-system-generation number - #:optional (profile %system-profile)) + #:optional (profile %system-profile) + #:key (list-installed-regex #f)) "Display a summary of system generation NUMBER in a human-readable format." (define (display-channel channel) (format #t " ~a:~%" (channel-name channel)) @@ -544,23 +546,34 @@ (define-values (channels config-file) (format #t (G_ " configuration file: ~a~%") (if (supports-hyperlinks?) (file-hyperlink config-file) - config-file)))))) - -(define* (list-generations pattern #:optional (profile %system-profile)) + config-file))) + (when list-installed-regex + (format #t (G_ " packages:\n")) + (pretty-print-table (list-installed + list-installed-regex + (list (string-append generation "/profile"))) + #:left-pad 4))))) + +(define* (list-generations pattern #:optional (profile %system-profile) + #:key (list-installed-regex #f)) "Display in a human-readable format all the system generations matching PATTERN, a string. When PATTERN is #f, display all the system generations." (cond ((not (file-exists? profile)) ; XXX: race condition (raise (condition (&profile-not-found-error (profile profile))))) ((not pattern) - (for-each display-system-generation (profile-generations profile))) + (for-each (cut display-system-generation <> + #:list-installed-regex list-installed-regex) + (profile-generations profile))) ((matching-generations pattern profile) => (lambda (numbers) (if (null-list? numbers) (exit 1) (leave-on-EPIPE - (for-each display-system-generation numbers))))))) + (for-each (cut display-system-generation <> + #:list-installed-regex list-installed-regex) + numbers))))))) ;;; @@ -1032,6 +1045,11 @@ (define (show-help) use BACKEND for 'extension-graphs' and 'shepherd-graph'")) (newline) (display (G_ " + -I, --list-installed[=REGEXP] + for 'describe' and 'list-generations', list installed + packages matching REGEXP")) + (newline) + (display (G_ " -h, --help display this help and exit")) (display (G_ " -V, --version display version information and exit")) @@ -1135,6 +1153,9 @@ (define %options (option '("graph-backend") #t #f (lambda (opt name arg result) (alist-cons 'graph-backend arg result))) + (option '(#\I "list-installed") #f #t + (lambda (opt name arg result) + (alist-cons 'list-installed (or arg "") result))) %standard-build-options)) (define %default-options @@ -1322,25 +1343,29 @@ (define-syntax-rule (with-store* store exp ...) ;; The following commands do not need to use the store, and they do not need ;; an operating system configuration file. ((list-generations) - (let ((pattern (match args + (let ((list-installed-regex (assoc-ref opts 'list-installed)) + (pattern (match args (() #f) ((pattern) pattern) (x (leave (G_ "wrong number of arguments~%")))))) - (list-generations pattern))) + (list-generations pattern #:list-installed-regex list-installed-regex))) ((describe) ;; Describe the running system, which is not necessarily the current ;; generation. /run/current-system might point to ;; /var/guix/profiles/system-N-link, or it might point directly to ;; /gnu/store/…-system. Try both. - (match (generation-number "/run/current-system" %system-profile) - (0 - (match (generation-number %system-profile) - (0 - (leave (G_ "no system generation, nothing to describe~%"))) - (generation - (display-system-generation generation)))) - (generation - (display-system-generation generation)))) + (let ((list-installed-regex (assoc-ref opts 'list-installed))) + (match (generation-number "/run/current-system" %system-profile) + (0 + (match (generation-number %system-profile) + (0 + (leave (G_ "no system generation, nothing to describe~%"))) + (generation + (display-system-generation + generation #:list-installed-regex list-installed-regex)))) + (generation + (display-system-generation + generation #:list-installed-regex list-installed-regex))))) ((search) (apply (resolve-subcommand "search") args)) ((edit) -- 2.36.1