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.c...@windriver.com> --- scripts/oe-depends-dot | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/scripts/oe-depends-dot b/scripts/oe-depends-dot index 5cec23b..6c7e9d3 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: -- 1.9.1 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core