diff options
Diffstat (limited to 'bitbake/bin/bitbake-dumpsig')
| l---------[-rwxr-xr-x] | bitbake/bin/bitbake-dumpsig | 95 |
1 files changed, 1 insertions, 94 deletions
diff --git a/bitbake/bin/bitbake-dumpsig b/bitbake/bin/bitbake-dumpsig index 95ebd93546..b1e8489b45 100755..120000 --- a/bitbake/bin/bitbake-dumpsig +++ b/bitbake/bin/bitbake-dumpsig | |||
| @@ -1,94 +1 @@ | |||
| 1 | #!/usr/bin/env python3 | bitbake-diffsigs \ No newline at end of file | |
| 2 | |||
| 3 | # bitbake-dumpsig | ||
| 4 | # BitBake task signature dump utility | ||
| 5 | # | ||
| 6 | # Copyright (C) 2013 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 | |||
| 21 | import os | ||
| 22 | import sys | ||
| 23 | import warnings | ||
| 24 | import optparse | ||
| 25 | import logging | ||
| 26 | import pickle | ||
| 27 | |||
| 28 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) | ||
| 29 | |||
| 30 | import bb.tinfoil | ||
| 31 | import bb.siggen | ||
| 32 | import bb.msg | ||
| 33 | |||
| 34 | logger = bb.msg.logger_create('bitbake-dumpsig') | ||
| 35 | |||
| 36 | def find_siginfo_task(bbhandler, pn, taskname): | ||
| 37 | """ Find the most recent signature file for the specified PN/task """ | ||
| 38 | |||
| 39 | if not hasattr(bb.siggen, 'find_siginfo'): | ||
| 40 | logger.error('Metadata does not support finding signature data files') | ||
| 41 | sys.exit(1) | ||
| 42 | |||
| 43 | if not taskname.startswith('do_'): | ||
| 44 | taskname = 'do_%s' % taskname | ||
| 45 | |||
| 46 | filedates = bb.siggen.find_siginfo(pn, taskname, None, bbhandler.config_data) | ||
| 47 | latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-1:] | ||
| 48 | if not latestfiles: | ||
| 49 | logger.error('No sigdata files found matching %s %s' % (pn, taskname)) | ||
| 50 | sys.exit(1) | ||
| 51 | |||
| 52 | return latestfiles[0] | ||
| 53 | |||
| 54 | parser = optparse.OptionParser( | ||
| 55 | description = "Dumps siginfo/sigdata files written out by BitBake", | ||
| 56 | usage = """ | ||
| 57 | %prog -t recipename taskname | ||
| 58 | %prog sigdatafile""") | ||
| 59 | |||
| 60 | parser.add_option("-D", "--debug", | ||
| 61 | help = "enable debug", | ||
| 62 | action = "store_true", dest="debug", default = False) | ||
| 63 | |||
| 64 | parser.add_option("-t", "--task", | ||
| 65 | help = "find the signature data file for the specified task", | ||
| 66 | action="store", dest="taskargs", nargs=2, metavar='recipename taskname') | ||
| 67 | |||
| 68 | options, args = parser.parse_args(sys.argv) | ||
| 69 | |||
| 70 | if options.debug: | ||
| 71 | logger.setLevel(logging.DEBUG) | ||
| 72 | |||
| 73 | if options.taskargs: | ||
| 74 | tinfoil = bb.tinfoil.Tinfoil() | ||
| 75 | tinfoil.prepare(config_only = True) | ||
| 76 | file = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1]) | ||
| 77 | logger.debug("Signature file: %s" % file) | ||
| 78 | elif len(args) == 1: | ||
| 79 | parser.print_help() | ||
| 80 | sys.exit(0) | ||
| 81 | else: | ||
| 82 | file = args[1] | ||
| 83 | |||
| 84 | try: | ||
| 85 | output = bb.siggen.dump_sigfile(file) | ||
| 86 | except IOError as e: | ||
| 87 | logger.error(str(e)) | ||
| 88 | sys.exit(1) | ||
| 89 | except (pickle.UnpicklingError, EOFError): | ||
| 90 | logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file') | ||
| 91 | sys.exit(1) | ||
| 92 | |||
| 93 | if output: | ||
| 94 | print('\n'.join(output)) | ||
