2015-08-26 18:36:41 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2022-03-11 15:13:31 -05:00
|
|
|
|
;;; Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
|
2020-01-16 09:16:02 -05:00
|
|
|
|
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
|
2015-08-26 18:36:41 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (guix scripts graph)
|
|
|
|
|
#:use-module (guix ui)
|
2015-11-21 07:12:02 -05:00
|
|
|
|
#:use-module (guix graph)
|
2016-02-27 17:06:50 -05:00
|
|
|
|
#:use-module (guix grafts)
|
2015-09-10 05:37:36 -04:00
|
|
|
|
#:use-module (guix scripts)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (guix monads)
|
|
|
|
|
#:use-module (guix store)
|
|
|
|
|
#:use-module (guix gexp)
|
|
|
|
|
#:use-module (guix derivations)
|
Add (guix memoization).
* guix/combinators.scm (memoize): Remove.
* guix/memoization.scm: New file.
* Makefile.am (MODULES): Add it.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
guix/build-system/gnu.scm, guix/build-system/python.scm,
guix/derivations.scm, guix/gnu-maintenance.scm,
guix/import/cran.scm, guix/import/elpa.scm,
guix/modules.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/store.scm, guix/utils.scm: Adjust imports accordingly.
2017-01-28 10:33:57 -05:00
|
|
|
|
#:use-module (guix memoization)
|
2018-03-27 08:00:48 -04:00
|
|
|
|
#:use-module (guix modules)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#:use-module ((guix build-system gnu) #:select (standard-packages))
|
|
|
|
|
#:use-module (gnu packages)
|
|
|
|
|
#:use-module (guix sets)
|
2020-07-25 12:26:18 -04:00
|
|
|
|
#:use-module ((guix diagnostics)
|
|
|
|
|
#:select (location-file formatted-message))
|
guix build: Move transformation options to (guix transformations).
* guix/transformations.scm: New file.
* tests/scripts-build.scm: Rename to...
* tests/transformations.scm: ... this.
* Makefile.am (MODULES): Add 'guix/transformations.scm'.
(SCM_TESTS): Adjust to rename.
* guix/scripts/build.scm (numeric-extension?)
(tarball-base-name, <downloaded-file>, download-to-store*)
(compile-downloaded-file, package-with-source)
(transform-package-source, evaluate-replacement-specs)
(transform-package-inputs, transform-package-inputs/graft)
(%not-equal, package-git-url, evaluate-git-replacement-specs)
(transform-package-source-branch, transform-package-source-commit)
(transform-package-source-git-url, package-dependents/spec)
(package-toolchain-rewriting, transform-package-toolchain)
(transform-package-with-debug-info, transform-package-tests)
(%transformations, transformation-procedure, %transformation-options)
(show-transformation-options-help, options->transformation)
(package-transformations): Move to (guix transformations).
* guix/scripts/environment.scm: Adjust accordingly.
* guix/scripts/graph.scm: Likewise.
* guix/scripts/install.scm: Likewise.
* guix/scripts/pack.scm: Likewise.
* guix/scripts/package.scm: Likewise.
* guix/scripts/upgrade.scm: Likewise.
* po/guix/POTFILES.in: Add 'guix/transformations.scm'.
2020-10-29 13:30:07 -04:00
|
|
|
|
#:use-module ((guix transformations)
|
2020-11-21 06:14:04 -05:00
|
|
|
|
#:select (show-transformation-options-help
|
|
|
|
|
options->transformation
|
2019-11-07 12:15:55 -05:00
|
|
|
|
%transformation-options))
|
guix build: Move transformation options to (guix transformations).
* guix/transformations.scm: New file.
* tests/scripts-build.scm: Rename to...
* tests/transformations.scm: ... this.
* Makefile.am (MODULES): Add 'guix/transformations.scm'.
(SCM_TESTS): Adjust to rename.
* guix/scripts/build.scm (numeric-extension?)
(tarball-base-name, <downloaded-file>, download-to-store*)
(compile-downloaded-file, package-with-source)
(transform-package-source, evaluate-replacement-specs)
(transform-package-inputs, transform-package-inputs/graft)
(%not-equal, package-git-url, evaluate-git-replacement-specs)
(transform-package-source-branch, transform-package-source-commit)
(transform-package-source-git-url, package-dependents/spec)
(package-toolchain-rewriting, transform-package-toolchain)
(transform-package-with-debug-info, transform-package-tests)
(%transformations, transformation-procedure, %transformation-options)
(show-transformation-options-help, options->transformation)
(package-transformations): Move to (guix transformations).
* guix/scripts/environment.scm: Adjust accordingly.
* guix/scripts/graph.scm: Likewise.
* guix/scripts/install.scm: Likewise.
* guix/scripts/pack.scm: Likewise.
* guix/scripts/package.scm: Likewise.
* guix/scripts/upgrade.scm: Likewise.
* po/guix/POTFILES.in: Add 'guix/transformations.scm'.
2020-10-29 13:30:07 -04:00
|
|
|
|
#:use-module ((guix scripts build)
|
2022-05-02 06:59:14 -04:00
|
|
|
|
#:select (%standard-build-options
|
|
|
|
|
%standard-native-build-options
|
|
|
|
|
show-native-build-options-help))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#:use-module (srfi srfi-1)
|
2015-11-23 17:31:53 -05:00
|
|
|
|
#:use-module (srfi srfi-26)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#:use-module (srfi srfi-34)
|
2016-05-20 11:07:23 -04:00
|
|
|
|
#:use-module (srfi srfi-35)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#:use-module (srfi srfi-37)
|
2020-06-28 09:43:26 -04:00
|
|
|
|
#:use-module (ice-9 format)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:export (%package-node-type
|
2017-01-04 10:16:17 -05:00
|
|
|
|
%reverse-package-node-type
|
2015-08-26 18:36:41 -04:00
|
|
|
|
%bag-node-type
|
2015-11-23 17:31:53 -05:00
|
|
|
|
%bag-with-origins-node-type
|
2015-08-26 18:36:41 -04:00
|
|
|
|
%bag-emerged-node-type
|
2019-03-23 10:04:44 -04:00
|
|
|
|
%reverse-bag-node-type
|
2015-08-26 18:36:41 -04:00
|
|
|
|
%derivation-node-type
|
|
|
|
|
%reference-node-type
|
2016-10-15 16:47:42 -04:00
|
|
|
|
%referrer-node-type
|
2018-03-27 08:00:48 -04:00
|
|
|
|
%module-node-type
|
2015-08-27 15:32:23 -04:00
|
|
|
|
%node-types
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
guix-graph))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Package DAG.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (node-full-name thing)
|
|
|
|
|
"Return a human-readable name to denote THING, a package, origin, or file
|
|
|
|
|
name."
|
|
|
|
|
(cond ((package? thing)
|
|
|
|
|
(package-full-name thing))
|
|
|
|
|
((origin? thing)
|
2015-09-10 16:39:44 -04:00
|
|
|
|
(origin-actual-file-name thing))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
((string? thing) ;file name
|
|
|
|
|
(or (basename thing)
|
|
|
|
|
(error "basename" thing)))
|
|
|
|
|
(else
|
|
|
|
|
(number->string (object-address thing) 16))))
|
|
|
|
|
|
|
|
|
|
(define (package-node-edges package)
|
|
|
|
|
"Return the list of dependencies of PACKAGE."
|
|
|
|
|
(match (package-direct-inputs package)
|
|
|
|
|
(((labels packages . outputs) ...)
|
|
|
|
|
;; Filter out origins and other non-package dependencies.
|
|
|
|
|
(filter package? packages))))
|
|
|
|
|
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(define assert-package
|
|
|
|
|
(match-lambda
|
|
|
|
|
((? package? package)
|
|
|
|
|
package)
|
|
|
|
|
(x
|
|
|
|
|
(raise
|
2020-07-25 12:26:18 -04:00
|
|
|
|
(formatted-message (G_ "~a: invalid argument (package name expected)")
|
|
|
|
|
x)))))
|
2016-05-20 11:07:23 -04:00
|
|
|
|
|
|
|
|
|
(define nodes-from-package
|
|
|
|
|
;; The default conversion method.
|
|
|
|
|
(lift1 (compose list assert-package) %store-monad))
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(define %package-node-type
|
|
|
|
|
;; Type for the traversal of package nodes.
|
|
|
|
|
(node-type
|
|
|
|
|
(name "package")
|
|
|
|
|
(description "the DAG of packages, excluding implicit inputs")
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(convert nodes-from-package)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
;; We use package addresses as unique identifiers. This generally works
|
|
|
|
|
;; well, but for generated package objects, we could end up with two
|
|
|
|
|
;; packages that are not 'eq?', yet map to the same derivation (XXX).
|
|
|
|
|
(identifier (lift1 object-address %store-monad))
|
|
|
|
|
(label node-full-name)
|
|
|
|
|
(edges (lift1 package-node-edges %store-monad))))
|
|
|
|
|
|
2017-01-04 10:16:17 -05:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Reverse package DAG.
|
|
|
|
|
;;;
|
|
|
|
|
|
2019-03-23 10:10:37 -04:00
|
|
|
|
(define (all-packages) ;XXX: duplicated from (guix scripts refresh)
|
|
|
|
|
"Return the list of all the distro's packages."
|
|
|
|
|
(fold-packages (lambda (package result)
|
|
|
|
|
;; Ignore deprecated packages.
|
|
|
|
|
(if (package-superseded package)
|
|
|
|
|
result
|
|
|
|
|
(cons package result)))
|
|
|
|
|
'()
|
|
|
|
|
#:select? (const #t))) ;include hidden packages
|
|
|
|
|
|
2017-01-04 10:16:17 -05:00
|
|
|
|
(define %reverse-package-node-type
|
|
|
|
|
;; For this node type we first need to compute the list of packages and the
|
|
|
|
|
;; list of back-edges. Since we want to do it only once, we use the
|
|
|
|
|
;; promises below.
|
2019-03-23 10:10:37 -04:00
|
|
|
|
(let* ((packages (delay (all-packages)))
|
2017-01-04 10:16:17 -05:00
|
|
|
|
(back-edges (delay (run-with-store #f ;store not actually needed
|
|
|
|
|
(node-back-edges %package-node-type
|
|
|
|
|
(force packages))))))
|
|
|
|
|
(node-type
|
|
|
|
|
(inherit %package-node-type)
|
|
|
|
|
(name "reverse-package")
|
|
|
|
|
(description "the reverse DAG of packages")
|
|
|
|
|
(edges (lift1 (force back-edges) %store-monad)))))
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Package DAG using bags.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (bag-node-identifier thing)
|
|
|
|
|
"Return a unique identifier for THING, which may be a package, origin, or a
|
|
|
|
|
file name."
|
|
|
|
|
;; If THING is a file name (a string), we just return it; if it's a package
|
|
|
|
|
;; or origin, we return its address. That gives us the object graph, but
|
|
|
|
|
;; that may differ from the derivation graph (for instance,
|
|
|
|
|
;; 'package-with-bootstrap-guile' generates fresh package objects, and
|
|
|
|
|
;; several packages that are not 'eq?' may actually map to the same
|
|
|
|
|
;; derivation.) Thus, we lower THING and use its derivation file name as a
|
|
|
|
|
;; unique identifier.
|
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(if (string? thing)
|
|
|
|
|
(return thing)
|
|
|
|
|
(mlet %store-monad ((low (lower-object thing)))
|
|
|
|
|
(return (if (derivation? low)
|
|
|
|
|
(derivation-file-name low)
|
|
|
|
|
low))))))
|
|
|
|
|
|
|
|
|
|
(define (bag-node-edges thing)
|
2015-11-23 17:31:53 -05:00
|
|
|
|
"Return the list of dependencies of THING, a package or origin.
|
|
|
|
|
Dependencies may include packages, origin, and file names."
|
|
|
|
|
(cond ((package? thing)
|
|
|
|
|
(match (bag-direct-inputs (package->bag thing))
|
|
|
|
|
(((labels things . outputs) ...)
|
|
|
|
|
things)))
|
|
|
|
|
((origin? thing)
|
2016-01-02 16:22:57 -05:00
|
|
|
|
(cons (or (origin-patch-guile thing) (default-guile))
|
2015-11-23 17:31:53 -05:00
|
|
|
|
(if (or (pair? (origin-patches thing))
|
|
|
|
|
(origin-snippet thing))
|
|
|
|
|
(match (origin-patch-inputs thing)
|
|
|
|
|
(#f '())
|
|
|
|
|
(((labels dependencies _ ...) ...)
|
|
|
|
|
(delete-duplicates dependencies eq?)))
|
|
|
|
|
'())))
|
|
|
|
|
(else
|
|
|
|
|
'())))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define %bag-node-type
|
|
|
|
|
;; Type for the traversal of package nodes via the "bag" representation,
|
|
|
|
|
;; which includes implicit inputs.
|
|
|
|
|
(node-type
|
|
|
|
|
(name "bag")
|
|
|
|
|
(description "the DAG of packages, including implicit inputs")
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(convert nodes-from-package)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(identifier bag-node-identifier)
|
|
|
|
|
(label node-full-name)
|
2015-11-23 17:31:53 -05:00
|
|
|
|
(edges (lift1 (compose (cut filter package? <>) bag-node-edges)
|
|
|
|
|
%store-monad))))
|
|
|
|
|
|
|
|
|
|
(define %bag-with-origins-node-type
|
|
|
|
|
(node-type
|
|
|
|
|
(name "bag-with-origins")
|
|
|
|
|
(description "the DAG of packages and origins, including implicit inputs")
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(convert nodes-from-package)
|
2015-11-23 17:31:53 -05:00
|
|
|
|
(identifier bag-node-identifier)
|
|
|
|
|
(label node-full-name)
|
|
|
|
|
(edges (lift1 (lambda (thing)
|
|
|
|
|
(filter (match-lambda
|
|
|
|
|
((? package?) #t)
|
|
|
|
|
((? origin?) #t)
|
|
|
|
|
(_ #f))
|
|
|
|
|
(bag-node-edges thing)))
|
|
|
|
|
%store-monad))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define standard-package-set
|
2017-01-28 11:09:34 -05:00
|
|
|
|
(mlambda ()
|
|
|
|
|
"Return the set of standard packages provided by GNU-BUILD-SYSTEM."
|
|
|
|
|
(match (standard-packages)
|
|
|
|
|
(((labels packages . output) ...)
|
|
|
|
|
(list->setq packages)))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define (bag-node-edges-sans-bootstrap thing)
|
|
|
|
|
"Like 'bag-node-edges', but pretend that the standard packages of
|
|
|
|
|
GNU-BUILD-SYSTEM have zero dependencies."
|
|
|
|
|
(if (set-contains? (standard-package-set) thing)
|
|
|
|
|
'()
|
|
|
|
|
(bag-node-edges thing)))
|
|
|
|
|
|
|
|
|
|
(define %bag-emerged-node-type
|
|
|
|
|
;; Like %BAG-NODE-TYPE, but without the bootstrap subset of the DAG.
|
|
|
|
|
(node-type
|
|
|
|
|
(name "bag-emerged")
|
|
|
|
|
(description "same as 'bag', but without the bootstrap nodes")
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(convert nodes-from-package)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(identifier bag-node-identifier)
|
|
|
|
|
(label node-full-name)
|
2016-01-02 16:12:36 -05:00
|
|
|
|
(edges (lift1 (compose (cut filter package? <>)
|
|
|
|
|
bag-node-edges-sans-bootstrap)
|
|
|
|
|
%store-monad))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
2019-03-23 10:04:44 -04:00
|
|
|
|
(define %reverse-bag-node-type
|
|
|
|
|
;; Type for the reverse traversal of package nodes via the "bag"
|
|
|
|
|
;; representation, which includes implicit inputs.
|
2019-03-23 10:10:37 -04:00
|
|
|
|
(let* ((packages (delay (package-closure (all-packages))))
|
2019-03-23 10:04:44 -04:00
|
|
|
|
(back-edges (delay (run-with-store #f ;store not actually needed
|
|
|
|
|
(node-back-edges %bag-node-type
|
|
|
|
|
(force packages))))))
|
|
|
|
|
(node-type
|
|
|
|
|
(name "reverse-bag")
|
|
|
|
|
(description "the reverse DAG of packages, including implicit inputs")
|
|
|
|
|
(convert nodes-from-package)
|
|
|
|
|
(identifier bag-node-identifier)
|
|
|
|
|
(label node-full-name)
|
|
|
|
|
(edges (lift1 (force back-edges) %store-monad)))))
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Derivation DAG.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (derivation-dependencies obj)
|
|
|
|
|
"Return the <derivation> objects and store items corresponding to the
|
|
|
|
|
dependencies of OBJ, a <derivation> or store item."
|
|
|
|
|
(if (derivation? obj)
|
2019-06-23 03:38:23 -04:00
|
|
|
|
(append (map derivation-input-derivation (derivation-inputs obj))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(derivation-sources obj))
|
|
|
|
|
'()))
|
|
|
|
|
|
|
|
|
|
(define (derivation-node-identifier node)
|
|
|
|
|
"Return a unique identifier for NODE, which may be either a <derivation> or
|
|
|
|
|
a plain store file."
|
|
|
|
|
(if (derivation? node)
|
|
|
|
|
(derivation-file-name node)
|
|
|
|
|
node))
|
|
|
|
|
|
|
|
|
|
(define (derivation-node-label node)
|
|
|
|
|
"Return a label for NODE, a <derivation> object or plain store item."
|
|
|
|
|
(store-path-package-name (match node
|
|
|
|
|
((? derivation? drv)
|
|
|
|
|
(derivation-file-name drv))
|
|
|
|
|
((? string? file)
|
|
|
|
|
file))))
|
|
|
|
|
|
|
|
|
|
(define %derivation-node-type
|
|
|
|
|
;; DAG of derivations. Very accurate, very detailed, but usually too much
|
|
|
|
|
;; detailed.
|
|
|
|
|
(node-type
|
|
|
|
|
(name "derivation")
|
|
|
|
|
(description "the DAG of derivations")
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(convert (match-lambda
|
|
|
|
|
((? package? package)
|
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(>>= (package->derivation package)
|
|
|
|
|
(lift1 list %store-monad))))
|
|
|
|
|
((? derivation-path? item)
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
((store-lift add-temp-root) item)
|
2017-06-12 11:11:22 -04:00
|
|
|
|
(return (list (read-derivation-from-file item)))))
|
2016-05-20 11:07:23 -04:00
|
|
|
|
(x
|
|
|
|
|
(raise
|
|
|
|
|
(condition (&message (message "unsupported argument for \
|
|
|
|
|
derivation graph")))))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(identifier (lift1 derivation-node-identifier %store-monad))
|
|
|
|
|
(label derivation-node-label)
|
|
|
|
|
(edges (lift1 derivation-dependencies %store-monad))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; DAG of residual references (aka. run-time dependencies).
|
|
|
|
|
;;;
|
|
|
|
|
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(define intern
|
|
|
|
|
(mlambda (str)
|
|
|
|
|
"Intern STR, a string denoting a store item."
|
|
|
|
|
;; This is necessary for %REFERENCE-NODE-TYPE and %REFERRER-NODE-TYPE
|
|
|
|
|
;; because their nodes are strings but the (guix graph) traversal
|
|
|
|
|
;; procedures expect to be able to compare nodes with 'eq?'.
|
|
|
|
|
str))
|
|
|
|
|
|
2016-10-15 16:47:42 -04:00
|
|
|
|
(define ensure-store-items
|
|
|
|
|
;; Return a list of store items as a monadic value based on the given
|
|
|
|
|
;; argument, which may be a store item or a package.
|
|
|
|
|
(match-lambda
|
|
|
|
|
((? package? package)
|
|
|
|
|
;; Return the output file names of PACKAGE.
|
|
|
|
|
(mlet %store-monad ((drv (package->derivation package)))
|
|
|
|
|
(return (match (derivation->output-paths drv)
|
|
|
|
|
(((_ . file-names) ...)
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(map intern file-names))))))
|
2016-10-15 16:47:42 -04:00
|
|
|
|
((? store-path? item)
|
|
|
|
|
(with-monad %store-monad
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(return (list (intern item)))))
|
2016-10-15 16:47:42 -04:00
|
|
|
|
(x
|
|
|
|
|
(raise
|
|
|
|
|
(condition (&message (message "unsupported argument for \
|
|
|
|
|
this type of graph")))))))
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(define (references* item)
|
|
|
|
|
"Return as a monadic value the references of ITEM, based either on the
|
|
|
|
|
information available in the local store or using information about
|
|
|
|
|
substitutes."
|
|
|
|
|
(lambda (store)
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 11:41:11 -05:00
|
|
|
|
(guard (c ((store-protocol-error? c)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(match (substitutable-path-info store (list item))
|
|
|
|
|
((info)
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(values (map intern (substitutable-references info))
|
|
|
|
|
store))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(()
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(leave (G_ "references for '~a' are not known~%")
|
2015-08-26 18:36:41 -04:00
|
|
|
|
item)))))
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(values (map intern (references store item)) store))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define %reference-node-type
|
|
|
|
|
(node-type
|
|
|
|
|
(name "references")
|
|
|
|
|
(description "the DAG of run-time dependencies (store references)")
|
2016-10-15 16:47:42 -04:00
|
|
|
|
(convert ensure-store-items)
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(identifier (lift1 intern %store-monad))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(label store-path-package-name)
|
|
|
|
|
(edges references*)))
|
|
|
|
|
|
2016-10-15 16:47:42 -04:00
|
|
|
|
(define non-derivation-referrers
|
|
|
|
|
(let ((referrers (store-lift referrers)))
|
|
|
|
|
(lambda (item)
|
|
|
|
|
"Return the referrers of ITEM, except '.drv' files."
|
|
|
|
|
(mlet %store-monad ((items (referrers item)))
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(return (map intern (remove derivation-path? items)))))))
|
2016-10-15 16:47:42 -04:00
|
|
|
|
|
|
|
|
|
(define %referrer-node-type
|
|
|
|
|
(node-type
|
|
|
|
|
(name "referrers")
|
|
|
|
|
(description "the DAG of referrers in the store")
|
|
|
|
|
(convert ensure-store-items)
|
2020-05-09 18:04:59 -04:00
|
|
|
|
(identifier (lift1 intern %store-monad))
|
2016-10-15 16:47:42 -04:00
|
|
|
|
(label store-path-package-name)
|
|
|
|
|
(edges non-derivation-referrers)))
|
|
|
|
|
|
2018-03-27 08:00:48 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Scheme modules.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (module-from-package package)
|
|
|
|
|
(file-name->module-name (location-file (package-location package))))
|
|
|
|
|
|
|
|
|
|
(define (source-module-dependencies* module)
|
|
|
|
|
"Like 'source-module-dependencies' but filter out modules that are not
|
|
|
|
|
package modules, while attempting to retain user package modules."
|
|
|
|
|
(remove (match-lambda
|
|
|
|
|
(('guix _ ...) #t)
|
|
|
|
|
(('system _ ...) #t)
|
|
|
|
|
(('language _ ...) #t)
|
|
|
|
|
(('ice-9 _ ...) #t)
|
|
|
|
|
(('srfi _ ...) #t)
|
|
|
|
|
(_ #f))
|
|
|
|
|
(source-module-dependencies module)))
|
|
|
|
|
|
|
|
|
|
(define %module-node-type
|
|
|
|
|
;; Show the graph of package modules.
|
|
|
|
|
(node-type
|
|
|
|
|
(name "module")
|
|
|
|
|
(description "the graph of package modules")
|
|
|
|
|
(convert (lift1 (compose list module-from-package) %store-monad))
|
|
|
|
|
(identifier (lift1 identity %store-monad))
|
|
|
|
|
(label object->string)
|
|
|
|
|
(edges (lift1 source-module-dependencies* %store-monad))))
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; List of node types.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define %node-types
|
|
|
|
|
;; List of all the node types.
|
|
|
|
|
(list %package-node-type
|
2017-01-04 10:16:17 -05:00
|
|
|
|
%reverse-package-node-type
|
2015-08-26 18:36:41 -04:00
|
|
|
|
%bag-node-type
|
2015-11-23 17:31:53 -05:00
|
|
|
|
%bag-with-origins-node-type
|
2015-08-26 18:36:41 -04:00
|
|
|
|
%bag-emerged-node-type
|
2019-03-23 10:04:44 -04:00
|
|
|
|
%reverse-bag-node-type
|
2015-08-26 18:36:41 -04:00
|
|
|
|
%derivation-node-type
|
2016-10-15 16:47:42 -04:00
|
|
|
|
%reference-node-type
|
2018-03-27 08:00:48 -04:00
|
|
|
|
%referrer-node-type
|
|
|
|
|
%module-node-type))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define (lookup-node-type name)
|
|
|
|
|
"Return the node type called NAME. Raise an error if it is not found."
|
|
|
|
|
(or (find (lambda (type)
|
|
|
|
|
(string=? (node-type-name type) name))
|
|
|
|
|
%node-types)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(leave (G_ "~a: unknown node type~%") name)))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define (list-node-types)
|
|
|
|
|
"Print the available node types along with their synopsis."
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "The available node types are:\n"))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(newline)
|
|
|
|
|
(for-each (lambda (type)
|
|
|
|
|
(format #t " - ~a: ~a~%"
|
|
|
|
|
(node-type-name type)
|
|
|
|
|
(node-type-description type)))
|
|
|
|
|
%node-types))
|
|
|
|
|
|
2016-10-21 17:59:00 -04:00
|
|
|
|
(define (list-backends)
|
|
|
|
|
"Print the available backends along with their synopsis."
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "The available backend types are:\n"))
|
2016-10-21 17:59:00 -04:00
|
|
|
|
(newline)
|
|
|
|
|
(for-each (lambda (backend)
|
|
|
|
|
(format #t " - ~a: ~a~%"
|
|
|
|
|
(graph-backend-name backend)
|
|
|
|
|
(graph-backend-description backend)))
|
|
|
|
|
%graph-backends))
|
|
|
|
|
|
2020-05-09 18:53:29 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Displaying a path.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (display-path node1 node2 type)
|
|
|
|
|
"Display the shortest path from NODE1 to NODE2, of TYPE."
|
|
|
|
|
(mlet %store-monad ((path (shortest-path node1 node2 type)))
|
|
|
|
|
(define node-label
|
|
|
|
|
(let ((label (node-type-label type)))
|
|
|
|
|
;; Special-case derivations and store items to print them in full,
|
|
|
|
|
;; contrary to what their 'node-type-label' normally does.
|
|
|
|
|
(match-lambda
|
|
|
|
|
((? derivation? drv) (derivation-file-name drv))
|
|
|
|
|
((? string? str) str)
|
|
|
|
|
(node (label node)))))
|
|
|
|
|
|
|
|
|
|
(if path
|
|
|
|
|
(format #t "~{~a~%~}" (map node-label path))
|
|
|
|
|
(leave (G_ "no path from '~a' to '~a'~%")
|
|
|
|
|
(node-label node1) (node-label node2)))
|
|
|
|
|
(return #t)))
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Command-line options.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define %options
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(cons* (option '(#\t "type") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'node-type (lookup-node-type arg)
|
|
|
|
|
result)))
|
2020-05-09 18:53:29 -04:00
|
|
|
|
(option '("path") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'path? #t result)))
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(option '("list-types") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(list-node-types)
|
|
|
|
|
(exit 0)))
|
|
|
|
|
(option '(#\b "backend") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'backend (lookup-backend arg)
|
|
|
|
|
result)))
|
2021-09-17 04:13:15 -04:00
|
|
|
|
(option '(#\M "max-depth") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'max-depth (string->number* arg)
|
|
|
|
|
result)))
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(option '("list-backends") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(list-backends)
|
|
|
|
|
(exit 0)))
|
|
|
|
|
(option '(#\e "expression") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'expression arg result)))
|
2020-01-16 09:16:02 -05:00
|
|
|
|
(find (lambda (option)
|
|
|
|
|
(member "load-path" (option-names option)))
|
|
|
|
|
%standard-build-options)
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(option '(#\h "help") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-help)
|
|
|
|
|
(exit 0)))
|
|
|
|
|
(option '(#\V "version") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-version-and-exit "guix graph")))
|
|
|
|
|
|
2022-05-02 06:59:14 -04:00
|
|
|
|
(append %transformation-options
|
|
|
|
|
%standard-native-build-options)))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
(define (show-help)
|
|
|
|
|
;; TRANSLATORS: Here 'dot' is the name of a program; it must not be
|
|
|
|
|
;; translated.
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "Usage: guix graph PACKAGE...
|
2017-10-27 17:53:17 -04:00
|
|
|
|
Emit a representation of the dependency graph of PACKAGE...\n"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2016-10-21 17:59:00 -04:00
|
|
|
|
-b, --backend=TYPE produce a graph with the given backend TYPE"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2016-10-21 17:59:00 -04:00
|
|
|
|
--list-backends list the available graph backends"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-08-26 18:36:41 -04:00
|
|
|
|
-t, --type=TYPE represent nodes of the given TYPE"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-08-26 18:36:41 -04:00
|
|
|
|
--list-types list the available graph types"))
|
2021-09-17 04:13:15 -04:00
|
|
|
|
(display (G_ "
|
2021-11-23 04:16:36 -05:00
|
|
|
|
-M, --max-depth=DEPTH limit to nodes within distance DEPTH"))
|
2020-05-09 18:53:29 -04:00
|
|
|
|
(display (G_ "
|
|
|
|
|
--path display the shortest path between the given nodes"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-09-02 09:23:52 -04:00
|
|
|
|
-e, --expression=EXPR consider the package EXPR evaluates to"))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(newline)
|
2020-01-16 09:16:02 -05:00
|
|
|
|
(display (G_ "
|
|
|
|
|
-L, --load-path=DIR prepend DIR to the package module search path"))
|
|
|
|
|
(newline)
|
2020-11-21 06:14:04 -05:00
|
|
|
|
(show-transformation-options-help)
|
|
|
|
|
(newline)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-08-26 18:36:41 -04:00
|
|
|
|
-h, --help display this help and exit"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-08-26 18:36:41 -04:00
|
|
|
|
-V, --version display version information and exit"))
|
|
|
|
|
(newline)
|
2022-05-02 06:59:14 -04:00
|
|
|
|
(show-native-build-options-help)
|
|
|
|
|
(newline)
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(show-bug-report-information))
|
|
|
|
|
|
|
|
|
|
(define %default-options
|
2016-10-21 17:59:00 -04:00
|
|
|
|
`((node-type . ,%package-node-type)
|
2018-09-16 15:38:23 -04:00
|
|
|
|
(backend . ,%graphviz-backend)
|
2021-09-17 04:13:15 -04:00
|
|
|
|
(max-depth . +inf.0)
|
2018-09-16 15:38:23 -04:00
|
|
|
|
(system . ,(%current-system))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Entry point.
|
|
|
|
|
;;;
|
|
|
|
|
|
2020-09-01 16:13:11 -04:00
|
|
|
|
(define-command (guix-graph . args)
|
|
|
|
|
(category packaging)
|
|
|
|
|
(synopsis "view and query package dependency graphs")
|
|
|
|
|
|
2015-08-26 18:36:41 -04:00
|
|
|
|
(with-error-handling
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(define opts
|
|
|
|
|
(parse-command-line args %options
|
|
|
|
|
(list %default-options)
|
|
|
|
|
#:build-options? #f))
|
|
|
|
|
(define backend
|
|
|
|
|
(assoc-ref opts 'backend))
|
|
|
|
|
(define type
|
|
|
|
|
(assoc-ref opts 'node-type))
|
|
|
|
|
|
|
|
|
|
(with-store store
|
|
|
|
|
(let* ((transform (options->transformation opts))
|
2021-09-17 04:13:15 -04:00
|
|
|
|
(max-depth (assoc-ref opts 'max-depth))
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(items (filter-map (match-lambda
|
|
|
|
|
(('argument . (? store-path? item))
|
|
|
|
|
item)
|
|
|
|
|
(('argument . spec)
|
guix build: 'options->transformation' no longer takes a 'store' parameter.
* guix/scripts/build.scm (transform-package-source)
(transform-package-inputs, transform-package-inputs/graft)
(transform-package-source-branch, transform-package-source-commit)
(transform-package-source-git-url, transform-package-toolchain)
(transform-package-with-debug-info, transform-package-tests): Remove
'store' parameter.
(options->transformation, options->derivations): Adjust accordingly.
* guix/scripts/environment.scm (options/resolve-packages): Likewise.
* guix/scripts/graph.scm (guix-graph): Likewise.
* guix/scripts/pack.scm (guix-pack): Likewise.
* guix/scripts/package.scm (transaction-upgrade-entry): Likewise.
(process-actions): Likewise.
* tests/scripts-build.scm ("options->transformation, no transformations")
("options->transformation, with-source, replacement"):
Adjust tests.
("options->transformation, with-source")
("options->transformation, with-source, with version")
("options->transformation, with-source, PKG=URI"): Use 'lower-object' to
compute the store file name of the source.
("options->transformation, with-source, no matches"): Remove
'with-store' and adjust accordingly.
("options->transformation, with-input"): Likewise.
("options->transformation, with-graft"): Likewise.
("options->transformation, with-branch"): Likewise.
("options->transformation, with-commit"): Likewise.
("options->transformation, with-git-url"): Likewise.
("options->transformation, with-git-url + with-branch"): Likewise.
("options->transformation, with-c-toolchain"): Likewise.
("options->transformation, with-c-toolchain twice"): Likewise.
("options->transformation, with-c-toolchain, no effect"): Likewise.
("options->transformation, with-debug-info"): Likewise.
("options->transformation, without-tests"): Likewise.
2020-10-28 18:35:49 -04:00
|
|
|
|
(transform
|
|
|
|
|
(specification->package spec)))
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(('expression . exp)
|
guix build: 'options->transformation' no longer takes a 'store' parameter.
* guix/scripts/build.scm (transform-package-source)
(transform-package-inputs, transform-package-inputs/graft)
(transform-package-source-branch, transform-package-source-commit)
(transform-package-source-git-url, transform-package-toolchain)
(transform-package-with-debug-info, transform-package-tests): Remove
'store' parameter.
(options->transformation, options->derivations): Adjust accordingly.
* guix/scripts/environment.scm (options/resolve-packages): Likewise.
* guix/scripts/graph.scm (guix-graph): Likewise.
* guix/scripts/pack.scm (guix-pack): Likewise.
* guix/scripts/package.scm (transaction-upgrade-entry): Likewise.
(process-actions): Likewise.
* tests/scripts-build.scm ("options->transformation, no transformations")
("options->transformation, with-source, replacement"):
Adjust tests.
("options->transformation, with-source")
("options->transformation, with-source, with version")
("options->transformation, with-source, PKG=URI"): Use 'lower-object' to
compute the store file name of the source.
("options->transformation, with-source, no matches"): Remove
'with-store' and adjust accordingly.
("options->transformation, with-input"): Likewise.
("options->transformation, with-graft"): Likewise.
("options->transformation, with-branch"): Likewise.
("options->transformation, with-commit"): Likewise.
("options->transformation, with-git-url"): Likewise.
("options->transformation, with-git-url + with-branch"): Likewise.
("options->transformation, with-c-toolchain"): Likewise.
("options->transformation, with-c-toolchain twice"): Likewise.
("options->transformation, with-c-toolchain, no effect"): Likewise.
("options->transformation, with-debug-info"): Likewise.
("options->transformation, without-tests"): Likewise.
2020-10-28 18:35:49 -04:00
|
|
|
|
(transform
|
|
|
|
|
(read/eval-package-expression exp)))
|
2019-11-07 12:15:55 -05:00
|
|
|
|
(_ #f))
|
|
|
|
|
opts)))
|
2021-05-28 04:53:49 -04:00
|
|
|
|
(when (null? items)
|
|
|
|
|
(warning (G_ "no arguments specified; creating an empty graph~%")))
|
|
|
|
|
|
2020-01-24 12:13:38 -05:00
|
|
|
|
(run-with-store store
|
|
|
|
|
;; XXX: Since grafting can trigger unsolicited builds, disable it.
|
|
|
|
|
(mlet %store-monad ((_ (set-grafting #f))
|
|
|
|
|
(nodes (mapm %store-monad
|
|
|
|
|
(node-type-convert type)
|
2020-05-09 18:53:29 -04:00
|
|
|
|
(reverse items))))
|
|
|
|
|
(if (assoc-ref opts 'path?)
|
|
|
|
|
(match nodes
|
|
|
|
|
(((node1 _ ...) (node2 _ ...))
|
|
|
|
|
(display-path node1 node2 type))
|
|
|
|
|
(_
|
|
|
|
|
(leave (G_ "'--path' option requires exactly two \
|
|
|
|
|
nodes (given ~a)~%")
|
|
|
|
|
(length nodes))))
|
|
|
|
|
(export-graph (concatenate nodes)
|
|
|
|
|
(current-output-port)
|
|
|
|
|
#:node-type type
|
2021-09-17 04:13:15 -04:00
|
|
|
|
#:backend backend
|
|
|
|
|
#:max-depth max-depth)))
|
2020-01-24 12:13:38 -05:00
|
|
|
|
#:system (assq-ref opts 'system)))))
|
2015-08-26 18:36:41 -04:00
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
;;; graph.scm ends here
|