* [PATCH] list-packages: Display package usage count.
@ 2014-10-20 17:15 Eric Bavier
2014-10-25 21:47 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Eric Bavier @ 2014-10-20 17:15 UTC (permalink / raw
To: guix-devel
[-- 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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] list-packages: Display package usage count.
2014-10-20 17:15 [PATCH] list-packages: Display package usage count Eric Bavier
@ 2014-10-25 21:47 ` Ludovic Courtès
2014-10-26 18:23 ` Eric Bavier
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2014-10-25 21:47 UTC (permalink / raw
To: Eric Bavier; +Cc: guix-devel
Eric Bavier <ericbavier@gmail.com> 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 <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.
[...]
> + (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’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] list-packages: Display package usage count.
2014-10-25 21:47 ` Ludovic Courtès
@ 2014-10-26 18:23 ` Eric Bavier
2014-10-26 19:46 ` Mark H Weaver
0 siblings, 1 reply; 6+ messages in thread
From: Eric Bavier @ 2014-10-26 18:23 UTC (permalink / raw
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès writes:
> Eric Bavier <ericbavier@gmail.com> skribis:
>
>> + (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)?
Because that would not accurately count the "true" number of dependents.
It is constistent with the discussion and script I attached at
https://lists.gnu.org/archive/html/guix-devel/2014-10/msg00196.html
>> -(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.)
That's correct.
--
Eric Bavier
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] list-packages: Display package usage count.
2014-10-26 18:23 ` Eric Bavier
@ 2014-10-26 19:46 ` Mark H Weaver
2014-10-26 20:22 ` Eric Bavier
0 siblings, 1 reply; 6+ messages in thread
From: Mark H Weaver @ 2014-10-26 19:46 UTC (permalink / raw
To: Eric Bavier; +Cc: guix-devel
Eric Bavier <ericbavier@gmail.com> writes:
> Ludovic Courtès writes:
>
>> Eric Bavier <ericbavier@gmail.com> skribis:
>>
>>> + (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)?
>
> Because that would not accurately count the "true" number of dependents.
Agreed, but what you wrote doesn't fully address the problem either.
If we modify 'gnu-make', that's also going to affect 'gnu-make-boot0' in
commencement.scm. Since that one has a different name ("make-boot0"),
your logic won't catch it.
Similarly, if you modify 'gcc-4.7', that's also going to affect
'gcc-4.8' (different version) which affects 'gcc-boot0' (with a
different name and version).
So, it seems to me that we need a way to find all packages that
'inherit' from the package we're changing, transitively. I'm not sure
off-hand if that information is preserved, but if not, we should
probably arrange to preserve it somehow.
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] list-packages: Display package usage count.
2014-10-26 19:46 ` Mark H Weaver
@ 2014-10-26 20:22 ` Eric Bavier
2014-10-26 21:17 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Eric Bavier @ 2014-10-26 20:22 UTC (permalink / raw
To: Mark H Weaver; +Cc: guix-devel
Mark H Weaver writes:
> Eric Bavier <ericbavier@gmail.com> writes:
>
>> Ludovic Courtès writes:
>>
>>> Eric Bavier <ericbavier@gmail.com> skribis:
>>>
>>>> + (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)?
>>
>> Because that would not accurately count the "true" number of dependents.
>
> Agreed, but what you wrote doesn't fully address the problem either.
>
> If we modify 'gnu-make', that's also going to affect 'gnu-make-boot0' in
> commencement.scm. Since that one has a different name ("make-boot0"),
> your logic won't catch it.
>
> Similarly, if you modify 'gcc-4.7', that's also going to affect
> 'gcc-4.8' (different version) which affects 'gcc-boot0' (with a
> different name and version).
True. This is part of the reason the documentation for 'guix refresh
-l' notes the *approximate* accuracy of the reported dependents. The
yet-to-be-pushed rewrite with the bags api improves things, but doesn't
address these issues.
> So, it seems to me that we need a way to find all packages that
> 'inherit' from the package we're changing, transitively. I'm not sure
> off-hand if that information is preserved, but if not, we should
> probably arrange to preserve it somehow.
I was just thinking of this possibility earlier while working with 'guix
lint', regarding the patch-name warnings. Perhaps each package could
have an 'ancestor' field that is auto-populated when (inherit foo) is
used, and #f otherwise? That information could be included in the
DAG created by (package-dependencies).
--
Eric Bavier
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] list-packages: Display package usage count.
2014-10-26 20:22 ` Eric Bavier
@ 2014-10-26 21:17 ` Ludovic Courtès
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2014-10-26 21:17 UTC (permalink / raw
To: Eric Bavier; +Cc: guix-devel
Eric Bavier <ericbavier@gmail.com> skribis:
> Mark H Weaver writes:
>
>> Eric Bavier <ericbavier@gmail.com> writes:
>>
>>> Ludovic Courtès writes:
>>>
>>>> Eric Bavier <ericbavier@gmail.com> skribis:
>>>>
>>>>> + (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)?
>>>
>>> Because that would not accurately count the "true" number of dependents.
>>
>> Agreed, but what you wrote doesn't fully address the problem either.
>>
>> If we modify 'gnu-make', that's also going to affect 'gnu-make-boot0' in
>> commencement.scm. Since that one has a different name ("make-boot0"),
>> your logic won't catch it.
>>
>> Similarly, if you modify 'gcc-4.7', that's also going to affect
>> 'gcc-4.8' (different version) which affects 'gcc-boot0' (with a
>> different name and version).
>
> True. This is part of the reason the documentation for 'guix refresh
> -l' notes the *approximate* accuracy of the reported dependents. The
> yet-to-be-pushed rewrite with the bags api improves things, but doesn't
> address these issues.
In the examples Mark gave, the various packages use the same origin. I
think a good fix would be to somehow map <origin> objects to packages
that refer to them.
However, that seems mostly useful to ‘guix refresh -l’, and not really
for list-packages.scm. WDYT?
>> So, it seems to me that we need a way to find all packages that
>> 'inherit' from the package we're changing, transitively. I'm not sure
>> off-hand if that information is preserved, but if not, we should
>> probably arrange to preserve it somehow.
>
> I was just thinking of this possibility earlier while working with 'guix
> lint', regarding the patch-name warnings. Perhaps each package could
> have an 'ancestor' field that is auto-populated when (inherit foo) is
> used, and #f otherwise? That information could be included in the
> DAG created by (package-dependencies).
That’s an option, but I’d like to avoid going this far. Notably because
it might lead to a growth in heap usage as ancestors would remain
reachable, but also because I feel we may not be looking at things from
the right angle.
Conceptually, there’s an object DAG and we’re trying to enumerate the
those that depend on a given object. What you did works well for
package objects, but ignores edges in the DAG between a package and an
origin, or between a package and a file. Perhaps the fix would be to
account for those edges?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-26 21:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-20 17:15 [PATCH] list-packages: Display package usage count Eric Bavier
2014-10-25 21:47 ` 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
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.