diff options
Diffstat (limited to 'bitbake/bin/bitbake-diffsigs')
-rwxr-xr-x | bitbake/bin/bitbake-diffsigs | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs index 19420a2df6..8202c78623 100755 --- a/bitbake/bin/bitbake-diffsigs +++ b/bitbake/bin/bitbake-diffsigs | |||
@@ -11,6 +11,8 @@ | |||
11 | import os | 11 | import os |
12 | import sys | 12 | import sys |
13 | import warnings | 13 | import warnings |
14 | |||
15 | warnings.simplefilter("default") | ||
14 | import argparse | 16 | import argparse |
15 | import logging | 17 | import logging |
16 | import pickle | 18 | import pickle |
@@ -26,6 +28,7 @@ logger = bb.msg.logger_create(myname) | |||
26 | 28 | ||
27 | is_dump = myname == 'bitbake-dumpsig' | 29 | is_dump = myname == 'bitbake-dumpsig' |
28 | 30 | ||
31 | |||
29 | def find_siginfo(tinfoil, pn, taskname, sigs=None): | 32 | def find_siginfo(tinfoil, pn, taskname, sigs=None): |
30 | result = None | 33 | result = None |
31 | tinfoil.set_event_mask(['bb.event.FindSigInfoResult', | 34 | tinfoil.set_event_mask(['bb.event.FindSigInfoResult', |
@@ -51,6 +54,7 @@ def find_siginfo(tinfoil, pn, taskname, sigs=None): | |||
51 | sys.exit(2) | 54 | sys.exit(2) |
52 | return result | 55 | return result |
53 | 56 | ||
57 | |||
54 | def find_siginfo_task(bbhandler, pn, taskname, sig1=None, sig2=None): | 58 | def find_siginfo_task(bbhandler, pn, taskname, sig1=None, sig2=None): |
55 | """ Find the most recent signature files for the specified PN/task """ | 59 | """ Find the most recent signature files for the specified PN/task """ |
56 | 60 | ||
@@ -59,22 +63,25 @@ def find_siginfo_task(bbhandler, pn, taskname, sig1=None, sig2=None): | |||
59 | 63 | ||
60 | if sig1 and sig2: | 64 | if sig1 and sig2: |
61 | sigfiles = find_siginfo(bbhandler, pn, taskname, [sig1, sig2]) | 65 | sigfiles = find_siginfo(bbhandler, pn, taskname, [sig1, sig2]) |
62 | if len(sigfiles) == 0: | 66 | if not sigfiles: |
63 | logger.error('No sigdata files found matching %s %s matching either %s or %s' % (pn, taskname, sig1, sig2)) | 67 | logger.error('No sigdata files found matching %s %s matching either %s or %s' % (pn, taskname, sig1, sig2)) |
64 | sys.exit(1) | 68 | sys.exit(1) |
65 | elif not sig1 in sigfiles: | 69 | elif sig1 not in sigfiles: |
66 | logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig1)) | 70 | logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig1)) |
67 | sys.exit(1) | 71 | sys.exit(1) |
68 | elif not sig2 in sigfiles: | 72 | elif sig2 not in sigfiles: |
69 | logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig2)) | 73 | logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig2)) |
70 | sys.exit(1) | 74 | sys.exit(1) |
71 | latestfiles = [sigfiles[sig1], sigfiles[sig2]] | ||
72 | else: | 75 | else: |
73 | filedates = find_siginfo(bbhandler, pn, taskname) | 76 | sigfiles = find_siginfo(bbhandler, pn, taskname) |
74 | latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-2:] | 77 | latestsigs = sorted(sigfiles.keys(), key=lambda h: sigfiles[h]['time'])[-2:] |
75 | if not latestfiles: | 78 | if not latestsigs: |
76 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) | 79 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) |
77 | sys.exit(1) | 80 | sys.exit(1) |
81 | sig1 = latestsigs[0] | ||
82 | sig2 = latestsigs[1] | ||
83 | |||
84 | latestfiles = [sigfiles[sig1]['path'], sigfiles[sig2]['path']] | ||
78 | 85 | ||
79 | return latestfiles | 86 | return latestfiles |
80 | 87 | ||
@@ -85,14 +92,14 @@ def recursecb(key, hash1, hash2): | |||
85 | hashfiles = find_siginfo(tinfoil, key, None, hashes) | 92 | hashfiles = find_siginfo(tinfoil, key, None, hashes) |
86 | 93 | ||
87 | recout = [] | 94 | recout = [] |
88 | if len(hashfiles) == 0: | 95 | if not hashfiles: |
89 | recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) | 96 | recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) |
90 | elif not hash1 in hashfiles: | 97 | elif hash1 not in hashfiles: |
91 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1)) | 98 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1)) |
92 | elif not hash2 in hashfiles: | 99 | elif hash2 not in hashfiles: |
93 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) | 100 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) |
94 | else: | 101 | else: |
95 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb, color=color) | 102 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1]['path'], hashfiles[hash2]['path'], recursecb, color=color) |
96 | for change in out2: | 103 | for change in out2: |
97 | for line in change.splitlines(): | 104 | for line in change.splitlines(): |
98 | recout.append(' ' + line) | 105 | recout.append(' ' + line) |
@@ -109,36 +116,36 @@ parser.add_argument('-D', '--debug', | |||
109 | 116 | ||
110 | if is_dump: | 117 | if is_dump: |
111 | parser.add_argument("-t", "--task", | 118 | parser.add_argument("-t", "--task", |
112 | help="find the signature data file for the last run of the specified task", | 119 | help="find the signature data file for the last run of the specified task", |
113 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) | 120 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) |
114 | 121 | ||
115 | parser.add_argument("sigdatafile1", | 122 | parser.add_argument("sigdatafile1", |
116 | help="Signature file to dump. Not used when using -t/--task.", | 123 | help="Signature file to dump. Not used when using -t/--task.", |
117 | action="store", nargs='?', metavar="sigdatafile") | 124 | action="store", nargs='?', metavar="sigdatafile") |
118 | else: | 125 | else: |
119 | parser.add_argument('-c', '--color', | 126 | parser.add_argument('-c', '--color', |
120 | help='Colorize the output (where %(metavar)s is %(choices)s)', | 127 | help='Colorize the output (where %(metavar)s is %(choices)s)', |
121 | choices=['auto', 'always', 'never'], default='auto', metavar='color') | 128 | choices=['auto', 'always', 'never'], default='auto', metavar='color') |
122 | 129 | ||
123 | parser.add_argument('-d', '--dump', | 130 | parser.add_argument('-d', '--dump', |
124 | help='Dump the last signature data instead of comparing (equivalent to using bitbake-dumpsig)', | 131 | help='Dump the last signature data instead of comparing (equivalent to using bitbake-dumpsig)', |
125 | action='store_true') | 132 | action='store_true') |
126 | 133 | ||
127 | parser.add_argument("-t", "--task", | 134 | parser.add_argument("-t", "--task", |
128 | help="find the signature data files for the last two runs of the specified task and compare them", | 135 | help="find the signature data files for the last two runs of the specified task and compare them", |
129 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) | 136 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) |
130 | 137 | ||
131 | parser.add_argument("-s", "--signature", | 138 | parser.add_argument("-s", "--signature", |
132 | help="With -t/--task, specify the signatures to look for instead of taking the last two", | 139 | help="With -t/--task, specify the signatures to look for instead of taking the last two", |
133 | action="store", dest="sigargs", nargs=2, metavar=('fromsig', 'tosig')) | 140 | action="store", dest="sigargs", nargs=2, metavar=('fromsig', 'tosig')) |
134 | 141 | ||
135 | parser.add_argument("sigdatafile1", | 142 | parser.add_argument("sigdatafile1", |
136 | help="First signature file to compare (or signature file to dump, if second not specified). Not used when using -t/--task.", | 143 | help="First signature file to compare (or signature file to dump, if second not specified). Not used when using -t/--task.", |
137 | action="store", nargs='?') | 144 | action="store", nargs='?') |
138 | 145 | ||
139 | parser.add_argument("sigdatafile2", | 146 | parser.add_argument("sigdatafile2", |
140 | help="Second signature file to compare", | 147 | help="Second signature file to compare", |
141 | action="store", nargs='?') | 148 | action="store", nargs='?') |
142 | 149 | ||
143 | options = parser.parse_args() | 150 | options = parser.parse_args() |
144 | if is_dump: | 151 | if is_dump: |
@@ -156,7 +163,8 @@ if options.taskargs: | |||
156 | with bb.tinfoil.Tinfoil() as tinfoil: | 163 | with bb.tinfoil.Tinfoil() as tinfoil: |
157 | tinfoil.prepare(config_only=True) | 164 | tinfoil.prepare(config_only=True) |
158 | if not options.dump and options.sigargs: | 165 | if not options.dump and options.sigargs: |
159 | files = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1], options.sigargs[0], options.sigargs[1]) | 166 | files = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1], options.sigargs[0], |
167 | options.sigargs[1]) | ||
160 | else: | 168 | else: |
161 | files = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1]) | 169 | files = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1]) |
162 | 170 | ||
@@ -165,7 +173,8 @@ if options.taskargs: | |||
165 | output = bb.siggen.dump_sigfile(files[-1]) | 173 | output = bb.siggen.dump_sigfile(files[-1]) |
166 | else: | 174 | else: |
167 | if len(files) < 2: | 175 | if len(files) < 2: |
168 | logger.error('Only one matching sigdata file found for the specified task (%s %s)' % (options.taskargs[0], options.taskargs[1])) | 176 | logger.error('Only one matching sigdata file found for the specified task (%s %s)' % ( |
177 | options.taskargs[0], options.taskargs[1])) | ||
169 | sys.exit(1) | 178 | sys.exit(1) |
170 | 179 | ||
171 | # Recurse into signature comparison | 180 | # Recurse into signature comparison |