63cb953d14
Previously, the flake8 script didn't help us to detect when Python scripts were incorrectly wrapped. Now, however, it does report such errors. Fix one such an error now. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com> Cc: Arnout Vandecappelle <arnout@mind.be> [Arnout: give commit message a more positive tone] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
# Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
|
# Copyright (C) 2019 Yann E. MORIN <yann.morin.1998@free.fr>
|
|
|
|
import logging
|
|
import os
|
|
import subprocess
|
|
from collections import defaultdict
|
|
|
|
|
|
# This function returns a tuple of four dictionaries, all using package
|
|
# names as keys:
|
|
# - a dictionary which values are the lists of packages that are the
|
|
# dependencies of the package used as key;
|
|
# - a dictionary which values are the lists of packages that are the
|
|
# reverse dependencies of the package used as key;
|
|
# - a dictionary which values are the type of the package used as key;
|
|
# - a dictionary which values are the version of the package used as key,
|
|
# 'virtual' for a virtual package, or the empty string for a rootfs.
|
|
def get_dependency_tree():
|
|
logging.info("Getting dependency tree...")
|
|
|
|
deps = defaultdict(list)
|
|
rdeps = defaultdict(list)
|
|
types = {}
|
|
versions = {}
|
|
|
|
# Special case for the 'all' top-level fake package
|
|
deps['all'] = []
|
|
types['all'] = 'target'
|
|
versions['all'] = ''
|
|
|
|
cmd = ["make", "-s", "--no-print-directory", "show-dependency-tree"]
|
|
with open(os.devnull, 'wb') as devnull:
|
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=devnull,
|
|
universal_newlines=True)
|
|
output = p.communicate()[0]
|
|
|
|
for l in output.splitlines():
|
|
if " -> " in l:
|
|
pkg = l.split(" -> ")[0]
|
|
deps[pkg] += l.split(" -> ")[1].split()
|
|
for p in l.split(" -> ")[1].split():
|
|
rdeps[p].append(pkg)
|
|
else:
|
|
pkg, type_version = l.split(": ", 1)
|
|
t, v = "{} -".format(type_version).split(None, 2)[:2]
|
|
deps['all'].append(pkg)
|
|
types[pkg] = t
|
|
versions[pkg] = v
|
|
|
|
return (deps, rdeps, types, versions)
|