From patchwork Thu Oct 27 21:28:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\\(" X-Patchwork-Id: 44161 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 68A2A27BBEB; Thu, 27 Oct 2022 22:31:40 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 7043727BBEA for ; Thu, 27 Oct 2022 22:31:39 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooAS0-0007fP-Ke; Thu, 27 Oct 2022 17:30:08 -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 1ooARv-0007Xv-16 for guix-patches@gnu.org; Thu, 27 Oct 2022 17:30:03 -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 1ooARu-0005ZT-Q1 for guix-patches@gnu.org; Thu, 27 Oct 2022 17:30:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ooARu-0003WO-JK for guix-patches@gnu.org; Thu, 27 Oct 2022 17:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58824] [PATCH 1/1] 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: Thu, 27 Oct 2022 21:30:02 +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.166690615413457 (code B ref 58824); Thu, 27 Oct 2022 21:30:02 +0000 Received: (at 58824) by debbugs.gnu.org; 27 Oct 2022 21:29:14 +0000 Received: from localhost ([127.0.0.1]:59497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooAR7-0003Uy-Pa for submit@debbugs.gnu.org; Thu, 27 Oct 2022 17:29:14 -0400 Received: from knopi.disroot.org ([178.21.23.139]:60662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooAR6-0003Ur-2D for 58824@debbugs.gnu.org; Thu, 27 Oct 2022 17:29:12 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6D13D4E7B1; Thu, 27 Oct 2022 23:29: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 qON8V6_lMvPF; Thu, 27 Oct 2022 23:29:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1666906145; bh=RX4bJxeslxrvpwh4rVf9sS/QmUq5D2w8gzHxa/921nA=; h=From:To:Cc:Subject:Date; b=dKEtZfo4caUWcnud+ldh1xvZNQPkORCbGaJGgZ/qpXlbi7mwN7UJVo6jH7+RcHZYD HM21psLJG1ovVxxiOwJgQIcWBIbB6k+xSR16rRVaC8ROR02YLhuSgG8JO3iqeokEU0 V8q+He+SApV6GxH2d/nJJkyoLBGOzPmKYALSwtPiFOxzmqWRRXuIum50uUCKokZlRP m+JRBIs8QNGEqNRgRaUutjUq0RxBRmG3gnpXHyfnHRv3ukYOic2+6G+QqkPsWn4Lm9 Tm+aIbtaMWYn4vZ0H4ZWRkwfOoTHGMGQuXZJdUsR6Zt/oqafhhy+mroYm1WPcR7S/f I8P2f4J5YudMg== Date: Thu, 27 Oct 2022 22:28:59 +0100 Message-Id: <20221027212859.21755-1-paren@disroot.org> 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: , Sender: "Guix-patches" Reply-to: "\(" X-ACL-Warn: , "\( via Guix-patches" X-Patchwork-Original-From: "\( via Guix-patches" via From: "\\(" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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. --- guix/scripts/refresh.scm | 61 ++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 14329751f8..9040f4d83d 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -93,9 +93,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 +420,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 +436,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 +537,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 +554,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?