From: Cyril Roelandt <tipecaml@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH v3 1/2] guix ui: add the "depends" field to package->recutils:
Date: Mon, 21 Jul 2014 01:48:14 +0200 [thread overview]
Message-ID: <1405900094-19802-1-git-send-email-tipecaml@gmail.com> (raw)
In-Reply-To: <87mwc7bm96.fsf@gnu.org>
* 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
next prev parent reply other threads:[~2014-07-20 23:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Cyril Roelandt [this message]
2014-07-21 15:51 ` [PATCH v3 " Ludovic Courtès
2014-07-20 23:49 ` [PATCH v2 " Cyril Roelandt
2014-07-21 15:53 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405900094-19802-1-git-send-email-tipecaml@gmail.com \
--to=tipecaml@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.