guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] list-packages: Display package usage count.


From: Ludovic Courtès
Subject: Re: [PATCH] list-packages: Display package usage count.
Date: Sat, 25 Oct 2014 23:47:02 +0200
User-agent: Gnus/5.130011 (Ma Gnus v0.11) Emacs/24.3 (gnu/linux)

Eric Bavier <address@hidden> skribis:

> 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.

Nice.

> From 41a3599bcdc3888085379801e9a7f05430ffe0c3 Mon Sep 17 00:00:00 2001
> From: Eric Bavier <address@hidden>
> 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.

[...]

> +  (define (users package)
> +    (let ((n (length (package-transitive-dependents
> +                      (find-packages-by-name* (package-name package)
> +                                              (package-version package))))))

Why not just (package-transitive-dependents package)?

> +      (and (> n 0)
> +           `(div "used by " ,n " other " ,(if (= n 1) "package" 
> "packages")))))

Good.

> -(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*))

‘fold-packages*’ is the variant that also looks for private packages,
right? (It’s from one of the recent patches that hasn’t made it yet.)

But perhaps this is not needed, depending on the answer to the comment
above.  :-)

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]