diff options
| -rw-r--r-- | doc/guix.texi | 18 | ||||
| -rw-r--r-- | guix/scripts/graph.scm | 21 | ||||
| -rw-r--r-- | tests/graph.scm | 14 |
3 files changed, 52 insertions, 1 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 3a9ebe8a637..adc7fefcae0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -5445,6 +5445,10 @@ end, display the fraction of packages covered by all these updaters. | |||
| 5445 | List top-level dependent packages that would need to be rebuilt as a | 5445 | List top-level dependent packages that would need to be rebuilt as a |
| 5446 | result of upgrading one or more packages. | 5446 | result of upgrading one or more packages. |
| 5447 | 5447 | ||
| 5448 | @xref{Invoking guix graph, the @code{reverse-package} type of | ||
| 5449 | @command{guix graph}}, for information on how to visualize the list of | ||
| 5450 | dependents of a package. | ||
| 5451 | |||
| 5448 | @end table | 5452 | @end table |
| 5449 | 5453 | ||
| 5450 | Be aware that the @code{--list-dependent} option only | 5454 | Be aware that the @code{--list-dependent} option only |
| @@ -5746,6 +5750,20 @@ This is the default type used in the example above. It shows the DAG of | |||
| 5746 | package objects, excluding implicit dependencies. It is concise, but | 5750 | package objects, excluding implicit dependencies. It is concise, but |
| 5747 | filters out many details. | 5751 | filters out many details. |
| 5748 | 5752 | ||
| 5753 | @item reverse-package | ||
| 5754 | This shows the @emph{reverse} DAG of packages. For example: | ||
| 5755 | |||
| 5756 | @example | ||
| 5757 | guix graph --type=reverse-package ocaml | ||
| 5758 | @end example | ||
| 5759 | |||
| 5760 | ... yields the graph of packages that depend on OCaml. | ||
| 5761 | |||
| 5762 | Note that for core packages this can yield huge graphs. If all you want | ||
| 5763 | is to know the number of packages that depend on a given package, use | ||
| 5764 | @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh, | ||
| 5765 | @option{--list-dependent}}). | ||
| 5766 | |||
| 5749 | @item bag-emerged | 5767 | @item bag-emerged |
| 5750 | This is the package DAG, @emph{including} implicit inputs. | 5768 | This is the package DAG, @emph{including} implicit inputs. |
| 5751 | 5769 | ||
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm index d96df5fbaf6..79ce503a2e5 100644 --- a/guix/scripts/graph.scm +++ b/guix/scripts/graph.scm | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #:use-module (srfi srfi-37) | 37 | #:use-module (srfi srfi-37) |
| 38 | #:use-module (ice-9 match) | 38 | #:use-module (ice-9 match) |
| 39 | #:export (%package-node-type | 39 | #:export (%package-node-type |
| 40 | %reverse-package-node-type | ||
| 40 | %bag-node-type | 41 | %bag-node-type |
| 41 | %bag-with-origins-node-type | 42 | %bag-with-origins-node-type |
| 42 | %bag-emerged-node-type | 43 | %bag-emerged-node-type |
| @@ -103,6 +104,25 @@ name." | |||
| 103 | 104 | ||
| 104 | 105 | ||
| 105 | ;;; | 106 | ;;; |
| 107 | ;;; Reverse package DAG. | ||
| 108 | ;;; | ||
| 109 | |||
| 110 | (define %reverse-package-node-type | ||
| 111 | ;; For this node type we first need to compute the list of packages and the | ||
| 112 | ;; list of back-edges. Since we want to do it only once, we use the | ||
| 113 | ;; promises below. | ||
| 114 | (let* ((packages (delay (fold-packages cons '()))) | ||
| 115 | (back-edges (delay (run-with-store #f ;store not actually needed | ||
| 116 | (node-back-edges %package-node-type | ||
| 117 | (force packages)))))) | ||
| 118 | (node-type | ||
| 119 | (inherit %package-node-type) | ||
| 120 | (name "reverse-package") | ||
| 121 | (description "the reverse DAG of packages") | ||
| 122 | (edges (lift1 (force back-edges) %store-monad))))) | ||
| 123 | |||
| 124 | |||
| 125 | ;;; | ||
| 106 | ;;; Package DAG using bags. | 126 | ;;; Package DAG using bags. |
| 107 | ;;; | 127 | ;;; |
| 108 | 128 | ||
| @@ -323,6 +343,7 @@ substitutes." | |||
| 323 | (define %node-types | 343 | (define %node-types |
| 324 | ;; List of all the node types. | 344 | ;; List of all the node types. |
| 325 | (list %package-node-type | 345 | (list %package-node-type |
| 346 | %reverse-package-node-type | ||
| 326 | %bag-node-type | 347 | %bag-node-type |
| 327 | %bag-with-origins-node-type | 348 | %bag-with-origins-node-type |
| 328 | %bag-emerged-node-type | 349 | %bag-emerged-node-type |
diff --git a/tests/graph.scm b/tests/graph.scm index bc4d62fe503..6431c482f7a 100644 --- a/tests/graph.scm +++ b/tests/graph.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -32,6 +32,7 @@ | |||
| 32 | #:use-module (gnu packages) | 32 | #:use-module (gnu packages) |
| 33 | #:use-module (gnu packages base) | 33 | #:use-module (gnu packages base) |
| 34 | #:use-module (gnu packages guile) | 34 | #:use-module (gnu packages guile) |
| 35 | #:use-module (gnu packages libunistring) | ||
| 35 | #:use-module (gnu packages bootstrap) | 36 | #:use-module (gnu packages bootstrap) |
| 36 | #:use-module (ice-9 match) | 37 | #:use-module (ice-9 match) |
| 37 | #:use-module (srfi srfi-1) | 38 | #:use-module (srfi srfi-1) |
| @@ -92,6 +93,17 @@ edges." | |||
| 92 | (list p3 p3 p2) | 93 | (list p3 p3 p2) |
| 93 | (list p2 p1 p1)))))))) | 94 | (list p2 p1 p1)))))))) |
| 94 | 95 | ||
| 96 | (test-assert "reverse package DAG" | ||
| 97 | (let-values (((backend nodes+edges) (make-recording-backend))) | ||
| 98 | (run-with-store %store | ||
| 99 | (export-graph (list libunistring) 'port | ||
| 100 | #:node-type %reverse-package-node-type | ||
| 101 | #:backend backend)) | ||
| 102 | ;; We should see nothing more than these 3 packages. | ||
| 103 | (let-values (((nodes edges) (nodes+edges))) | ||
| 104 | (and (member (package->tuple guile-2.0) nodes) | ||
| 105 | (->bool (member (edge->tuple libunistring guile-2.0) edges)))))) | ||
| 106 | |||
| 95 | (test-assert "bag-emerged DAG" | 107 | (test-assert "bag-emerged DAG" |
| 96 | (let-values (((backend nodes+edges) (make-recording-backend))) | 108 | (let-values (((backend nodes+edges) (make-recording-backend))) |
| 97 | (let* ((o (dummy-origin (method (lambda _ | 109 | (let* ((o (dummy-origin (method (lambda _ |
