* [PATCH] guix package: add a "show" option.
@ 2014-07-13 18:54 Cyril Roelandt
2014-07-13 21:32 ` Ludovic Courtès
2014-07-15 21:23 ` Ludovic Courtès
0 siblings, 2 replies; 14+ messages in thread
From: Cyril Roelandt @ 2014-07-13 18:54 UTC (permalink / raw)
To: guix-devel
* guix/packages.scm (package-direct-inputs): New procedure.
* guix/scripts/package.scm: Add a "show" option.
* tests/guix-package.sh: Add a test for the "show" option.
---
guix/packages.scm | 8 ++++++++
guix/scripts/package.scm | 37 +++++++++++++++++++++++++++++++++++++
tests/guix-package.sh | 3 +++
3 files changed, 48 insertions(+)
diff --git a/guix/packages.scm b/guix/packages.scm
index 985a573..4fda77f 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -75,6 +75,7 @@
package-location
package-field-location
+ package-direct-inputs
package-transitive-inputs
package-transitive-target-inputs
package-transitive-native-inputs
@@ -467,6 +468,13 @@ IMPORTED-MODULES specify modules to use/import for use by SNIPPET."
((? string? file)
(add-to-store store (basename file) #t "sha256" file))))
+(define (package-direct-inputs package)
+ (sort (append (package-inputs package)
+ (package-native-inputs package)
+ (package-propagated-inputs package))
+ (lambda (p1 p2)
+ (string<? (car p1) (car p2)))))
+
(define (transitive-inputs inputs)
(let loop ((inputs inputs)
(result '()))
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 1c3209f..2b5efc9 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -22,6 +22,7 @@
#:use-module (guix ui)
#:use-module (guix store)
#:use-module (guix derivations)
+ #:use-module (guix licenses)
#:use-module (guix packages)
#:use-module (guix profiles)
#:use-module (guix utils)
@@ -517,6 +518,8 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
(display (_ "
-A, --list-available[=REGEXP]
list available packages matching REGEXP"))
+ (display (_ "
+ --show=PACKAGE show details about PACKAGE"))
(newline)
(show-build-options-help)
(newline)
@@ -615,6 +618,11 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
(values (cons `(query list-available ,(or arg ""))
result)
#f)))
+ (option '("show") #t #t
+ (lambda (opt name arg result arg-handler)
+ (values (cons `(query show-package ,arg)
+ result)
+ #f)))
%standard-build-options))
@@ -1011,6 +1019,35 @@ more information.~%"))
(reverse installed)))
#t))
+ (('show-package requested-name)
+ (let* ((available (fold-packages
+ (lambda (p r)
+ (let ((name (package-name p))
+ (full-name (package-full-name p)))
+ (if (or (string=? requested-name name)
+ (string=? requested-name full-name))
+ (cons p r)
+ r)))
+ '())))
+ (leave-on-EPIPE
+ (for-each (lambda (p)
+ (format #t "Package: ~a\n\
+Version: ~a\n\
+Description: ~a\n\
+Depends: ~a\n\
+Homepage: ~a\n\
+License: ~a\n~%"
+ (package-name p)
+ (package-version p)
+ (package-description p)
+ (string-join (map car (package-direct-inputs p)) ", ")
+ (package-home-page p)
+ (license-name (package-license p))))
+ (sort available
+ (lambda (p1 p2)
+ (version>? (package-version p2) (package-version p1))))))
+ #t))
+
(('list-available regexp)
(let* ((regexp (and regexp (make-regexp regexp)))
(available (fold-packages
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 4d75955..d388514 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -176,6 +176,9 @@ then false; else true; fi
# Check whether `--list-available' returns something sensible.
guix package -p "$profile" -A 'gui.*e' | grep guile
+# Check whether `--show' returns something sensible.
+guix package -p "$profile" --show=guile | grep "^Package: guile"
+
# There's no generation older than 12 months, so the following command should
# have no effect.
generation="`readlink_base "$profile"`"
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] guix package: add a "show" option.
2014-07-13 18:54 [PATCH] guix package: add a "show" option Cyril Roelandt
@ 2014-07-13 21:32 ` Ludovic Courtès
2014-07-14 8:41 ` Andreas Enge
2014-07-15 21:23 ` Ludovic Courtès
1 sibling, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2014-07-13 21:32 UTC (permalink / raw)
To: Cyril Roelandt; +Cc: guix-devel
Cyril Roelandt <tipecaml@gmail.com> skribis:
> + (for-each (lambda (p)
> + (format #t "Package: ~a\n\
> +Version: ~a\n\
> +Description: ~a\n\
> +Depends: ~a\n\
> +Homepage: ~a\n\
> +License: ~a\n~%"
> + (package-name p)
> + (package-version p)
> + (package-description p)
> + (string-join (map car (package-direct-inputs p)) ", ")
> + (package-home-page p)
> + (license-name (package-license p))))
No strong opinion, but this seems a bit redundant with ‘--search’, for
example:
--8<---------------cut here---------------start------------->8---
$ guix package -s guile | recsel -e 'name = "guile-cairo"'
name: guile-cairo
version: 1.4.1
location: gnu/packages/gtk.scm:424:2
homepage: http://www.nongnu.org/guile-cairo/
license: LGPL 3+
synopsis: Cairo bindings for GNU Guile
description: Guile-Cairo wraps the Cairo graphics library for Guile Scheme.
+ Guile-Cairo is complete, wrapping almost all of the Cairo API. It is API
+ stable, providing a firm base on which to do graphics work. Finally, and
+ importantly, it is pleasant to use. You get a powerful and well-maintained
+ graphics library with all of the benefits of Scheme: memory management,
+ exceptions, macros, and a dynamic programming environment.
--8<---------------cut here---------------end--------------->8---
One advantage is that ‘--show’ is restricted to exact package name
matches.
WDYT?
Besides, if ‘--show’ were to be added, it should be implemented in terms
of ‘package->recutils’ like ‘--search’.
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] guix package: add a "show" option.
2014-07-13 21:32 ` Ludovic Courtès
@ 2014-07-14 8:41 ` Andreas Enge
2014-07-14 8:47 ` Alex Sassmannshausen
0 siblings, 1 reply; 14+ messages in thread
From: Andreas Enge @ 2014-07-14 8:41 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
On Sun, Jul 13, 2014 at 11:32:33PM +0200, Ludovic Courtès wrote:
> No strong opinion, but this seems a bit redundant with ‘--search’, for
> example:
>
> --8<---------------cut here---------------start------------->8---
> $ guix package -s guile | recsel -e 'name = "guile-cairo"'
It is an option I missed, not knowing recsel. I think it would be useful.
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] guix package: add a "show" option.
2014-07-14 8:41 ` Andreas Enge
@ 2014-07-14 8:47 ` Alex Sassmannshausen
2014-07-14 9:03 ` John Darrington
0 siblings, 1 reply; 14+ messages in thread
From: Alex Sassmannshausen @ 2014-07-14 8:47 UTC (permalink / raw)
To: Andreas Enge; +Cc: guix-devel
Hello,
Andreas Enge writes:
> On Sun, Jul 13, 2014 at 11:32:33PM +0200, Ludovic Courtès wrote:
>> No strong opinion, but this seems a bit redundant with ‘--search’, for
>> example:
>>
>> --8<---------------cut here---------------start------------->8---
>> $ guix package -s guile | recsel -e 'name = "guile-cairo"'
>
> It is an option I missed, not knowing recsel. I think it would be useful.
>
> Andreas
+1.
I like the show option providing user-friendly syntactic sugar.
Alex
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] guix package: add a "show" option.
2014-07-14 8:47 ` Alex Sassmannshausen
@ 2014-07-14 9:03 ` John Darrington
0 siblings, 0 replies; 14+ messages in thread
From: John Darrington @ 2014-07-14 9:03 UTC (permalink / raw)
To: Alex Sassmannshausen; +Cc: guix-devel
On Mon, Jul 14, 2014 at 10:47:42AM +0200, Alex Sassmannshausen wrote:
Hello,
Andreas Enge writes:
> On Sun, Jul 13, 2014 at 11:32:33PM +0200, Ludovic Court??s wrote:
>> No strong opinion, but this seems a bit redundant with ???--search???, for
>> example:
>>
>> --8<---------------cut here---------------start------------->8---
>> $ guix package -s guile | recsel -e 'name = "guile-cairo"'
>
> It is an option I missed, not knowing recsel. I think it would be useful.
>
> Andreas
+1.
I like the show option providing user-friendly syntactic sugar.
Too much sugar early in the life of a project leads to chronic and possibly fatal disease
in middle age.
J'
--
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] guix package: add a "show" option.
2014-07-13 18:54 [PATCH] guix package: add a "show" option Cyril Roelandt
2014-07-13 21:32 ` Ludovic Courtès
@ 2014-07-15 21:23 ` Ludovic Courtès
2014-07-17 0:54 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Cyril Roelandt
1 sibling, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2014-07-15 21:23 UTC (permalink / raw)
To: Cyril Roelandt; +Cc: guix-devel
Cyril Roelandt <tipecaml@gmail.com> skribis:
> * guix/packages.scm (package-direct-inputs): New procedure.
> * guix/scripts/package.scm: Add a "show" option.
> * tests/guix-package.sh: Add a test for the "show" option.
Given that there is popular demand ;-), here’s a better review.
> +(define (package-direct-inputs package)
> + (sort (append (package-inputs package)
> + (package-native-inputs package)
> + (package-propagated-inputs package))
> + (lambda (p1 p2)
> + (string<? (car p1) (car p2)))))
Please add a docstring and at least one test in tests/packages.scm.
However, please remove ‘sort’ from here. The labels we use in package
inputs don’t have any special meaning, so there’s no reason to sort
things here, and they’ll probably vanish once we’ve fully integrated
gexps.
> + (display (_ "
> + --show=PACKAGE show details about PACKAGE"))
Please also add it to guix.texi, mentioning that the output is in
recutils format.
> + (('show-package requested-name)
> + (let* ((available (fold-packages
> + (lambda (p r)
> + (let ((name (package-name p))
> + (full-name (package-full-name p)))
> + (if (or (string=? requested-name name)
> + (string=? requested-name full-name))
> + (cons p r)
> + r)))
> + '())))
Use ‘specification->package+output’ (and ignore the second return value)
instead of ‘fold-packages’.
> + (leave-on-EPIPE
> + (for-each (lambda (p)
> + (format #t "Package: ~a\n\
> +Version: ~a\n\
> +Description: ~a\n\
> +Depends: ~a\n\
> +Homepage: ~a\n\
> +License: ~a\n~%"
> + (package-name p)
> + (package-version p)
> + (package-description p)
> + (string-join (map car (package-direct-inputs p)) ", ")
> + (package-home-page p)
> + (license-name (package-license p))))
Use ‘package->recutils’ instead of this.
In a separate patch, you can augment it to add the ‘depends’ field.
> + (sort available
> + (lambda (p1 p2)
> + (version>? (package-version p2) (package-version p1))))))
Sort by ‘package-full-name’ instead of ‘package-version’.
Thoughts?
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils:
2014-07-15 21:23 ` Ludovic Courtès
@ 2014-07-17 0:54 ` Cyril Roelandt
2014-07-17 0:54 ` [PATCH v2 2/2] guix package: add a "show" option Cyril Roelandt
2014-07-17 23:26 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
0 siblings, 2 replies; 14+ messages in thread
From: Cyril Roelandt @ 2014-07-17 0:54 UTC (permalink / raw)
To: guix-devel
* guix/packages.scm (package-direct-inputs): New procedure.
* tests/packages.scm: Test it.
* guix/ui.scm (package->recutils): Print the dependencies of the package.
---
guix/packages.scm | 8 ++++++++
guix/ui.scm | 8 ++++++++
tests/packages.scm | 13 +++++++++++++
3 files changed, 29 insertions(+)
diff --git a/guix/packages.scm b/guix/packages.scm
index 985a573..89f810f 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -75,6 +75,7 @@
package-location
package-field-location
+ package-direct-inputs
package-transitive-inputs
package-transitive-target-inputs
package-transitive-native-inputs
@@ -484,6 +485,13 @@ IMPORTED-MODULES specify modules to use/import for use by SNIPPET."
((input rest ...)
(loop rest (cons input result))))))
+(define (package-direct-inputs package)
+ "Return all the direct inputs of PACKAGE---i.e, its direct inputs along
+with their propagated inputs."
+ (append (package-inputs package)
+ (package-native-inputs package)
+ (package-propagated-inputs package)))
+
(define (package-transitive-inputs package)
"Return the transitive inputs of PACKAGE---i.e., its direct inputs along
with their propagated inputs, recursively."
diff --git a/guix/ui.scm b/guix/ui.scm
index 7338b82..6a1da96 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -456,6 +456,14 @@ WIDTH columns."
;; Note: Don't i18n field names so that people can post-process it.
(format port "name: ~a~%" (package-name p))
(format port "version: ~a~%" (package-version p))
+ (format port "depends: ~a~%"
+ (string-join
+ (map car
+ (sort (package-direct-inputs p)
+ (lambda (p1 p2)
+ (string<? (package-full-name (cadr p1))
+ (package-full-name (cadr p2))))))
+ ", "))
(format port "location: ~a~%"
(or (and=> (package-location p) location->string)
(_ "unknown")))
diff --git a/tests/packages.scm b/tests/packages.scm
index 6ac215b..e00d4f9 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -87,6 +87,19 @@
(with-fluids ((%file-port-name-canonicalization 'absolute))
(location-file (package-field-location %bootstrap-guile 'version))))
+(test-assert "package-direct-inputs"
+ (let* ((a (dummy-package "a"))
+ (b (dummy-package "b"))
+ (c (dummy-package "c"))
+ (d (dummy-package "d"
+ (inputs "c")))
+ (e (dummy-package "e"
+ (inputs `(("a" ,a)))
+ (native-inputs `(("b" ,b)))
+ (propagated-inputs `(("d" ,d))))))
+ (equal? (package-direct-inputs e)
+ `(("a" ,a) ("b" ,b) ("d" ,d)))))
+
(test-assert "package-transitive-inputs"
(let* ((a (dummy-package "a"))
(b (dummy-package "b"
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/2] guix package: add a "show" option.
2014-07-17 0:54 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Cyril Roelandt
@ 2014-07-17 0:54 ` Cyril Roelandt
2014-07-17 23:30 ` Ludovic Courtès
2014-07-17 23:26 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
1 sibling, 1 reply; 14+ messages in thread
From: Cyril Roelandt @ 2014-07-17 0:54 UTC (permalink / raw)
To: guix-devel
* doc/guix.texi: Update the documentation.
* guix/scripts/package.scm: Add a "show" option.
* tests/guix-package.sh: Add a test for the "show" option.
---
doc/guix.texi | 23 +++++++++++++++++++++++
guix/scripts/package.scm | 15 +++++++++++++++
tests/guix-package.sh | 3 +++
3 files changed, 41 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index 7ea40e5..38aade5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -839,6 +839,29 @@ name: gmp
@dots{}
@end example
+@item --show=@var{package}
+Show details about a given package in @code{recutils} format (@pxref{Top, GNU
+recutils databases,, recutils, GNU recutils manual}).
+
+@example
+$ guix package --show=python | recsel -p name,version
+name: python
+version: 2.7.6
+
+name: python
+version: 3.3.5
+@end example
+
+You may also specify the full name of a package to only get details about a
+specific version of it:
+@example
+$ guix package --show=python-3.3.5 | recsel -p name,version
+name: python
+version: 3.3.5
+@end example
+
+
+
@item --list-installed[=@var{regexp}]
@itemx -I [@var{regexp}]
List the currently installed packages in the specified profile, with the
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 1c3209f..0d17414 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -517,6 +517,8 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
(display (_ "
-A, --list-available[=REGEXP]
list available packages matching REGEXP"))
+ (display (_ "
+ --show=PACKAGE show details about PACKAGE"))
(newline)
(show-build-options-help)
(newline)
@@ -615,6 +617,11 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
(values (cons `(query list-available ,(or arg ""))
result)
#f)))
+ (option '("show") #t #t
+ (lambda (opt name arg result arg-handler)
+ (values (cons `(query show ,arg)
+ result)
+ #f)))
%standard-build-options))
@@ -1042,6 +1049,14 @@ more information.~%"))
(find-packages-by-description regexp)))
#t))
+ (('show requested-name)
+ (let-values (((name version)
+ (package-name->name+version requested-name)))
+ (leave-on-EPIPE
+ (for-each (cute package->recutils <> (current-output-port))
+ (find-packages-by-name name version)))
+ #t))
+
(('search-paths)
(let* ((manifest (profile-manifest profile))
(entries (manifest-entries manifest))
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 4d75955..d388514 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -176,6 +176,9 @@ then false; else true; fi
# Check whether `--list-available' returns something sensible.
guix package -p "$profile" -A 'gui.*e' | grep guile
+# Check whether `--show' returns something sensible.
+guix package -p "$profile" --show=guile | grep "^Package: guile"
+
# There's no generation older than 12 months, so the following command should
# have no effect.
generation="`readlink_base "$profile"`"
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils:
2014-07-17 0:54 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Cyril Roelandt
2014-07-17 0:54 ` [PATCH v2 2/2] guix package: add a "show" option Cyril Roelandt
@ 2014-07-17 23:26 ` Ludovic Courtès
2014-07-20 23:48 ` [PATCH v3 " Cyril Roelandt
2014-07-20 23:49 ` [PATCH v2 " Cyril Roelandt
1 sibling, 2 replies; 14+ messages in thread
From: Ludovic Courtès @ 2014-07-17 23:26 UTC (permalink / raw)
To: Cyril Roelandt; +Cc: guix-devel
Cyril Roelandt <tipecaml@gmail.com> skribis:
> * guix/packages.scm (package-direct-inputs): New procedure.
> * tests/packages.scm: Test it.
> * guix/ui.scm (package->recutils): Print the dependencies of the package.
[...]
> --- a/guix/ui.scm
> +++ b/guix/ui.scm
> @@ -456,6 +456,14 @@ WIDTH columns."
> ;; Note: Don't i18n field names so that people can post-process it.
> (format port "name: ~a~%" (package-name p))
> (format port "version: ~a~%" (package-version p))
> + (format port "depends: ~a~%"
> + (string-join
> + (map car
> + (sort (package-direct-inputs p)
> + (lambda (p1 p2)
> + (string<? (package-full-name (cadr p1))
> + (package-full-name (cadr p2))))))
> + ", "))
‘car’, ‘cadr’ & friends are frowned upon here.
Could you:
1. make a local helper procedure:
(define (package<? p1 p2)
(string<? (package-full-name p1) ...))
2. use ‘match’:
(match (package-direct-inputs p)
(((labels packages . _) ...)
(string-join (sort packages package<?) ", ")))
Otherwise looks good.
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] guix package: add a "show" option.
2014-07-17 0:54 ` [PATCH v2 2/2] guix package: add a "show" option Cyril Roelandt
@ 2014-07-17 23:30 ` Ludovic Courtès
0 siblings, 0 replies; 14+ messages in thread
From: Ludovic Courtès @ 2014-07-17 23:30 UTC (permalink / raw)
To: Cyril Roelandt; +Cc: guix-devel
Cyril Roelandt <tipecaml@gmail.com> skribis:
> * doc/guix.texi: Update the documentation.
> * guix/scripts/package.scm: Add a "show" option.
> * tests/guix-package.sh: Add a test for the "show" option.
[...]
> +@item --show=@var{package}
> +Show details about a given package in @code{recutils} format (@pxref{Top, GNU
Rather: “Show details about @var{package}, taken from the list of
available packages, in ...” (to make it clear that it’s not from the
list of installed packages.)
> --- a/tests/guix-package.sh
> +++ b/tests/guix-package.sh
> @@ -176,6 +176,9 @@ then false; else true; fi
> # Check whether `--list-available' returns something sensible.
> guix package -p "$profile" -A 'gui.*e' | grep guile
>
> +# Check whether `--show' returns something sensible.
> +guix package -p "$profile" --show=guile | grep "^Package: guile"
‘-p "$profile"’ can be omitted here.
OK to push with these changes, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 1/2] guix ui: add the "depends" field to package->recutils:
2014-07-17 23:26 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
@ 2014-07-20 23:48 ` Cyril Roelandt
2014-07-21 15:51 ` Ludovic Courtès
2014-07-20 23:49 ` [PATCH v2 " Cyril Roelandt
1 sibling, 1 reply; 14+ messages in thread
From: Cyril Roelandt @ 2014-07-20 23:48 UTC (permalink / raw)
To: guix-devel
* guix/packages.scm (package-direct-inputs): New procedure.
* tests/packages.scm: Test it.
* guix/ui.scm (package->recutils): Print the dependencies of the package.
---
guix/packages.scm | 8 ++++++++
guix/ui.scm | 7 +++++++
tests/packages.scm | 13 +++++++++++++
3 files changed, 28 insertions(+)
diff --git a/guix/packages.scm b/guix/packages.scm
index 985a573..89f810f 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -75,6 +75,7 @@
package-location
package-field-location
+ package-direct-inputs
package-transitive-inputs
package-transitive-target-inputs
package-transitive-native-inputs
@@ -484,6 +485,13 @@ IMPORTED-MODULES specify modules to use/import for use by SNIPPET."
((input rest ...)
(loop rest (cons input result))))))
+(define (package-direct-inputs package)
+ "Return all the direct inputs of PACKAGE---i.e, its direct inputs along
+with their propagated inputs."
+ (append (package-inputs package)
+ (package-native-inputs package)
+ (package-propagated-inputs package)))
+
(define (package-transitive-inputs package)
"Return the transitive inputs of PACKAGE---i.e., its direct inputs along
with their propagated inputs, recursively."
diff --git a/guix/ui.scm b/guix/ui.scm
index 7338b82..5674439 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -453,9 +453,16 @@ WIDTH columns."
(fill-paragraph str width
(string-length "description: ")))))
+ (define (package<? p1 p2)
+ (string<? (package-full-name p1) (package-full-name p2)))
+
;; Note: Don't i18n field names so that people can post-process it.
(format port "name: ~a~%" (package-name p))
(format port "version: ~a~%" (package-version p))
+ (format port "depends: ~a~%"
+ (match (package-direct-inputs p)
+ (((labels packages) ...)
+ (string-join (map package-full-name (sort packages package<?)) ", "))))
(format port "location: ~a~%"
(or (and=> (package-location p) location->string)
(_ "unknown")))
diff --git a/tests/packages.scm b/tests/packages.scm
index 6ac215b..e00d4f9 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -87,6 +87,19 @@
(with-fluids ((%file-port-name-canonicalization 'absolute))
(location-file (package-field-location %bootstrap-guile 'version))))
+(test-assert "package-direct-inputs"
+ (let* ((a (dummy-package "a"))
+ (b (dummy-package "b"))
+ (c (dummy-package "c"))
+ (d (dummy-package "d"
+ (inputs "c")))
+ (e (dummy-package "e"
+ (inputs `(("a" ,a)))
+ (native-inputs `(("b" ,b)))
+ (propagated-inputs `(("d" ,d))))))
+ (equal? (package-direct-inputs e)
+ `(("a" ,a) ("b" ,b) ("d" ,d)))))
+
(test-assert "package-transitive-inputs"
(let* ((a (dummy-package "a"))
(b (dummy-package "b"
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils:
2014-07-17 23:26 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
2014-07-20 23:48 ` [PATCH v3 " Cyril Roelandt
@ 2014-07-20 23:49 ` Cyril Roelandt
2014-07-21 15:53 ` Ludovic Courtès
1 sibling, 1 reply; 14+ messages in thread
From: Cyril Roelandt @ 2014-07-20 23:49 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
On 07/18/2014 01:26 AM, Ludovic Courtès wrote:
> (match (package-direct-inputs p)
> (((labels packages . _) ...)
> (string-join (sort packages package<?) ", ")))
Not sure why I'd need '. _' here, but I may just be misunderstanding
some features of Guile. See the third version of the patch.
Cyril.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 1/2] guix ui: add the "depends" field to package->recutils:
2014-07-20 23:48 ` [PATCH v3 " Cyril Roelandt
@ 2014-07-21 15:51 ` Ludovic Courtès
0 siblings, 0 replies; 14+ messages in thread
From: Ludovic Courtès @ 2014-07-21 15:51 UTC (permalink / raw)
To: Cyril Roelandt; +Cc: guix-devel
Cyril Roelandt <tipecaml@gmail.com> skribis:
> * guix/packages.scm (package-direct-inputs): New procedure.
> * tests/packages.scm: Test it.
> * guix/ui.scm (package->recutils): Print the dependencies of the package.
OK! “ui:” is enough in the subject line.
> + (format port "depends: ~a~%"
> + (match (package-direct-inputs p)
> + (((labels packages) ...)
> + (string-join (map package-full-name (sort packages package<?)) ", "))))
Please align “(match” with “port”.
Also, I think “dependencies” would be more consistent than “depends”
(sorry I didn’t catch it before.) Could you make that change?
OK to commit with these changes.
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils:
2014-07-20 23:49 ` [PATCH v2 " Cyril Roelandt
@ 2014-07-21 15:53 ` Ludovic Courtès
0 siblings, 0 replies; 14+ messages in thread
From: Ludovic Courtès @ 2014-07-21 15:53 UTC (permalink / raw)
To: Cyril Roelandt; +Cc: guix-devel
Cyril Roelandt <tipecaml@gmail.com> skribis:
> On 07/18/2014 01:26 AM, Ludovic Courtès wrote:
>> (match (package-direct-inputs p)
>> (((labels packages . _) ...)
>> (string-join (sort packages package<?) ", ")))
>
>
> Not sure why I'd need '. _' here,
The pattern (labels packages . _) matches a list of two or more
elements.
There’s often exactly two elements, but there can be one more when
specifying an output name, as in ("glib-bin" ,glib "bin").
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-07-21 15:54 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-13 18:54 [PATCH] guix package: add a "show" option Cyril Roelandt
2014-07-13 21:32 ` Ludovic Courtès
2014-07-14 8:41 ` Andreas Enge
2014-07-14 8:47 ` Alex Sassmannshausen
2014-07-14 9:03 ` John Darrington
2014-07-15 21:23 ` Ludovic Courtès
2014-07-17 0:54 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Cyril Roelandt
2014-07-17 0:54 ` [PATCH v2 2/2] guix package: add a "show" option Cyril Roelandt
2014-07-17 23:30 ` Ludovic Courtès
2014-07-17 23:26 ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
2014-07-20 23:48 ` [PATCH v3 " Cyril Roelandt
2014-07-21 15:51 ` Ludovic Courtès
2014-07-20 23:49 ` [PATCH v2 " Cyril Roelandt
2014-07-21 15:53 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).