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:56:49 +0100
commit20b0c638bac24a749ad7f87057a51e643cc7e5ec (patch)
tree2527c15cc7d2bfab282925970202d2f4bd06ef12 /scripts
parent970f12b7bbde4b8918904b53ee61237fa7e0157a (diff)
downloadpoky-20b0c638bac24a749ad7f87057a51e643cc7e5ec.tar.gz
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 (From OE-Core rev: 1115e06599751f776134674d93627cc381a06660) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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):
47 if len(sys.argv) != 3 and len(sys.argv) < 5: 47 if len(sys.argv) != 3 and len(sys.argv) < 5:
48 print('ERROR: Not enough args, see --help for usage') 48 print('ERROR: Not enough args, see --help for usage')
49 49
50 @staticmethod
51 def insert_dep_chain(chain, rdeps, alldeps):
52 """
53 insert elements to chain from rdeps, according to alldeps
54 """
55 # chain should at least contain one element
56 if len(chain) == 0:
57 raise
58
59 inserted_elements = []
60 for rdep in rdeps:
61 if rdep in chain:
62 continue
63 else:
64 for i in range(0, len(chain)-1):
65 if chain[i] in alldeps[rdep] and rdep in alldeps[chain[i+1]]:
66 chain.insert(i+1, rdep)
67 inserted_elements.append(rdep)
68 break
69 if chain[-1] in alldeps[rdep] and rdep not in chain:
70 chain.append(rdep)
71 inserted_elements.append(rdep)
72 return inserted_elements
73
74 @staticmethod
75 def print_dep_chains(key, rdeps, alldeps):
76 rlist = rdeps.copy()
77 chain = []
78 removed_rdeps = [] # hold rdeps removed from rlist
79
80 chain.append(key)
81 while (len(rlist) != 0):
82 # insert chain from rlist
83 inserted_elements = Dot.insert_dep_chain(chain, rlist, alldeps)
84 if not inserted_elements:
85 if chain[-1] in rlist:
86 rlist.remove(chain[-1])
87 removed_rdeps.append(chain[-1])
88 chain.pop()
89 continue
90 else:
91 # insert chain from removed_rdeps
92 Dot.insert_dep_chain(chain, removed_rdeps, alldeps)
93 print(' -> '.join(list(reversed(chain))))
94
50 def main(self): 95 def main(self):
51 #print(self.args.dotfile[0]) 96 #print(self.args.dotfile[0])
52 # The format is {key: depends} 97 # The format is {key: depends}
@@ -109,6 +154,7 @@ class Dot(object):
109 if self.args.key in v and not k in reverse_deps: 154 if self.args.key in v and not k in reverse_deps:
110 reverse_deps.append(k) 155 reverse_deps.append(k)
111 print('Because: %s' % ' '.join(reverse_deps)) 156 print('Because: %s' % ' '.join(reverse_deps))
157 Dot.print_dep_chains(self.args.key, reverse_deps, depends)
112 158
113if __name__ == "__main__": 159if __name__ == "__main__":
114 try: 160 try: