summaryrefslogtreecommitdiff
path: root/tools/binman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-01-10 06:14:08 +0300
committerSimon Glass <sjg@chromium.org>2022-01-25 22:36:11 +0300
commit359e431cbc1d956b65b6b6bc86b7f3f88fc15927 (patch)
treec1b97b995b95abb618eca576c4449df90668b6b7 /tools/binman
parent4cd4ee04320b421c3e30e4c8b3dd8cdf0f986ec1 (diff)
downloadu-boot-359e431cbc1d956b65b6b6bc86b7f3f88fc15927.tar.xz
binman: Convert to using the lzma_alone bintool
Update the code to use this bintool, instead of running lzma_alone directly. This simplifies the code and provides more consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman')
-rw-r--r--tools/binman/comp_util.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py
index baa29798be..2f78bab9bb 100644
--- a/tools/binman/comp_util.py
+++ b/tools/binman/comp_util.py
@@ -12,6 +12,9 @@ from patman import tools
LZ4 = bintool.Bintool.create('lz4')
HAVE_LZ4 = LZ4.is_present()
+LZMA_ALONE = bintool.Bintool.create('lzma_alone')
+HAVE_LZMA_ALONE = LZMA_ALONE.is_present()
+
def compress(indata, algo, with_header=True):
"""Compress some data using a given algorithm
@@ -41,11 +44,7 @@ def compress(indata, algo, with_header=True):
data = LZ4.compress(indata)
# cbfstool uses a very old version of lzma
elif algo == 'lzma':
- outfname = tempfile.NamedTemporaryFile(prefix='%s.comp.otmp' % algo,
- dir=tools.GetOutputDir()).name
- tools.Run('lzma_alone', 'e', fname, outfname, '-lc1', '-lp0', '-pb0',
- '-d8')
- data = tools.ReadFile(outfname)
+ data = LZMA_ALONE.compress(indata)
elif algo == 'gzip':
data = tools.Run('gzip', '-c', fname, binary=True)
else:
@@ -81,9 +80,7 @@ def decompress(indata, algo, with_header=True):
if algo == 'lz4':
data = LZ4.decompress(indata)
elif algo == 'lzma':
- outfname = tools.GetOutputFilename('%s.decomp.otmp' % algo)
- tools.Run('lzma_alone', 'd', fname, outfname)
- data = tools.ReadFile(outfname, binary=True)
+ data = LZMA_ALONE.decompress(indata)
elif algo == 'gzip':
data = tools.Run('gzip', '-cd', fname, binary=True)
else: