guix-devel
[Top][All Lists]
Advanced

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

[PATCH v3 1/2] guix ui: add the "depends" field to package->recutils:


From: Cyril Roelandt
Subject: [PATCH v3 1/2] guix ui: add the "depends" field to package->recutils:
Date: Mon, 21 Jul 2014 01:48:14 +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        |  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




reply via email to

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