diff options
Diffstat (limited to 'bitbake/bin/bitbake-diffsigs')
| -rwxr-xr-x | bitbake/bin/bitbake-diffsigs | 97 |
1 files changed, 92 insertions, 5 deletions
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs index 146cab8119..62f682748b 100755 --- a/bitbake/bin/bitbake-diffsigs +++ b/bitbake/bin/bitbake-diffsigs | |||
| @@ -1,15 +1,102 @@ | |||
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | |||
| 3 | # bitbake-diffsigs | ||
| 4 | # BitBake task signature data comparison utility | ||
| 5 | # | ||
| 6 | # Copyright (C) 2012 Intel Corporation | ||
| 7 | # | ||
| 8 | # This program is free software; you can redistribute it and/or modify | ||
| 9 | # it under the terms of the GNU General Public License version 2 as | ||
| 10 | # published by the Free Software Foundation. | ||
| 11 | # | ||
| 12 | # This program is distributed in the hope that it will be useful, | ||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | # GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | # You should have received a copy of the GNU General Public License along | ||
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | |||
| 2 | import os | 21 | import os |
| 3 | import sys | 22 | import sys |
| 4 | import warnings | 23 | import warnings |
| 24 | import fnmatch | ||
| 25 | import optparse | ||
| 26 | import logging | ||
| 27 | |||
| 5 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) | 28 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) |
| 6 | 29 | ||
| 30 | import bb.tinfoil | ||
| 7 | import bb.siggen | 31 | import bb.siggen |
| 8 | 32 | ||
| 9 | if len(sys.argv) > 2: | 33 | logger = logging.getLogger('BitBake') |
| 10 | output = bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2]) | 34 | |
| 35 | def find_compare_task(bbhandler, pn, taskname): | ||
| 36 | """ Find the most recent signature files for the specified PN/task and compare them """ | ||
| 37 | |||
| 38 | if not hasattr(bb.siggen, 'find_siginfo'): | ||
| 39 | logger.error('Metadata does not support finding signature data files') | ||
| 40 | sys.exit(1) | ||
| 41 | |||
| 42 | filedates = bb.siggen.find_siginfo(pn, taskname, None, bbhandler.config_data) | ||
| 43 | latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-2:] | ||
| 44 | if not latestfiles: | ||
| 45 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) | ||
| 46 | sys.exit(1) | ||
| 47 | elif len(latestfiles) < 2: | ||
| 48 | logger.error('Only one matching sigdata file found for the specified task (%s %s)' % (pn, taskname)) | ||
| 49 | sys.exit(1) | ||
| 50 | else: | ||
| 51 | # Define recursion callback | ||
| 52 | def recursecb(key, hash1, hash2): | ||
| 53 | hashes = [hash1, hash2] | ||
| 54 | hashfiles = bb.siggen.find_siginfo(key, None, hashes, bbhandler.config_data) | ||
| 55 | |||
| 56 | recout = [] | ||
| 57 | if len(hashfiles) == 2: | ||
| 58 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb) | ||
| 59 | recout.extend(list(' ' + l for l in out2)) | ||
| 60 | else: | ||
| 61 | recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) | ||
| 62 | |||
| 63 | return recout | ||
| 64 | |||
| 65 | # Recurse into signature comparison | ||
| 66 | output = bb.siggen.compare_sigfiles(latestfiles[0], latestfiles[1], recursecb) | ||
| 67 | if output: | ||
| 68 | print '\n'.join(output) | ||
| 69 | sys.exit(0) | ||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | parser = optparse.OptionParser( | ||
| 74 | usage = """ | ||
| 75 | %prog -t recipename taskname | ||
| 76 | %prog sigdatafile1 sigdatafile2 | ||
| 77 | %prog sigdatafile1""") | ||
| 78 | |||
| 79 | parser.add_option("-t", "--task", | ||
| 80 | help = "find the signature data files for last two runs of the specified task and compare them", | ||
| 81 | action="store_true", dest="taskmode") | ||
| 82 | |||
| 83 | options, args = parser.parse_args(sys.argv) | ||
| 84 | |||
| 85 | if len(args) == 1: | ||
| 86 | parser.print_help() | ||
| 11 | else: | 87 | else: |
| 12 | output = bb.siggen.dump_sigfile(sys.argv[1]) | 88 | tinfoil = bb.tinfoil.Tinfoil() |
| 89 | if options.taskmode: | ||
| 90 | if len(args) < 3: | ||
| 91 | logger.error("Please specify a recipe and task name") | ||
| 92 | sys.exit(1) | ||
| 93 | tinfoil.prepare(config_only = True) | ||
| 94 | find_compare_task(tinfoil, args[1], args[2]) | ||
| 95 | else: | ||
| 96 | if len(args) == 2: | ||
| 97 | output = bb.siggen.dump_sigfile(sys.argv[1]) | ||
| 98 | else: | ||
| 99 | output = bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2]) | ||
| 13 | 100 | ||
| 14 | if output: | 101 | if output: |
| 15 | print '\n'.join(output) | 102 | print '\n'.join(output) |
