From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Bavier Subject: [PATCH] list-packages: Display package usage count. Date: Mon, 20 Oct 2014 12:15:33 -0500 Message-ID: <87wq7uu0ga.fsf@member.fsf.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgGWB-00022X-Kc for guix-devel@gnu.org; Mon, 20 Oct 2014 13:13:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgGW5-0005vM-0f for guix-devel@gnu.org; Mon, 20 Oct 2014 13:13:15 -0400 Received: from mail-ig0-x229.google.com ([2607:f8b0:4001:c05::229]:57634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgGW4-0005vH-DZ for guix-devel@gnu.org; Mon, 20 Oct 2014 13:13:08 -0400 Received: by mail-ig0-f169.google.com with SMTP id uq10so6769326igb.0 for ; Mon, 20 Oct 2014 10:13:06 -0700 (PDT) Received: from cooper.gmail.com (chippewa-nat.cray.com. [136.162.34.1]) by mx.google.com with ESMTPSA id qo2sm4060448igb.21.2014.10.20.10.13.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 20 Oct 2014 10:13:04 -0700 (PDT) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= This patch adds a simple message like "used by X other packages" to each packages description on https://www.gnu.org/software/guix/package-list.html. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-list-packages-Display-package-usage-count.patch >From 41a3599bcdc3888085379801e9a7f05430ffe0c3 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Mon, 20 Oct 2014 12:12:28 -0500 Subject: [PATCH] list-packages: Display package usage count. * gnu/packages.scm (find-packages, find-package-by-name*): New procedures. * build-aux/list-packages.scm (package->sxml)[users]: New local procedure. --- build-aux/list-packages.scm | 8 ++++++++ gnu/packages.scm | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build-aux/list-packages.scm b/build-aux/list-packages.scm index 7b046fe..276c153 100755 --- a/build-aux/list-packages.scm +++ b/build-aux/list-packages.scm @@ -166,6 +166,13 @@ decreasing, is 1." ,(url "i686-linux") " " ,(url "mips64el-linux"))) + (define (users package) + (let ((n (length (package-transitive-dependents + (find-packages-by-name* (package-name package) + (package-version package)))))) + (and (> n 0) + `(div "used by " ,n " other " ,(if (= n 1) "package" "packages"))))) + (define (package-logo name) (and=> (lookup-gnu-package name) gnu-package-logo)) @@ -206,6 +213,7 @@ description-ids as formal parameters." ,(package-home-page package)) ,(status package) ,(patches package) + ,(users package) ,(if js? (insert-js-call description-ids) "")))))) diff --git a/gnu/packages.scm b/gnu/packages.scm index d3a064c..2ec160a 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -41,6 +41,7 @@ fold-packages* find-packages-by-name + find-packages-by-name* find-best-packages-by-name find-newest-available-packages @@ -192,11 +193,11 @@ guaranteed to never traverse the same package twice." (filter package? inputs)))) (fold-packages cons '()))) -(define find-packages-by-name +(define (find-packages fold) (let ((packages (delay - (fold-packages (lambda (p r) - (vhash-cons (package-name p) p r)) - vlist-null)))) + (fold (lambda (p r) + (vhash-cons (package-name p) p r)) + vlist-null)))) (lambda* (name #:optional version) "Return the list of packages with the given NAME. If VERSION is not #f, then only return packages whose version is equal to VERSION." @@ -207,6 +208,9 @@ then only return packages whose version is equal to VERSION." matching) matching))))) +(define find-packages-by-name (find-packages fold-packages)) +(define find-packages-by-name* (find-packages fold-packages*)) + (define find-newest-available-packages (memoize (lambda () -- 1.7.9.5 --=-=-= -- Eric Bavier --=-=-=--