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