bitbake-dumpsig 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  2. # bitbake-dumpsig
  3. # BitBake task signature dump utility
  4. #
  5. # Copyright (C) 2013 Intel Corporation
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License version 2 as
  9. # published by the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along
  17. # with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. import os
  20. import sys
  21. import warnings
  22. import optparse
  23. import logging
  24. sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
  25. import bb.siggen
  26. def logger_create(name, output=sys.stderr):
  27. logger = logging.getLogger(name)
  28. console = logging.StreamHandler(output)
  29. format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
  30. if output.isatty():
  31. format.enable_color()
  32. console.setFormatter(format)
  33. logger.addHandler(console)
  34. logger.setLevel(logging.INFO)
  35. return logger
  36. logger = logger_create('bitbake-dumpsig')
  37. parser = optparse.OptionParser(
  38. description = "Dumps siginfo/sigdata files written out by BitBake",
  39. usage = """
  40. %prog sigdatafile""")
  41. options, args = parser.parse_args(sys.argv)
  42. if len(args) == 1:
  43. parser.print_help()
  44. else:
  45. import cPickle
  46. try:
  47. output = bb.siggen.dump_sigfile(args[1])
  48. except IOError as e:
  49. logger.error(str(e))
  50. sys.exit(1)
  51. except cPickle.UnpicklingError, EOFError:
  52. logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file')
  53. sys.exit(1)
  54. if output:
  55. print '\n'.join(output)