[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/2] guix ui: add the "depends" field to package->recutils:
From: |
Cyril Roelandt |
Subject: |
[PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: |
Date: |
Thu, 17 Jul 2014 02:54:09 +0200 |
* 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