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>
This commit is contained in:
Yann E. MORIN 2019-03-22 22:07:06 +01:00 committed by Thomas Petazzoni
parent ad89bffed5
commit 893dde0102

View File

@ -216,13 +216,17 @@ def check_circular_deps(deps):
# This functions trims down the dependency list of all packages.
# It applies in sequence all the dependency-elimination methods.
def remove_extra_deps(deps, rootpkg, transitive):
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)
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)
for pkg in list(deps.keys()):
if not transitive or pkg == rootpkg:
deps[pkg] = remove_transitive_deps(pkg, deps)
@ -420,7 +424,7 @@ def main():
if check_only:
sys.exit(0)
dict_deps = remove_extra_deps(dict_deps, rootpkg, args.transitive)
dict_deps = remove_extra_deps(dict_deps, rootpkg, args.transitive, arrow_dir)
dict_version = brpkgutil.get_version([pkg for pkg in allpkgs
if pkg != "all" and not pkg.startswith("root")])