summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-04-07 09:52:07 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-04-10 23:00:32 +0100
commite0eda80371b0ed46a77af722eefd3f6913c61c46 (patch)
treec9427c2842a071588cabd3bea00a1a0781c30fd6 /bitbake/bin
parent8c015e45fffe2cfb483c196e78554bfbd9cf66cc (diff)
downloadpoky-e0eda80371b0ed46a77af722eefd3f6913c61c46.tar.gz
bitbake: bitbake-diffsigs: change to use argparse
Argparse is a bit easier to deal with than optparse, and since we're about to add some options, migrate this script over. (Bitbake rev: 7f130e0b5ce6cfc6b35176465f260092cd3b3d64) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-diffsigs64
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
22import sys 22import sys
23import warnings 23import warnings
24import fnmatch 24import fnmatch
25import optparse 25import argparse
26import logging 26import logging
27import pickle 27import pickle
28 28
@@ -83,22 +83,27 @@ def find_compare_task(bbhandler, pn, taskname):
83 83
84 84
85 85
86parser = optparse.OptionParser( 86parser = 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
93parser.add_option("-D", "--debug", 89parser.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
97parser.add_option("-t", "--task", 93parser.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
101options, args = parser.parse_args(sys.argv) 97parser.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
101parser.add_argument("sigdatafile2",
102 help="Second signature file to compare",
103 action="store", nargs='?')
104
105
106options = parser.parse_args()
102 107
103if options.debug: 108if 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])
110else: 115else:
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))