[coreboot-gerrit] New patch to review for coreboot: dcf455e util/lzma_payload/squish.py: LZMA payload with header magics
Edward O'Callaghan (eocallaghan@alterapraxis.com)
gerrit at coreboot.org
Fri May 9 11:31:52 CEST 2014
Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5708
-gerrit
commit dcf455e8247b0900ce75c64cf1d1f9ee48c24ffb
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date: Fri May 9 19:28:50 2014 +1000
util/lzma_payload/squish.py: LZMA payload with header magics
SeaBIOS expects file-size information to be packed into the header of a
LZMA container before it will decompress it. Provide a little tool to do
that.
Change-Id: I26987357b21b6677dbfa013167824a6127270beb
Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
util/lzma_payload/squish.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/util/lzma_payload/squish.py b/util/lzma_payload/squish.py
new file mode 100755
index 0000000..f0329c0
--- /dev/null
+++ b/util/lzma_payload/squish.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+# This file is part of the coreboot project.
+# Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
+
+import sys
+import argparse
+import lzma
+import struct
+
+
+def compressor(infile, outfile):
+ lzc = lzma.LZMACompressor()
+ data = lzc.compress(infile.read())
+ size = len(infile.read())
+ data = data[:5] + struct.pack('<i', size) + data[9:]
+ outfile.write(data)
+
+
+def main(argv):
+ parser = argparse.ArgumentParser(
+ prog='squish',
+ description='''Compress a given file into LZMA package''',
+ epilog='''SeaBIOS expects a certain kind of LZMA compressed file
+ to unpack. This tool ensures correct header information
+ is provided.''',
+ usage='%(prog)s [options]')
+
+ parser.add_argument('-i', '--inputfile', nargs='?',
+ type=argparse.FileType('rb'),
+ default=sys.stdin,
+ help="file to be compressed")
+
+ parser.add_argument('-o', '--outputfile', nargs='?',
+ type=argparse.FileType('wb'),
+ default=sys.stdout,
+ help="compressed output name")
+ args = parser.parse_args()
+ compressor(args.inputfile, args.outputfile)
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
More information about the coreboot-gerrit
mailing list