2021-09-21 23:04:37 +02:00
|
|
|
#!/usr/bin/env python3
|
2010-05-06 10:09:14 +02:00
|
|
|
|
|
|
|
# Usage (the graphviz package must be installed in your distribution)
|
2014-04-13 22:42:38 +02:00
|
|
|
# ./support/scripts/graph-depends [-p package-name] > test.dot
|
2010-05-06 10:09:14 +02:00
|
|
|
# dot -Tpdf test.dot -o test.pdf
|
|
|
|
#
|
|
|
|
# With no arguments, graph-depends will draw a complete graph of
|
2014-04-13 22:42:38 +02:00
|
|
|
# dependencies for the current configuration.
|
|
|
|
# If '-p <package-name>' is specified, graph-depends will draw a graph
|
|
|
|
# of dependencies for the given package name.
|
2014-04-13 22:42:39 +02:00
|
|
|
# If '-d <depth>' is specified, graph-depends will limit the depth of
|
|
|
|
# the dependency graph to 'depth' levels.
|
2010-05-06 10:09:14 +02:00
|
|
|
#
|
|
|
|
# Limitations
|
|
|
|
#
|
|
|
|
# * Some packages have dependencies that depend on the Buildroot
|
|
|
|
# configuration. For example, many packages have a dependency on
|
|
|
|
# openssl if openssl has been enabled. This tool will graph the
|
|
|
|
# dependencies as they are with the current Buildroot
|
|
|
|
# configuration.
|
|
|
|
#
|
2013-01-02 08:08:52 +01:00
|
|
|
# Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
# Copyright (C) 2019 Yann E. MORIN <yann.morin.1998@free.fr>
|
2010-05-06 10:09:14 +02:00
|
|
|
|
2018-04-01 21:14:48 +02:00
|
|
|
import logging
|
2010-05-06 10:09:14 +02:00
|
|
|
import sys
|
2014-04-13 22:42:38 +02:00
|
|
|
import argparse
|
2015-03-24 23:16:49 +01:00
|
|
|
from fnmatch import fnmatch
|
2010-05-06 10:09:14 +02:00
|
|
|
|
2017-03-21 09:22:33 +01:00
|
|
|
import brpkgutil
|
2017-02-03 21:57:44 +01:00
|
|
|
|
2014-06-08 16:03:51 +02:00
|
|
|
# Modes of operation:
|
|
|
|
MODE_FULL = 1 # draw full dependency graph for all selected packages
|
2018-01-22 01:44:29 +01:00
|
|
|
MODE_PKG = 2 # draw dependency graph for a given package
|
2014-06-08 16:03:49 +02:00
|
|
|
|
2010-05-06 10:09:14 +02:00
|
|
|
allpkgs = []
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2010-05-06 10:09:14 +02:00
|
|
|
# The Graphviz "dot" utility doesn't like dashes in node names. So for
|
2018-11-24 10:34:52 +01:00
|
|
|
# node names, we strip all dashes. Also, nodes can't start with a number,
|
|
|
|
# so we prepend an underscore.
|
2010-05-06 10:09:14 +02:00
|
|
|
def pkg_node_name(pkg):
|
2018-11-24 10:34:52 +01:00
|
|
|
return "_" + pkg.replace("-", "")
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2010-05-06 10:09:14 +02:00
|
|
|
|
2015-12-15 11:21:41 +01:00
|
|
|
# Basic cache for the results of the is_dep() function, in order to
|
|
|
|
# optimize the execution time. The cache is a dict of dict of boolean
|
|
|
|
# values. The key to the primary dict is "pkg", and the key of the
|
|
|
|
# sub-dicts is "pkg2".
|
|
|
|
is_dep_cache = {}
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2015-12-15 11:21:41 +01:00
|
|
|
def is_dep_cache_insert(pkg, pkg2, val):
|
|
|
|
try:
|
|
|
|
is_dep_cache[pkg].update({pkg2: val})
|
|
|
|
except KeyError:
|
|
|
|
is_dep_cache[pkg] = {pkg2: val}
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2015-12-15 11:21:41 +01:00
|
|
|
# Retrieves from the cache whether pkg2 is a transitive dependency
|
|
|
|
# of pkg.
|
|
|
|
# Note: raises a KeyError exception if the dependency is not known.
|
|
|
|
def is_dep_cache_lookup(pkg, pkg2):
|
|
|
|
return is_dep_cache[pkg][pkg2]
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2014-06-08 16:03:46 +02:00
|
|
|
# This function return True if pkg is a dependency (direct or
|
|
|
|
# transitive) of pkg2, dependencies being listed in the deps
|
|
|
|
# dictionary. Returns False otherwise.
|
2015-12-15 11:21:41 +01:00
|
|
|
# This is the un-cached version.
|
2018-01-22 01:44:29 +01:00
|
|
|
def is_dep_uncached(pkg, pkg2, deps):
|
2015-12-15 11:21:41 +01:00
|
|
|
try:
|
2014-06-08 16:03:46 +02:00
|
|
|
for p in deps[pkg2]:
|
|
|
|
if pkg == p:
|
|
|
|
return True
|
2018-01-22 01:44:29 +01:00
|
|
|
if is_dep(pkg, p, deps):
|
2014-06-08 16:03:46 +02:00
|
|
|
return True
|
2015-12-15 11:21:41 +01:00
|
|
|
except KeyError:
|
|
|
|
pass
|
2014-06-08 16:03:46 +02:00
|
|
|
return False
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2015-12-29 23:46:10 +01:00
|
|
|
# See is_dep_uncached() above; this is the cached version.
|
2018-01-22 01:44:29 +01:00
|
|
|
def is_dep(pkg, pkg2, deps):
|
2015-12-15 11:21:41 +01:00
|
|
|
try:
|
|
|
|
return is_dep_cache_lookup(pkg, pkg2)
|
|
|
|
except KeyError:
|
|
|
|
val = is_dep_uncached(pkg, pkg2, deps)
|
|
|
|
is_dep_cache_insert(pkg, pkg2, val)
|
|
|
|
return val
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2014-06-08 16:03:46 +02:00
|
|
|
# This function eliminates transitive dependencies; for example, given
|
|
|
|
# these dependency chain: A->{B,C} and B->{C}, the A->{C} dependency is
|
|
|
|
# already covered by B->{C}, so C is a transitive dependency of A, via B.
|
|
|
|
# The functions does:
|
|
|
|
# - for each dependency d[i] of the package pkg
|
|
|
|
# - if d[i] is a dependency of any of the other dependencies d[j]
|
|
|
|
# - do not keep d[i]
|
|
|
|
# - otherwise keep d[i]
|
2018-01-22 01:44:29 +01:00
|
|
|
def remove_transitive_deps(pkg, deps):
|
2014-06-08 16:03:46 +02:00
|
|
|
d = deps[pkg]
|
|
|
|
new_d = []
|
|
|
|
for i in range(len(d)):
|
|
|
|
keep_me = True
|
|
|
|
for j in range(len(d)):
|
2018-01-22 01:44:29 +01:00
|
|
|
if j == i:
|
2014-06-08 16:03:46 +02:00
|
|
|
continue
|
2018-01-22 01:44:29 +01:00
|
|
|
if is_dep(d[i], d[j], deps):
|
2014-06-08 16:03:46 +02:00
|
|
|
keep_me = False
|
|
|
|
if keep_me:
|
|
|
|
new_d.append(d[i])
|
|
|
|
return new_d
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2018-12-02 10:04:35 +01:00
|
|
|
# List of dependencies that all/many packages have, and that we want
|
|
|
|
# to trim when generating the dependency graph.
|
2019-10-01 18:34:58 +02:00
|
|
|
MANDATORY_DEPS = ['toolchain', 'skeleton', 'host-skeleton', 'host-tar', 'host-gzip', 'host-ccache']
|
2018-12-02 10:04:35 +01:00
|
|
|
|
|
|
|
|
2015-07-14 13:36:26 +02:00
|
|
|
# This function removes the dependency on some 'mandatory' package, like the
|
|
|
|
# 'toolchain' package, or the 'skeleton' package
|
2018-01-22 01:44:29 +01:00
|
|
|
def remove_mandatory_deps(pkg, deps):
|
2018-12-02 10:04:35 +01:00
|
|
|
return [p for p in deps[pkg] if p not in MANDATORY_DEPS]
|
2014-06-08 16:03:47 +02:00
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
support/graph-depends: make sure mandatory deps are displayed
The current graph-depends implementation filters out a number of
"mandatory" dependencies that all packages have: dependency on
"toolchain" and dependency on "skeleton".
Despite this filtering, in full graph dependencies, "toolchain" and
"skeleton" are still shown, because they are target packages, and
therefore appear in the result of "make show-targets". Thanks to this,
they will be visible as dependencies of the "ALL" node, which is the
root of the dependency tree.
However, as we are going to introduce host-skeleton as a "mandatory
dependency" to be filtered out, this is no longer going to work.
This commit adjusts the remove_extra_deps() function to ensure that
when a mandatory dependency is removed, this dependency exists between
the root of the dependency tree and the mandatory dependency.
This issue was noticed by Yann E. Morin, and this commit provides a
different implementation than what Yann proposed in
https://patchwork.ozlabs.org/patch/910453/.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr:
- list mandatory deps before removing them
- fix flake8 warnings
]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-03 11:16:29 +01:00
|
|
|
# This function returns all dependencies of pkg that are part of the
|
|
|
|
# mandatory dependencies:
|
|
|
|
def get_mandatory_deps(pkg, deps):
|
|
|
|
return [p for p in deps[pkg] if p in MANDATORY_DEPS]
|
|
|
|
|
|
|
|
|
support/graph-depends: detect circular dependencies
Currently, if there is a circular dependency in the packages, the
graph-depends script just errors out with a Python RuntimeError which is
not caught, resulting in a very-long backtrace which does not provide
any hint as what the real issue is (even if "RuntimeError: maximum
recursion depth exceeded" is a pretty good hint at it).
We fix that by recursing the dependency chain of each package, until we
either end up with a package with no dependency, or with a package
already seen along the current dependency chain.
We need to introduce a new function, check_circular_deps(), because we
can't re-use the existing ones:
- remove_mandatory_deps() does not iterate,
- remove_transitive_deps() does iterate, but we do not call it for the
top-level package if it is not 'all'
- it does not make sense to use those functions anyway, as they were
not designed to _check_ but to _act_ on the dependency chain.
Since we've had time-related issues in the past, we do not want to
introduce yet another time-hog, so here are timings with the circular
dependency check:
$ time python -m cProfile -s cumtime support/scripts/graph-depends
[...]
28352654 function calls (20323050 primitive calls) in 87.292 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.012 0.012 87.292 87.292 graph-depends:24(<module>)
21 0.000 0.000 73.685 3.509 subprocess.py:473(_eintr_retry_call)
7 0.000 0.000 73.655 10.522 subprocess.py:768(communicate)
7 73.653 10.522 73.653 10.522 {method 'read' of 'file' objects}
5/1 0.027 0.005 43.488 43.488 graph-depends:164(get_all_depends)
5 0.003 0.001 43.458 8.692 graph-depends:135(get_depends)
1 0.001 0.001 25.712 25.712 graph-depends:98(get_version)
1 0.001 0.001 13.457 13.457 graph-depends:337(remove_extra_deps)
1717 1.672 0.001 13.050 0.008 graph-depends:290(remove_transitive_deps)
9784086/2672326 5.079 0.000 11.363 0.000 graph-depends:274(is_dep)
2883343/1980154 2.650 0.000 6.942 0.000 graph-depends:262(is_dep_uncached)
1 0.000 0.000 4.529 4.529 graph-depends:121(get_targets)
2883343 1.123 0.000 1.851 0.000 graph-depends:246(is_dep_cache_insert)
9784086 1.783 0.000 1.783 0.000 graph-depends:255(is_dep_cache_lookup)
2881580 0.728 0.000 0.728 0.000 {method 'update' of 'dict' objects}
1 0.001 0.001 0.405 0.405 graph-depends:311(check_circular_deps)
12264/1717 0.290 0.000 0.404 0.000 graph-depends:312(recurse)
[...]
real 1m27.371s
user 1m15.075s
sys 0m12.673s
The cumulative time spent in check_circular_deps is just below 0.5s,
which is largely less than 1% of the total run time.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-02-07 22:34:27 +01:00
|
|
|
# This function will check that there is no loop in the dependency chain
|
|
|
|
# As a side effect, it builds up the dependency cache.
|
|
|
|
def check_circular_deps(deps):
|
|
|
|
def recurse(pkg):
|
2018-01-22 01:44:29 +01:00
|
|
|
if pkg not in list(deps.keys()):
|
support/graph-depends: detect circular dependencies
Currently, if there is a circular dependency in the packages, the
graph-depends script just errors out with a Python RuntimeError which is
not caught, resulting in a very-long backtrace which does not provide
any hint as what the real issue is (even if "RuntimeError: maximum
recursion depth exceeded" is a pretty good hint at it).
We fix that by recursing the dependency chain of each package, until we
either end up with a package with no dependency, or with a package
already seen along the current dependency chain.
We need to introduce a new function, check_circular_deps(), because we
can't re-use the existing ones:
- remove_mandatory_deps() does not iterate,
- remove_transitive_deps() does iterate, but we do not call it for the
top-level package if it is not 'all'
- it does not make sense to use those functions anyway, as they were
not designed to _check_ but to _act_ on the dependency chain.
Since we've had time-related issues in the past, we do not want to
introduce yet another time-hog, so here are timings with the circular
dependency check:
$ time python -m cProfile -s cumtime support/scripts/graph-depends
[...]
28352654 function calls (20323050 primitive calls) in 87.292 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.012 0.012 87.292 87.292 graph-depends:24(<module>)
21 0.000 0.000 73.685 3.509 subprocess.py:473(_eintr_retry_call)
7 0.000 0.000 73.655 10.522 subprocess.py:768(communicate)
7 73.653 10.522 73.653 10.522 {method 'read' of 'file' objects}
5/1 0.027 0.005 43.488 43.488 graph-depends:164(get_all_depends)
5 0.003 0.001 43.458 8.692 graph-depends:135(get_depends)
1 0.001 0.001 25.712 25.712 graph-depends:98(get_version)
1 0.001 0.001 13.457 13.457 graph-depends:337(remove_extra_deps)
1717 1.672 0.001 13.050 0.008 graph-depends:290(remove_transitive_deps)
9784086/2672326 5.079 0.000 11.363 0.000 graph-depends:274(is_dep)
2883343/1980154 2.650 0.000 6.942 0.000 graph-depends:262(is_dep_uncached)
1 0.000 0.000 4.529 4.529 graph-depends:121(get_targets)
2883343 1.123 0.000 1.851 0.000 graph-depends:246(is_dep_cache_insert)
9784086 1.783 0.000 1.783 0.000 graph-depends:255(is_dep_cache_lookup)
2881580 0.728 0.000 0.728 0.000 {method 'update' of 'dict' objects}
1 0.001 0.001 0.405 0.405 graph-depends:311(check_circular_deps)
12264/1717 0.290 0.000 0.404 0.000 graph-depends:312(recurse)
[...]
real 1m27.371s
user 1m15.075s
sys 0m12.673s
The cumulative time spent in check_circular_deps is just below 0.5s,
which is largely less than 1% of the total run time.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-02-07 22:34:27 +01:00
|
|
|
return
|
|
|
|
if pkg in not_loop:
|
|
|
|
return
|
|
|
|
not_loop.append(pkg)
|
|
|
|
chain.append(pkg)
|
|
|
|
for p in deps[pkg]:
|
|
|
|
if p in chain:
|
2018-04-01 21:14:48 +02:00
|
|
|
logging.warning("\nRecursion detected for : %s" % (p))
|
support/graph-depends: detect circular dependencies
Currently, if there is a circular dependency in the packages, the
graph-depends script just errors out with a Python RuntimeError which is
not caught, resulting in a very-long backtrace which does not provide
any hint as what the real issue is (even if "RuntimeError: maximum
recursion depth exceeded" is a pretty good hint at it).
We fix that by recursing the dependency chain of each package, until we
either end up with a package with no dependency, or with a package
already seen along the current dependency chain.
We need to introduce a new function, check_circular_deps(), because we
can't re-use the existing ones:
- remove_mandatory_deps() does not iterate,
- remove_transitive_deps() does iterate, but we do not call it for the
top-level package if it is not 'all'
- it does not make sense to use those functions anyway, as they were
not designed to _check_ but to _act_ on the dependency chain.
Since we've had time-related issues in the past, we do not want to
introduce yet another time-hog, so here are timings with the circular
dependency check:
$ time python -m cProfile -s cumtime support/scripts/graph-depends
[...]
28352654 function calls (20323050 primitive calls) in 87.292 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.012 0.012 87.292 87.292 graph-depends:24(<module>)
21 0.000 0.000 73.685 3.509 subprocess.py:473(_eintr_retry_call)
7 0.000 0.000 73.655 10.522 subprocess.py:768(communicate)
7 73.653 10.522 73.653 10.522 {method 'read' of 'file' objects}
5/1 0.027 0.005 43.488 43.488 graph-depends:164(get_all_depends)
5 0.003 0.001 43.458 8.692 graph-depends:135(get_depends)
1 0.001 0.001 25.712 25.712 graph-depends:98(get_version)
1 0.001 0.001 13.457 13.457 graph-depends:337(remove_extra_deps)
1717 1.672 0.001 13.050 0.008 graph-depends:290(remove_transitive_deps)
9784086/2672326 5.079 0.000 11.363 0.000 graph-depends:274(is_dep)
2883343/1980154 2.650 0.000 6.942 0.000 graph-depends:262(is_dep_uncached)
1 0.000 0.000 4.529 4.529 graph-depends:121(get_targets)
2883343 1.123 0.000 1.851 0.000 graph-depends:246(is_dep_cache_insert)
9784086 1.783 0.000 1.783 0.000 graph-depends:255(is_dep_cache_lookup)
2881580 0.728 0.000 0.728 0.000 {method 'update' of 'dict' objects}
1 0.001 0.001 0.405 0.405 graph-depends:311(check_circular_deps)
12264/1717 0.290 0.000 0.404 0.000 graph-depends:312(recurse)
[...]
real 1m27.371s
user 1m15.075s
sys 0m12.673s
The cumulative time spent in check_circular_deps is just below 0.5s,
which is largely less than 1% of the total run time.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-02-07 22:34:27 +01:00
|
|
|
while True:
|
|
|
|
_p = chain.pop()
|
2018-04-01 21:14:48 +02:00
|
|
|
logging.warning("which is a dependency of: %s" % (_p))
|
support/graph-depends: detect circular dependencies
Currently, if there is a circular dependency in the packages, the
graph-depends script just errors out with a Python RuntimeError which is
not caught, resulting in a very-long backtrace which does not provide
any hint as what the real issue is (even if "RuntimeError: maximum
recursion depth exceeded" is a pretty good hint at it).
We fix that by recursing the dependency chain of each package, until we
either end up with a package with no dependency, or with a package
already seen along the current dependency chain.
We need to introduce a new function, check_circular_deps(), because we
can't re-use the existing ones:
- remove_mandatory_deps() does not iterate,
- remove_transitive_deps() does iterate, but we do not call it for the
top-level package if it is not 'all'
- it does not make sense to use those functions anyway, as they were
not designed to _check_ but to _act_ on the dependency chain.
Since we've had time-related issues in the past, we do not want to
introduce yet another time-hog, so here are timings with the circular
dependency check:
$ time python -m cProfile -s cumtime support/scripts/graph-depends
[...]
28352654 function calls (20323050 primitive calls) in 87.292 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.012 0.012 87.292 87.292 graph-depends:24(<module>)
21 0.000 0.000 73.685 3.509 subprocess.py:473(_eintr_retry_call)
7 0.000 0.000 73.655 10.522 subprocess.py:768(communicate)
7 73.653 10.522 73.653 10.522 {method 'read' of 'file' objects}
5/1 0.027 0.005 43.488 43.488 graph-depends:164(get_all_depends)
5 0.003 0.001 43.458 8.692 graph-depends:135(get_depends)
1 0.001 0.001 25.712 25.712 graph-depends:98(get_version)
1 0.001 0.001 13.457 13.457 graph-depends:337(remove_extra_deps)
1717 1.672 0.001 13.050 0.008 graph-depends:290(remove_transitive_deps)
9784086/2672326 5.079 0.000 11.363 0.000 graph-depends:274(is_dep)
2883343/1980154 2.650 0.000 6.942 0.000 graph-depends:262(is_dep_uncached)
1 0.000 0.000 4.529 4.529 graph-depends:121(get_targets)
2883343 1.123 0.000 1.851 0.000 graph-depends:246(is_dep_cache_insert)
9784086 1.783 0.000 1.783 0.000 graph-depends:255(is_dep_cache_lookup)
2881580 0.728 0.000 0.728 0.000 {method 'update' of 'dict' objects}
1 0.001 0.001 0.405 0.405 graph-depends:311(check_circular_deps)
12264/1717 0.290 0.000 0.404 0.000 graph-depends:312(recurse)
[...]
real 1m27.371s
user 1m15.075s
sys 0m12.673s
The cumulative time spent in check_circular_deps is just below 0.5s,
which is largely less than 1% of the total run time.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-02-07 22:34:27 +01:00
|
|
|
if p == _p:
|
|
|
|
sys.exit(1)
|
|
|
|
recurse(p)
|
|
|
|
chain.pop()
|
|
|
|
|
|
|
|
not_loop = []
|
|
|
|
chain = []
|
|
|
|
for pkg in list(deps.keys()):
|
|
|
|
recurse(pkg)
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2014-06-08 16:03:46 +02:00
|
|
|
# This functions trims down the dependency list of all packages.
|
2014-06-08 16:03:47 +02:00
|
|
|
# It applies in sequence all the dependency-elimination methods.
|
support/graph-depends: don't eliminate mandatory deps for reverse graphs
We we simplify the dependency graph, we try to remove so-called
mandatory dependencies from each package, and for each mandatory that
was thus removed, reattach it to the root-package of the graph.
This was made so that mandatory dependencies (which are dependencies of
all packages, or at least of a lot of packages) do not clutter the
dependency graph, but that they are still shown in the graph, as
dependencies of the root package.
However, these mandatory dependencies are only _direct_ dependencies.
As such, it does not make sense to reattach a mandatory dependency when
doing a reverse graph. Worse, it can actually be incorrect.
For example, 'skeleton' is a mandatory dependency, and as such is
removed from all packages. But when doing a reverse graph, skeleton is
now in the dependency chain of, e.g. skeleton-init-none; it should then
not be removed.
In short: the notion of mandatory dependencies does not make sense in
the case of a reverse graph.
Consequently, skip over the mandatory dependency removal when doing a
reverse graph.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:06 +01:00
|
|
|
def remove_extra_deps(deps, rootpkg, transitive, arrow_dir):
|
|
|
|
# For the direct dependencies, find and eliminate mandatory
|
|
|
|
# deps, and add them to the root package. Don't do it for a
|
|
|
|
# reverse graph, because mandatory deps are only direct deps.
|
|
|
|
if arrow_dir == "forward":
|
|
|
|
for pkg in list(deps.keys()):
|
|
|
|
if not pkg == rootpkg:
|
|
|
|
for d in get_mandatory_deps(pkg, deps):
|
|
|
|
if d not in deps[rootpkg]:
|
|
|
|
deps[rootpkg].append(d)
|
|
|
|
deps[pkg] = remove_mandatory_deps(pkg, deps)
|
2014-06-20 22:34:07 +02:00
|
|
|
for pkg in list(deps.keys()):
|
2018-12-02 10:04:34 +01:00
|
|
|
if not transitive or pkg == rootpkg:
|
2018-01-22 01:44:29 +01:00
|
|
|
deps[pkg] = remove_transitive_deps(pkg, deps)
|
2014-06-08 16:03:46 +02:00
|
|
|
return deps
|
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
2014-04-13 22:42:39 +02:00
|
|
|
# Print the attributes of a node: label and fill-color
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
def print_attrs(outfile, pkg, pkg_type, pkg_version, depth, colors):
|
2014-06-08 16:03:45 +02:00
|
|
|
name = pkg_node_name(pkg)
|
2010-05-06 10:09:14 +02:00
|
|
|
if pkg == 'all':
|
2014-06-08 16:03:45 +02:00
|
|
|
label = 'ALL'
|
|
|
|
else:
|
|
|
|
label = pkg
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
if depth == 0:
|
|
|
|
color = colors[0]
|
2010-05-06 10:09:14 +02:00
|
|
|
else:
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
if pkg_type == "host":
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
color = colors[2]
|
2014-06-08 16:03:45 +02:00
|
|
|
else:
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
color = colors[1]
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
if pkg_version == "virtual":
|
2016-02-07 22:34:25 +01:00
|
|
|
outfile.write("%s [label = <<I>%s</I>>]\n" % (name, label))
|
2015-01-03 15:29:12 +01:00
|
|
|
else:
|
2016-02-07 22:34:25 +01:00
|
|
|
outfile.write("%s [label = \"%s\"]\n" % (name, label))
|
|
|
|
outfile.write("%s [color=%s,style=filled]\n" % (name, color))
|
2010-05-06 10:09:14 +02:00
|
|
|
|
2018-01-22 01:44:29 +01:00
|
|
|
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
done_deps = []
|
|
|
|
|
|
|
|
|
2014-04-13 22:42:39 +02:00
|
|
|
# Print the dependency graph of a package
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
def print_pkg_deps(outfile, dict_deps, dict_types, dict_versions, stop_list, exclude_list,
|
2018-03-31 18:35:42 +02:00
|
|
|
arrow_dir, draw_graph, depth, max_depth, pkg, colors):
|
2014-04-13 22:42:39 +02:00
|
|
|
if pkg in done_deps:
|
|
|
|
return
|
|
|
|
done_deps.append(pkg)
|
2018-03-31 18:35:42 +02:00
|
|
|
if draw_graph:
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
print_attrs(outfile, pkg, dict_types[pkg], dict_versions[pkg], depth, colors)
|
2018-03-31 18:35:42 +02:00
|
|
|
elif depth != 0:
|
|
|
|
outfile.write("%s " % pkg)
|
2014-06-20 22:34:07 +02:00
|
|
|
if pkg not in dict_deps:
|
2014-04-13 22:42:39 +02:00
|
|
|
return
|
2015-03-24 23:16:49 +01:00
|
|
|
for p in stop_list:
|
|
|
|
if fnmatch(pkg, p):
|
|
|
|
return
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
if dict_versions[pkg] == "virtual" and "virtual" in stop_list:
|
2015-03-24 23:16:48 +01:00
|
|
|
return
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
if dict_types[pkg] == "host" and "host" in stop_list:
|
2016-01-27 21:32:14 +01:00
|
|
|
return
|
2014-04-13 22:42:39 +02:00
|
|
|
if max_depth == 0 or depth < max_depth:
|
|
|
|
for d in dict_deps[pkg]:
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
if dict_versions[d] == "virtual" and "virtual" in exclude_list:
|
2016-01-27 21:32:13 +01:00
|
|
|
continue
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
if dict_types[d] == "host" and "host" in exclude_list:
|
2016-01-27 21:32:14 +01:00
|
|
|
continue
|
2015-03-24 23:16:50 +01:00
|
|
|
add = True
|
|
|
|
for p in exclude_list:
|
2018-01-22 01:44:29 +01:00
|
|
|
if fnmatch(d, p):
|
2015-03-24 23:16:50 +01:00
|
|
|
add = False
|
|
|
|
break
|
|
|
|
if add:
|
2018-03-31 18:35:42 +02:00
|
|
|
if draw_graph:
|
|
|
|
outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir))
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
print_pkg_deps(outfile, dict_deps, dict_types, dict_versions, stop_list, exclude_list,
|
2018-03-31 18:35:42 +02:00
|
|
|
arrow_dir, draw_graph, depth + 1, max_depth, d, colors)
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description="Graph packages dependencies")
|
|
|
|
parser.add_argument("--check-only", "-C", dest="check_only", action="store_true", default=False,
|
|
|
|
help="Only do the dependency checks (circular deps...)")
|
|
|
|
parser.add_argument("--outfile", "-o", metavar="OUT_FILE", dest="outfile",
|
|
|
|
help="File in which to generate the dot representation")
|
|
|
|
parser.add_argument("--package", '-p', metavar="PACKAGE",
|
|
|
|
help="Graph the dependencies of PACKAGE")
|
|
|
|
parser.add_argument("--depth", '-d', metavar="DEPTH", dest="depth", type=int, default=0,
|
|
|
|
help="Limit the dependency graph to DEPTH levels; 0 means no limit.")
|
|
|
|
parser.add_argument("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append",
|
|
|
|
help="Do not graph past this package (can be given multiple times)." +
|
|
|
|
" Can be a package name or a glob, " +
|
|
|
|
" 'virtual' to stop on virtual packages, or " +
|
|
|
|
"'host' to stop on host packages.")
|
|
|
|
parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append",
|
|
|
|
help="Like --stop-on, but do not add PACKAGE to the graph.")
|
2019-03-03 11:16:30 +01:00
|
|
|
parser.add_argument("--exclude-mandatory", "-X", action="store_true",
|
|
|
|
help="Like if -x was passed for all mandatory dependencies.")
|
2018-03-31 18:35:40 +02:00
|
|
|
parser.add_argument("--colors", "-c", metavar="COLOR_LIST", dest="colors",
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
default="lightblue,grey,gainsboro",
|
2018-03-31 18:35:40 +02:00
|
|
|
help="Comma-separated list of the three colors to use" +
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
" to draw the top-level package, the target" +
|
|
|
|
" packages, and the host packages, in this order." +
|
|
|
|
" Defaults to: 'lightblue,grey,gainsboro'")
|
|
|
|
parser.add_argument("--transitive", dest="transitive", action='store_true',
|
|
|
|
default=False)
|
|
|
|
parser.add_argument("--no-transitive", dest="transitive", action='store_false',
|
|
|
|
help="Draw (do not draw) transitive dependencies")
|
|
|
|
parser.add_argument("--direct", dest="direct", action='store_true', default=True,
|
|
|
|
help="Draw direct dependencies (the default)")
|
|
|
|
parser.add_argument("--reverse", dest="direct", action='store_false',
|
|
|
|
help="Draw reverse dependencies")
|
2018-04-01 21:14:49 +02:00
|
|
|
parser.add_argument("--quiet", '-q', dest="quiet", action='store_true',
|
|
|
|
help="Quiet")
|
2018-03-31 18:35:42 +02:00
|
|
|
parser.add_argument("--flat-list", '-f', dest="flat_list", action='store_true', default=False,
|
|
|
|
help="Do not draw graph, just print a flat list")
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
args = parse_args()
|
|
|
|
|
|
|
|
check_only = args.check_only
|
|
|
|
|
2018-04-01 21:14:48 +02:00
|
|
|
logging.basicConfig(stream=sys.stderr, format='%(message)s',
|
2018-04-01 21:14:49 +02:00
|
|
|
level=logging.WARNING if args.quiet else logging.INFO)
|
2018-04-01 21:14:48 +02:00
|
|
|
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
if args.outfile is None:
|
|
|
|
outfile = sys.stdout
|
|
|
|
else:
|
|
|
|
if check_only:
|
2018-04-01 21:14:48 +02:00
|
|
|
logging.error("don't specify outfile and check-only at the same time")
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
sys.exit(1)
|
|
|
|
outfile = open(args.outfile, "w")
|
2018-01-22 01:44:29 +01:00
|
|
|
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
if args.package is None:
|
|
|
|
mode = MODE_FULL
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
rootpkg = 'all'
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
else:
|
|
|
|
mode = MODE_PKG
|
|
|
|
rootpkg = args.package
|
2014-04-13 22:42:39 +02:00
|
|
|
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
if args.stop_list is None:
|
|
|
|
stop_list = []
|
|
|
|
else:
|
|
|
|
stop_list = args.stop_list
|
|
|
|
|
|
|
|
if args.exclude_list is None:
|
|
|
|
exclude_list = []
|
|
|
|
else:
|
|
|
|
exclude_list = args.exclude_list
|
|
|
|
|
2019-03-03 11:16:30 +01:00
|
|
|
if args.exclude_mandatory:
|
|
|
|
exclude_list += MANDATORY_DEPS
|
|
|
|
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
if args.direct:
|
|
|
|
arrow_dir = "forward"
|
|
|
|
else:
|
|
|
|
if mode == MODE_FULL:
|
2018-04-01 21:14:48 +02:00
|
|
|
logging.error("--reverse needs a package")
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
sys.exit(1)
|
|
|
|
arrow_dir = "back"
|
|
|
|
|
2018-03-31 18:35:42 +02:00
|
|
|
draw_graph = not args.flat_list
|
|
|
|
|
2018-03-31 18:35:40 +02:00
|
|
|
# Get the colors: we need exactly three colors,
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
# so no need not split more than 4
|
2018-03-31 18:35:40 +02:00
|
|
|
# We'll let 'dot' validate the colors...
|
|
|
|
colors = args.colors.split(',', 4)
|
|
|
|
if len(colors) != 3:
|
2018-04-01 21:14:48 +02:00
|
|
|
logging.error("Error: incorrect color list '%s'" % args.colors)
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
deps, rdeps, dict_types, dict_versions = brpkgutil.get_dependency_tree()
|
|
|
|
dict_deps = deps if args.direct else rdeps
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
|
|
|
|
check_circular_deps(dict_deps)
|
|
|
|
if check_only:
|
|
|
|
sys.exit(0)
|
|
|
|
|
support/graph-depends: don't eliminate mandatory deps for reverse graphs
We we simplify the dependency graph, we try to remove so-called
mandatory dependencies from each package, and for each mandatory that
was thus removed, reattach it to the root-package of the graph.
This was made so that mandatory dependencies (which are dependencies of
all packages, or at least of a lot of packages) do not clutter the
dependency graph, but that they are still shown in the graph, as
dependencies of the root package.
However, these mandatory dependencies are only _direct_ dependencies.
As such, it does not make sense to reattach a mandatory dependency when
doing a reverse graph. Worse, it can actually be incorrect.
For example, 'skeleton' is a mandatory dependency, and as such is
removed from all packages. But when doing a reverse graph, skeleton is
now in the dependency chain of, e.g. skeleton-init-none; it should then
not be removed.
In short: the notion of mandatory dependencies does not make sense in
the case of a reverse graph.
Consequently, skip over the mandatory dependency removal when doing a
reverse graph.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:06 +01:00
|
|
|
dict_deps = remove_extra_deps(dict_deps, rootpkg, args.transitive, arrow_dir)
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
|
|
|
|
# Start printing the graph data
|
2018-03-31 18:35:42 +02:00
|
|
|
if draw_graph:
|
|
|
|
outfile.write("digraph G {\n")
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
|
support/graph-depends: use the new make-based dependency tree
Now that we can get the whole dependency tree from make, use it to
speed up things considerably.
So far, we had three functions to get the dependencies information:
get_depends(), get_rdepends(), and, somehow unrelated, get_version().
Because of the way %-show-{,r}depends works, getting the dependency tree
was expensive, the three functions all took a set of packages for which
to get the dependencies, in an attempt to limit the time it took to get
that tree, but we still had to call these functions iteratively, until
they returned no new dependency. This was pretty costly.
Now, getting the tree is much, much less costly, and we can get the
whole tree as cheaply as we previously got only the first-level
dependencies.
Furthermore, we can now also get the version information at the same
time, and that also brings in whether the package is virtual or not,
target or host.
So, we drop all three helper functions, and replace them with a single
one that returns all that information in one go: full dependency trees
(direct and reverse), per-package type, and per-package version.
Note: since commit 2d29fd96a (pkg-virtual: remove VERSION/SOURCE),
virtual packages are no longer reported as having a 'virtual' version,
so have since been displayed as regular packages in the graphs. Although
noone complained, this patch incidentally restores the initial
behaviour, and virtual packages are now correctly displayed as such
again.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-22 22:07:07 +01:00
|
|
|
print_pkg_deps(outfile, dict_deps, dict_types, dict_versions, stop_list, exclude_list,
|
2018-03-31 18:35:42 +02:00
|
|
|
arrow_dir, draw_graph, 0, args.depth, rootpkg, colors)
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
|
2018-03-31 18:35:42 +02:00
|
|
|
if draw_graph:
|
|
|
|
outfile.write("}\n")
|
|
|
|
else:
|
|
|
|
outfile.write("\n")
|
2014-04-13 22:42:39 +02:00
|
|
|
|
|
|
|
|
support/scripts/graph-depends: remove global code and most global variables
The graph-depends script had no main() function, and the main code was
actually spread between the function definitions, which was a real
mess.
This commit moves the global code into a main() function, which allows
to more easily follow the flow of the script. The argument parsing
code is moved into a parse_args() function.
Most of the global variables are removed, and are instead passed as
argument when appropriate. This has the side-effect that the
print_pkg_deps() function takes a lot of argument, but this is
considered better than tons of global variables.
The global variables that are removed are: max_depth, transitive,
mode, root_colour, target_colour, host_colour, outfile, dict_deps,
dict_version, stop_list, exclude_list, arrow_dir.
The root_colour/target_colour/host_colour variables are entirely
removed, and instead a single colours array is passed, and it's the
function using the colors that actually uses the different entries in
the array.
The way the print_attrs() function determines if we're display the
root node is not is changed. Instead of relying on the package name
and the mode (which requires passing the root package name, and the
mode), it relies on the depth: when the depth is 0, we're at the root
node.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 18:35:39 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|