From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-ID: <1405558450-13602-1-git-send-email-tipecaml@gmail.com> References: <87r41mjozg.fsf@gnu.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7a6O-0007C1-Ds for guix-devel@gnu.org; Wed, 16 Jul 2014 21:03:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7a6F-0002zy-5s for guix-devel@gnu.org; Wed, 16 Jul 2014 21:03:16 -0400 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:36773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7a6E-0002z0-RQ for guix-devel@gnu.org; Wed, 16 Jul 2014 21:03:07 -0400 Received: by mail-wg0-f47.google.com with SMTP id b13so1670703wgh.6 for ; Wed, 16 Jul 2014 18:03:05 -0700 (PDT) In-Reply-To: <87r41mjozg.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@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 | 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-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