all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Bavier <ericbavier@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH] list-packages: Display package usage count.
Date: Mon, 20 Oct 2014 12:15:33 -0500	[thread overview]
Message-ID: <87wq7uu0ga.fsf@member.fsf.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-list-packages-Display-package-usage-count.patch --]
[-- Type: text/x-diff, Size: 3003 bytes --]

From 41a3599bcdc3888085379801e9a7f05430ffe0c3 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bavier@member.fsf.org>
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


[-- Attachment #3: Type: text/plain, Size: 17 bytes --]


-- 
Eric Bavier

             reply	other threads:[~2014-10-20 17:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 17:15 Eric Bavier [this message]
2014-10-25 21:47 ` [PATCH] list-packages: Display package usage count Ludovic Courtès
2014-10-26 18:23   ` Eric Bavier
2014-10-26 19:46     ` Mark H Weaver
2014-10-26 20:22       ` Eric Bavier
2014-10-26 21:17         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wq7uu0ga.fsf@member.fsf.org \
    --to=ericbavier@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.