From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 4A+bKbv4WmNXGgAAbAwnHQ (envelope-from ) for ; Thu, 27 Oct 2022 23:31:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MMn2KLv4WmOhxwAAG6o9tA (envelope-from ) for ; Thu, 27 Oct 2022 23:31:39 +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 5623521C65 for ; Thu, 27 Oct 2022 23:31:39 +0200 (CEST) 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 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=1666906299; 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-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=Bmd93Ru2mGEx7FbatHk4tX8ljJx2iPqIJd/2MYO0abw=; b=JvmkS+8XZwvHjx4aCo+ADe6KADNvnr+zs24xhWx1mPUXDxWW4+DUv7URRLU2AkvFBIOn7j 8b3bd7hmsBWaGaqqy4mtkdDvmEg2/xOJgJZ6oqexEDZvyUipJvz3lDEDVxRMgM76OBhVsA QqGfcplKpr3THXB2t0U/7VpIJmxGVcjp4dvGBeHd9Ge8y5PmJHKS6L77mPb6+/idffJPuW eciy8LNFsEMwSH+AzlFmHYePUWZkBQitgtM3q7MeJ2aKGvVilczEXR8ZVtUR6NFTYfsbnt QFspPX7gJSOOvFkIHGDIoVWQcs3pKspecfpQ0Z/uwohB+huGg4TzMOlqRfTmUw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666906299; a=rsa-sha256; cv=none; b=FeeraSC8WLWDUwEPgjmMsOXGjpxLLCA80ypYRVBW8i4cqZmkGhpzOzgcmml0j3GvAv/cFh wLqRNRONr3PVvBlq0fpn2vnAeTVGiDDW6a6si58NbXvJXBAXjktq8svPClEx7+c4BPVKfV ST59TmyTaKBRL5CSX8LmN19RQnTl3xkIJohr0GQT6Tk+8yyY/EGh7zvR0UC7DyQzdZrBhw HF68TEle/sD5dNl8HXT+1JCxmKQvFXJ0PbLm3aSfkeKSIjBZqzeivANMx5I0PyG2hqEFpu MEeDtdHolPFWupYvj7Bik0+uT08MWsLsG9FsUT+CKR/SjF+kmJkZu8IS+3JrvA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=dKEtZfo4; 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: -1.71 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=dKEtZfo4; 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: 5623521C65 X-Spam-Score: -1.71 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2/DiTEbMQzRn * 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? -- 2.38.0