diff options
-rwxr-xr-x | bitbake/bin/bitbake-diffsigs | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs index 4ca085f073..e3f848d0ed 100755 --- a/bitbake/bin/bitbake-diffsigs +++ b/bitbake/bin/bitbake-diffsigs | |||
@@ -3,7 +3,7 @@ | |||
3 | # bitbake-diffsigs | 3 | # bitbake-diffsigs |
4 | # BitBake task signature data comparison utility | 4 | # BitBake task signature data comparison utility |
5 | # | 5 | # |
6 | # Copyright (C) 2012-2013 Intel Corporation | 6 | # Copyright (C) 2012-2013, 2017 Intel Corporation |
7 | # | 7 | # |
8 | # This program is free software; you can redistribute it and/or modify | 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 | 9 | # it under the terms of the GNU General Public License version 2 as |
@@ -22,7 +22,7 @@ import os | |||
22 | import sys | 22 | import sys |
23 | import warnings | 23 | import warnings |
24 | import fnmatch | 24 | import fnmatch |
25 | import optparse | 25 | import argparse |
26 | import logging | 26 | import logging |
27 | import pickle | 27 | import pickle |
28 | 28 | ||
@@ -83,22 +83,27 @@ def find_compare_task(bbhandler, pn, taskname): | |||
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | parser = optparse.OptionParser( | 86 | parser = argparse.ArgumentParser( |
87 | description = "Compares siginfo/sigdata files written out by BitBake", | 87 | description="Compares siginfo/sigdata files written out by BitBake") |
88 | usage = """ | ||
89 | %prog -t recipename taskname | ||
90 | %prog sigdatafile1 sigdatafile2 | ||
91 | %prog sigdatafile1""") | ||
92 | 88 | ||
93 | parser.add_option("-D", "--debug", | 89 | parser.add_argument('-d', '--debug', |
94 | help = "enable debug", | 90 | help='Enable debug output', |
95 | action = "store_true", dest="debug", default = False) | 91 | action='store_true') |
96 | 92 | ||
97 | parser.add_option("-t", "--task", | 93 | parser.add_argument("-t", "--task", |
98 | help = "find the signature data files for last two runs of the specified task and compare them", | 94 | help="find the signature data files for last two runs of the specified task and compare them", |
99 | action="store", dest="taskargs", nargs=2, metavar='recipename taskname') | 95 | action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) |
100 | 96 | ||
101 | options, args = parser.parse_args(sys.argv) | 97 | 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.", | ||
99 | action="store", nargs='?') | ||
100 | |||
101 | parser.add_argument("sigdatafile2", | ||
102 | help="Second signature file to compare", | ||
103 | action="store", nargs='?') | ||
104 | |||
105 | |||
106 | options = parser.parse_args() | ||
102 | 107 | ||
103 | if options.debug: | 108 | if options.debug: |
104 | logger.setLevel(logging.DEBUG) | 109 | logger.setLevel(logging.DEBUG) |
@@ -108,20 +113,17 @@ if options.taskargs: | |||
108 | tinfoil.prepare(config_only=True) | 113 | tinfoil.prepare(config_only=True) |
109 | find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1]) | 114 | find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1]) |
110 | else: | 115 | else: |
111 | if len(args) == 1: | 116 | try: |
112 | parser.print_help() | 117 | if options.sigdatafile1 and options.sigdatafile2: |
113 | else: | 118 | output = bb.siggen.compare_sigfiles(options.sigdatafile1, options.sigdatafile2) |
114 | try: | 119 | elif options.sigdatafile1: |
115 | if len(args) == 2: | 120 | output = bb.siggen.dump_sigfile(options.sigdatafile1) |
116 | output = bb.siggen.dump_sigfile(sys.argv[1]) | 121 | except IOError as e: |
117 | else: | 122 | logger.error(str(e)) |
118 | output = bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2]) | 123 | sys.exit(1) |
119 | except IOError as e: | 124 | except (pickle.UnpicklingError, EOFError): |
120 | logger.error(str(e)) | 125 | logger.error('Invalid signature data - ensure you are specifying sigdata/siginfo files') |
121 | sys.exit(1) | 126 | sys.exit(1) |
122 | except (pickle.UnpicklingError, EOFError): | ||
123 | logger.error('Invalid signature data - ensure you are specifying sigdata/siginfo files') | ||
124 | sys.exit(1) | ||
125 | 127 | ||
126 | if output: | 128 | if output: |
127 | print('\n'.join(output)) | 129 | print('\n'.join(output)) |