diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-04-07 09:52:08 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-04-10 23:00:32 +0100 |
commit | f79a969c3ae6449bf3a19ff3a55f4b3dbd81c6c2 (patch) | |
tree | 25d062622aa76ab61de015bb28f5c0f44ee70cb7 /bitbake | |
parent | e0eda80371b0ed46a77af722eefd3f6913c61c46 (diff) | |
download | poky-f79a969c3ae6449bf3a19ff3a55f4b3dbd81c6c2.tar.gz |
bitbake: bitbake-diffsigs: add an option to find and compare specific signatures
With the -t option which recurses to find the ultimate cause of a
signature change, it was hardcoded to take the last two executions of
the specified task. On the other hand, if you have two specific task
hashes (say from bitbake output, or some other tool) then you'll want to
pick those, so provide an option to specify those as well. (Note, the
new -s option needs to be specified alongside -t rather than instead of
it.)
(Bitbake rev: d9813b1a4223cf8dc80cab90e467ddf4bf8d1078)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/bin/bitbake-diffsigs | 95 |
1 files changed, 59 insertions, 36 deletions
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs index e3f848d0ed..e9fdb48993 100755 --- a/bitbake/bin/bitbake-diffsigs +++ b/bitbake/bin/bitbake-diffsigs | |||
@@ -34,7 +34,7 @@ import bb.msg | |||
34 | 34 | ||
35 | logger = bb.msg.logger_create('bitbake-diffsigs') | 35 | logger = bb.msg.logger_create('bitbake-diffsigs') |
36 | 36 | ||
37 | def find_compare_task(bbhandler, pn, taskname): | 37 | def find_compare_task(bbhandler, pn, taskname, sig1=None, sig2=None): |
38 | """ Find the most recent signature files for the specified PN/task and compare them """ | 38 | """ Find the most recent signature files for the specified PN/task and compare them """ |
39 | 39 | ||
40 | if not hasattr(bb.siggen, 'find_siginfo'): | 40 | if not hasattr(bb.siggen, 'find_siginfo'): |
@@ -44,41 +44,54 @@ def find_compare_task(bbhandler, pn, taskname): | |||
44 | if not taskname.startswith('do_'): | 44 | if not taskname.startswith('do_'): |
45 | taskname = 'do_%s' % taskname | 45 | taskname = 'do_%s' % taskname |
46 | 46 | ||
47 | filedates = bb.siggen.find_siginfo(pn, taskname, None, bbhandler.config_data) | 47 | if sig1 and sig2: |
48 | latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-3:] | 48 | sigfiles = bb.siggen.find_siginfo(pn, taskname, [sig1, sig2], bbhandler.config_data) |
49 | if not latestfiles: | 49 | if len(sigfiles) == 0: |
50 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) | 50 | logger.error('No sigdata files found matching %s %s matching either %s or %s' % (pn, taskname, sig1, sig2)) |
51 | sys.exit(1) | 51 | sys.exit(1) |
52 | elif len(latestfiles) < 2: | 52 | elif not sig1 in sigfiles: |
53 | logger.error('Only one matching sigdata file found for the specified task (%s %s)' % (pn, taskname)) | 53 | logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig1)) |
54 | sys.exit(1) | 54 | sys.exit(1) |
55 | elif not sig2 in sigfiles: | ||
56 | logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig2)) | ||
57 | sys.exit(1) | ||
58 | latestfiles = [sigfiles[sig1], sigfiles[sig2]] | ||
55 | else: | 59 | else: |
56 | # Define recursion callback | 60 | filedates = bb.siggen.find_siginfo(pn, taskname, None, bbhandler.config_data) |
57 | def recursecb(key, hash1, hash2): | 61 | latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-3:] |
58 | hashes = [hash1, hash2] | 62 | if not latestfiles: |
59 | hashfiles = bb.siggen.find_siginfo(key, None, hashes, bbhandler.config_data) | 63 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) |
60 | 64 | sys.exit(1) | |
61 | recout = [] | 65 | elif len(latestfiles) < 2: |
62 | if len(hashfiles) == 0: | 66 | logger.error('Only one matching sigdata file found for the specified task (%s %s)' % (pn, taskname)) |
63 | recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) | 67 | sys.exit(1) |
64 | elif not hash1 in hashfiles: | 68 | |
65 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1)) | 69 | # Define recursion callback |
66 | elif not hash2 in hashfiles: | 70 | def recursecb(key, hash1, hash2): |
67 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) | 71 | hashes = [hash1, hash2] |
68 | else: | 72 | hashfiles = bb.siggen.find_siginfo(key, None, hashes, bbhandler.config_data) |
69 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb) | 73 | |
70 | for change in out2: | 74 | recout = [] |
71 | for line in change.splitlines(): | 75 | if len(hashfiles) == 0: |
72 | recout.append(' ' + line) | 76 | recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) |
73 | 77 | elif not hash1 in hashfiles: | |
74 | return recout | 78 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1)) |
75 | 79 | elif not hash2 in hashfiles: | |
76 | # Recurse into signature comparison | 80 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) |
77 | logger.debug("Signature file (previous): %s" % latestfiles[-2]) | 81 | else: |
78 | logger.debug("Signature file (latest): %s" % latestfiles[-1]) | 82 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb) |
79 | output = bb.siggen.compare_sigfiles(latestfiles[-2], latestfiles[-1], recursecb) | 83 | for change in out2: |
80 | if output: | 84 | for line in change.splitlines(): |
81 | print('\n'.join(output)) | 85 | recout.append(' ' + line) |
86 | |||
87 | return recout | ||
88 | |||
89 | # Recurse into signature comparison | ||
90 | logger.debug("Signature file (previous): %s" % latestfiles[-2]) | ||
91 | logger.debug("Signature file (latest): %s" % latestfiles[-1]) | ||
92 | output = bb.siggen.compare_sigfiles(latestfiles[-2], latestfiles[-1], recursecb) | ||
93 | if output: | ||
94 | print('\n'.join(output)) | ||
82 | sys.exit(0) | 95 | sys.exit(0) |
83 | 96 | ||
84 | 97 | ||
@@ -94,6 +107,10 @@ parser.add_argument("-t", "--task", | |||
94 | help="find the signature data files for last two runs of the specified task and compare them", | 107 | help="find the signature data files for last two runs of the specified task and compare them", |
95 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) | 108 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) |
96 | 109 | ||
110 | parser.add_argument("-s", "--signature", | ||
111 | help="With -t/--task, specify the signatures to look for instead of taking the last two", | ||
112 | action="store", dest="sigargs", nargs=2, metavar=('fromsig', 'tosig')) | ||
113 | |||
97 | parser.add_argument("sigdatafile1", | 114 | parser.add_argument("sigdatafile1", |
98 | help="First signature file to compare (or signature file to dump, if second not specified). Not used when using -t/--task.", | 115 | help="First signature file to compare (or signature file to dump, if second not specified). Not used when using -t/--task.", |
99 | action="store", nargs='?') | 116 | action="store", nargs='?') |
@@ -111,8 +128,14 @@ if options.debug: | |||
111 | if options.taskargs: | 128 | if options.taskargs: |
112 | with bb.tinfoil.Tinfoil() as tinfoil: | 129 | with bb.tinfoil.Tinfoil() as tinfoil: |
113 | tinfoil.prepare(config_only=True) | 130 | tinfoil.prepare(config_only=True) |
114 | find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1]) | 131 | if options.sigargs: |
132 | find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1], options.sigargs[0], options.sigargs[1]) | ||
133 | else: | ||
134 | find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1]) | ||
115 | else: | 135 | else: |
136 | if options.sigargs: | ||
137 | logger.error('-s/--signature can only be used together with -t/--task') | ||
138 | sys.exit(1) | ||
116 | try: | 139 | try: |
117 | if options.sigdatafile1 and options.sigdatafile2: | 140 | if options.sigdatafile1 and options.sigdatafile2: |
118 | output = bb.siggen.compare_sigfiles(options.sigdatafile1, options.sigdatafile2) | 141 | output = bb.siggen.compare_sigfiles(options.sigdatafile1, options.sigdatafile2) |