summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2018-05-08 10:19:15 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-05-15 10:00:28 +0100
commit1115e06599751f776134674d93627cc381a06660 (patch)
treebe36baa19779d1e22e2cfe52fe6518cb755824b9 /scripts
parentf71bc69e5b7581c53071055b694bb0dbfe4b4a87 (diff)
downloadopenembedded-core-contrib-1115e06599751f776134674d93627cc381a06660.tar.gz
openembedded-core-contrib-1115e06599751f776134674d93627cc381a06660.tar.bz2
openembedded-core-contrib-1115e06599751f776134674d93627cc381a06660.zip
oe-depends-dot: print dependency chains for '--why' option
When using '--why' option, we currently only list elements. It's better to print out dependency chains. This patch adds such abitility. e.g. $ oe-depends-dot -k util-linux -w recipe-depends.dot Because: packagegroup-core-boot systemd-compat-units systemd shadow core-image-minimal dbus e2fsprogs core-image-minimal -> packagegroup-core-boot -> systemd-compat-units -> systemd -> dbus -> shadow -> util-linux core-image-minimal -> packagegroup-core-boot -> systemd-compat-units -> systemd -> dbus -> e2fsprogs -> util-linux Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/oe-depends-dot46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/oe-depends-dot b/scripts/oe-depends-dot
index 5cec23bf0a..6c7e9d3383 100755
--- a/scripts/oe-depends-dot
+++ b/scripts/oe-depends-dot
@@ -47,6 +47,51 @@ class Dot(object):
if len(sys.argv) != 3 and len(sys.argv) < 5:
print('ERROR: Not enough args, see --help for usage')
+ @staticmethod
+ def insert_dep_chain(chain, rdeps, alldeps):
+ """
+ insert elements to chain from rdeps, according to alldeps
+ """
+ # chain should at least contain one element
+ if len(chain) == 0:
+ raise
+
+ inserted_elements = []
+ for rdep in rdeps:
+ if rdep in chain:
+ continue
+ else:
+ for i in range(0, len(chain)-1):
+ if chain[i] in alldeps[rdep] and rdep in alldeps[chain[i+1]]:
+ chain.insert(i+1, rdep)
+ inserted_elements.append(rdep)
+ break
+ if chain[-1] in alldeps[rdep] and rdep not in chain:
+ chain.append(rdep)
+ inserted_elements.append(rdep)
+ return inserted_elements
+
+ @staticmethod
+ def print_dep_chains(key, rdeps, alldeps):
+ rlist = rdeps.copy()
+ chain = []
+ removed_rdeps = [] # hold rdeps removed from rlist
+
+ chain.append(key)
+ while (len(rlist) != 0):
+ # insert chain from rlist
+ inserted_elements = Dot.insert_dep_chain(chain, rlist, alldeps)
+ if not inserted_elements:
+ if chain[-1] in rlist:
+ rlist.remove(chain[-1])
+ removed_rdeps.append(chain[-1])
+ chain.pop()
+ continue
+ else:
+ # insert chain from removed_rdeps
+ Dot.insert_dep_chain(chain, removed_rdeps, alldeps)
+ print(' -> '.join(list(reversed(chain))))
+
def main(self):
#print(self.args.dotfile[0])
# The format is {key: depends}
@@ -109,6 +154,7 @@ class Dot(object):
if self.args.key in v and not k in reverse_deps:
reverse_deps.append(k)
print('Because: %s' % ' '.join(reverse_deps))
+ Dot.print_dep_chains(self.args.key, reverse_deps, depends)
if __name__ == "__main__":
try: