From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0H3kMfn3W2NiXwAAbAwnHQ (envelope-from ) for ; Fri, 28 Oct 2022 17:40:41 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id eMqpMfn3W2PMAgEAauVa8A (envelope-from ) for ; Fri, 28 Oct 2022 17:40:41 +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 872251755D for ; Fri, 28 Oct 2022 17:40:41 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooRSu-00012T-JM; Fri, 28 Oct 2022 11:40:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooRSk-0000yx-EH for guix-patches@gnu.org; Fri, 28 Oct 2022 11:40:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ooRSk-0002Uc-5u for guix-patches@gnu.org; Fri, 28 Oct 2022 11:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ooRSj-0004oq-Nx for guix-patches@gnu.org; Fri, 28 Oct 2022 11:40:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58824] [PATCH v2] scripts: refresh: Support --list-dependent=packages. References: <20221027212706.21680-1-paren@disroot.org> In-Reply-To: <20221027212706.21680-1-paren@disroot.org> Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Oct 2022 15:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58824 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58824@debbugs.gnu.org Cc: "\(" Received: via spool by 58824-submit@debbugs.gnu.org id=B58824.166697155818456 (code B ref 58824); Fri, 28 Oct 2022 15:40:01 +0000 Received: (at 58824) by debbugs.gnu.org; 28 Oct 2022 15:39:18 +0000 Received: from localhost ([127.0.0.1]:34091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooRS2-0004nb-95 for submit@debbugs.gnu.org; Fri, 28 Oct 2022 11:39:18 -0400 Received: from knopi.disroot.org ([178.21.23.139]:58764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooRRw-0004nO-EJ for 58824@debbugs.gnu.org; Fri, 28 Oct 2022 11:39:16 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 241EB4E8C6; Fri, 28 Oct 2022 17:39:11 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id 8NYV6MnO6e0M; Fri, 28 Oct 2022 17:39:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1666971060; bh=d/tiJysaQdblEUHSRSLo/r74txMVz6eJ2G0T4LzqtvQ=; h=From:To:Cc:Subject:Date; b=bk1Ap8dqllH+3r2vHgjpTavBKM86PkdmsIBSHSYLGxaw32NkLiOLP9kJunneqBjWZ HJB0FXeXZ/VjmZeQs1PnEF5oEyJBvACSIXMqx04MbZ/JtKSA2Z7dA5iZNxj9feeFo4 9hYRmrCyB5wDd+csFK2lSEYiao9/2yC+yGUsrvj4z4UGQrcwpcm0torIL6MB/fTX+0 uF0yaI3kW+sS6Ofka5/iq6GRw0dDby+3IM4NzimcYBNyPvYDOOJ4lFZIyRk/2JSXBm GLKTt7K15wy7nTriAMoErWiyj4ebuNe+S/GG1uqfKrHtaOlgRmdfuJxcyd5WyEp87z gl0EkPb3YJQuw== Date: Fri, 28 Oct 2022 16:30:52 +0100 Message-Id: <20221028153052.3051-1-paren@disroot.org> 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: , Sender: "Guix-patches" Reply-to: "\(" X-ACL-Warn: , "\( via Guix-patches" From: "\( via Guix-patches" via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org 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=1666971641; h=from:from:sender:sender:reply-to: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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=6Jxk107KOWadeqsoTYhgZNcx9kaZ5G4uPydeH2up8f4=; b=hqYH/BnEgqewQwj6QVbzOtcbpx8a/UMZw7r6/027kxdgneR2zwMDlYctS8/zPOqiBo/kP6 q8SFCg7pStLjEyxES28eaJT0FsxtcHCDhcB23lhy/uV/qMdJsUS90M/Mz7giPc0Q0gp+EK NBd0VJBSRPSueAo8Go273y8tCg7wmyOPd28IkbBe8n5bXoZEfJhprFqpBG4cyJX9EEpYhn OCCIn/uteGb4etHjYlmhDduZXnzD85YiHsGVTu7gLRkYjLbOcMI/CbC1rZwWfmskTDCWp9 +4dfTBK5Sm+yBH/ZL9v9bmoh03oLt5cPxEhWo5S3SyF+5XfbSJZyzag0awICBQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666971641; a=rsa-sha256; cv=none; b=kSo9aQJiuGpV+8xxL/V/W6SwH+g38AP/0E7ZHFPUFbkr3FEsfncNRqdKLAv5aOyEE9MLbp D9UbtJ3wOggRGXUSHIl0xvqloF2ICOJtxRWlJZXPlwgk42EzkewafPybqZIuCinVXLOTwC PU6wJuPRUpl932d4zSGYViMi+Q3izxfUwIluGJ+1KjWST+dshe+peNaPWmu455XjiWJiLv y8sesf63j0e3AJFsLfBjZ+3GsfT/g2VZJgD9KUs3W63ACvfZJ0VPMzQAh7x6hLcntjouna k15OHvHk32+E7flBnQU/rUgh4+WPvXJOKUdyZCAwuepjxnx5XCcA00BwaJBY/w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=bk1Ap8dq; 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: -2.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=bk1Ap8dq; 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: 872251755D X-Spam-Score: -2.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: pgOSDfTwBTas * guix/scripts/refresh.scm (%options)[list-dependent]: Allow an optional argument. Set 'LIST-DEPENDENT-MACHINE-READABLE? to #T in RESULT if the argument is "packages". (list-dependents): Support #:MACHINE-READABLE?. (guix-refresh): Pass #:MACHINE-READABLE? #T to LIST-DEPENDENTS if 'LIST-DEPENDENT-MACHINE-READABLE? is #T. * doc/guix.texi: Document 'guix refresh --list-dependent=packages'. --- doc/guix.texi | 13 +++++++-- guix/scripts/refresh.scm | 62 ++++++++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3bfb89bc33..9800307888 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14095,11 +14095,20 @@ be used when passing @command{guix refresh} one or more package names: @table @code -@item --list-dependent -@itemx -l +@item --list-dependent[=packages] +@itemx -l [packages] List top-level dependent packages that would need to be rebuilt as a result of upgrading one or more packages. +If the option is called with the optional @code{packages} argument, it +will display only the list of packages, without the header stating the +number of packages that will be rebuilt. This can be used to run +commands such as this, which builds all the dependents of @code{gtk}: + +@example +$ guix build $(guix refresh gtk -l packages) +@end example + @xref{Invoking guix graph, the @code{reverse-package} type of @command{guix graph}}, for information on how to visualize the list of dependents of a package. diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 14329751f8..7c3f392a96 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2019 Ricardo Wurmus ;;; Copyright © 2020 Simon Tournier ;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2022 ( ;;; ;;; This file is part of GNU Guix. ;;; @@ -93,9 +94,12 @@ (define %options (option '(#\e "expression") #t #f (lambda (opt name arg result) (alist-cons 'expression arg result))) - (option '(#\l "list-dependent") #f #f + (option '(#\l "list-dependent") #f #t (lambda (opt name arg result) - (alist-cons 'list-dependent? #t result))) + (append `((list-dependent? . #t) + (list-dependent-machine-readable? + . ,(and arg (string=? arg "packages")))) + result))) (option '(#\r "recursive") #f #f (lambda (opt name arg result) (alist-cons 'recursive? #t result))) @@ -417,8 +421,10 @@ (define (all-packages) '() #:select? (const #t))) ;include hidden packages -(define (list-dependents packages) - "List all the things that would need to be rebuilt if PACKAGES are changed." +(define* (list-dependents packages #:key (machine-readable? #f)) + "List all the things that would need to be rebuilt if PACKAGES are +changed. If MACHINE-READABLE? is #T, display only a list of packages, +with no human-friendly extra text." ;; Using %BAG-NODE-TYPE is more accurate than using %PACKAGE-NODE-TYPE ;; because it includes implicit dependencies. (define (full-name package) @@ -431,27 +437,31 @@ (define (full-name package) (covering (filter (lambda (node) (null? (edges node))) dependents))) - (match dependents - (() - (format (current-output-port) - (N_ "No dependents other than itself: ~{~a~}~%" - "No dependents other than themselves: ~{~a~^ ~}~%" - (length packages)) - (map full-name packages))) - - ((x) - (format (current-output-port) - (G_ "A single dependent package: ~a~%") - (full-name x))) - (lst - (format (current-output-port) - (N_ "Building the following ~d package would ensure ~d \ + (if machine-readable? + (format (current-output-port) + (G_ "~{~a~^ ~}~%") + (map full-name covering)) + (match dependents + (() + (format (current-output-port) + (N_ "No dependents other than itself: ~{~a~}~%" + "No dependents other than themselves: ~{~a~^ ~}~%" + (length packages)) + (map full-name packages))) + ((x) + (format (current-output-port) + (G_ "A single dependent package: ~a~%") + (full-name x))) + (lst + (format (current-output-port) + (N_ "Building the following ~d package would ensure ~d \ dependent packages are rebuilt: ~{~a~^ ~}~%" - "Building the following ~d packages would ensure ~d \ + "Building the following ~d packages would ensure ~d \ dependent packages are rebuilt: ~{~a~^ ~}~%" - (length covering)) - (length covering) (length dependents) - (map full-name covering)))) + (length covering)) + (length covering) (length dependents) + (map full-name covering))))) + (return #t)))) (define (list-transitive packages) @@ -528,6 +538,8 @@ (define (options->updaters opts) (updaters (options->updaters opts)) (recursive? (assoc-ref opts 'recursive?)) (list-dependent? (assoc-ref opts 'list-dependent?)) + (list-dependent-machine-readable? + (assoc-ref opts 'list-dependent-machine-readable?)) (list-transitive? (assoc-ref opts 'list-transitive?)) (key-download (assoc-ref opts 'key-download)) @@ -543,7 +555,9 @@ (define (options->updaters opts) (mlet %store-monad ((packages (options->packages opts))) (cond (list-dependent? - (list-dependents packages)) + (list-dependents packages + #:machine-readable? + list-dependent-machine-readable?)) (list-transitive? (list-transitive packages)) (update? base-commit: f928abac369f699f425ddee925d0d0c2dc0a635d -- 2.38.0