blob: 58ba1cad049f12add65dae8256fa6e9ef5b61163 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/usr/bin/env python3
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
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
21import os
22import sys
23import warnings
24import optparse
25import logging
Patrick Williamsc0f7c042017-02-23 20:41:17 -060026import pickle
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
28sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
29
30import bb.siggen
31
32def logger_create(name, output=sys.stderr):
33 logger = logging.getLogger(name)
34 console = logging.StreamHandler(output)
35 format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
36 if output.isatty():
37 format.enable_color()
38 console.setFormatter(format)
39 logger.addHandler(console)
40 logger.setLevel(logging.INFO)
41 return logger
42
43logger = logger_create('bitbake-dumpsig')
44
45parser = optparse.OptionParser(
46 description = "Dumps siginfo/sigdata files written out by BitBake",
47 usage = """
48 %prog sigdatafile""")
49
50options, args = parser.parse_args(sys.argv)
51
52if len(args) == 1:
53 parser.print_help()
54else:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055 try:
56 output = bb.siggen.dump_sigfile(args[1])
57 except IOError as e:
58 logger.error(str(e))
59 sys.exit(1)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060060 except (pickle.UnpicklingError, EOFError):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file')
62 sys.exit(1)
63
64 if output:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060065 print('\n'.join(output))