diff options
| author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2017-03-11 06:22:15 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-23 13:19:49 +0000 |
| commit | 82982d3d974f70970f334925648c83423e57371b (patch) | |
| tree | e6cc97be30da9340d113b7cba240ee76d441da08 | |
| parent | 99069699f1fd1f37f3fdc1435cae8ba702db65c9 (diff) | |
| download | poky-82982d3d974f70970f334925648c83423e57371b.tar.gz | |
bitbake: bitbake-dumpsig: Allow recipe and task to be specified
Use --task <recipe> <task> to dump the signature info for a given
recipe and task. This is similar to the --task option of
bitbake-diffsigs.
(Bitbake rev: bdc4356c7afc542b67b78e4e5225b813d7668ecd)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rwxr-xr-x | bitbake/bin/bitbake-dumpsig | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/bitbake/bin/bitbake-dumpsig b/bitbake/bin/bitbake-dumpsig index 58ba1cad04..b1fce2510d 100755 --- a/bitbake/bin/bitbake-dumpsig +++ b/bitbake/bin/bitbake-dumpsig | |||
| @@ -27,6 +27,7 @@ import pickle | |||
| 27 | 27 | ||
| 28 | 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')) |
| 29 | 29 | ||
| 30 | import bb.tinfoil | ||
| 30 | import bb.siggen | 31 | import bb.siggen |
| 31 | 32 | ||
| 32 | def logger_create(name, output=sys.stderr): | 33 | def logger_create(name, output=sys.stderr): |
| @@ -42,24 +43,54 @@ def logger_create(name, output=sys.stderr): | |||
| 42 | 43 | ||
| 43 | logger = logger_create('bitbake-dumpsig') | 44 | logger = logger_create('bitbake-dumpsig') |
| 44 | 45 | ||
| 46 | def find_siginfo_task(bbhandler, pn, taskname): | ||
| 47 | """ Find the most recent signature file for the specified PN/task """ | ||
| 48 | |||
| 49 | if not hasattr(bb.siggen, 'find_siginfo'): | ||
| 50 | logger.error('Metadata does not support finding signature data files') | ||
| 51 | sys.exit(1) | ||
| 52 | |||
| 53 | if not taskname.startswith('do_'): | ||
| 54 | taskname = 'do_%s' % taskname | ||
| 55 | |||
| 56 | filedates = bb.siggen.find_siginfo(pn, taskname, None, bbhandler.config_data) | ||
| 57 | latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-1:] | ||
| 58 | if not latestfiles: | ||
| 59 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) | ||
| 60 | sys.exit(1) | ||
| 61 | |||
| 62 | return latestfiles[0] | ||
| 63 | |||
| 45 | parser = optparse.OptionParser( | 64 | parser = optparse.OptionParser( |
| 46 | description = "Dumps siginfo/sigdata files written out by BitBake", | 65 | description = "Dumps siginfo/sigdata files written out by BitBake", |
| 47 | usage = """ | 66 | usage = """ |
| 67 | %prog -t recipename taskname | ||
| 48 | %prog sigdatafile""") | 68 | %prog sigdatafile""") |
| 49 | 69 | ||
| 70 | parser.add_option("-t", "--task", | ||
| 71 | help = "find the signature data file for the specified task", | ||
| 72 | action="store", dest="taskargs", nargs=2, metavar='recipename taskname') | ||
| 73 | |||
| 50 | options, args = parser.parse_args(sys.argv) | 74 | options, args = parser.parse_args(sys.argv) |
| 51 | 75 | ||
| 52 | if len(args) == 1: | 76 | if options.taskargs: |
| 77 | tinfoil = bb.tinfoil.Tinfoil() | ||
| 78 | tinfoil.prepare(config_only = True) | ||
| 79 | file = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1]) | ||
| 80 | elif len(args) == 1: | ||
| 53 | parser.print_help() | 81 | parser.print_help() |
| 82 | sys.exit(0) | ||
| 54 | else: | 83 | else: |
| 55 | try: | 84 | file = args[1] |
| 56 | output = bb.siggen.dump_sigfile(args[1]) | 85 | |
| 57 | except IOError as e: | 86 | try: |
| 58 | logger.error(str(e)) | 87 | output = bb.siggen.dump_sigfile(file) |
| 59 | sys.exit(1) | 88 | except IOError as e: |
| 60 | except (pickle.UnpicklingError, EOFError): | 89 | logger.error(str(e)) |
| 61 | logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file') | 90 | sys.exit(1) |
| 62 | sys.exit(1) | 91 | except (pickle.UnpicklingError, EOFError): |
| 92 | logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file') | ||
| 93 | sys.exit(1) | ||
| 63 | 94 | ||
| 64 | if output: | 95 | if output: |
| 65 | print('\n'.join(output)) | 96 | print('\n'.join(output)) |
