mirror of
https://xff.cz/git/u-boot/
synced 2025-09-26 04:51:17 +02:00
binman: Convert to using the lz4 bintool
Update the code to use this bintool, instead of running lz4 directly. This simplifies the code and provides more consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -19,6 +19,7 @@ import unittest
|
|||||||
from binman import bintool
|
from binman import bintool
|
||||||
from binman import cbfs_util
|
from binman import cbfs_util
|
||||||
from binman.cbfs_util import CbfsWriter
|
from binman.cbfs_util import CbfsWriter
|
||||||
|
from binman import comp_util
|
||||||
from binman import elf
|
from binman import elf
|
||||||
from patman import test_util
|
from patman import test_util
|
||||||
from patman import tools
|
from patman import tools
|
||||||
@@ -49,12 +50,7 @@ class TestCbfs(unittest.TestCase):
|
|||||||
cls.cbfstool = bintool.Bintool.create('cbfstool')
|
cls.cbfstool = bintool.Bintool.create('cbfstool')
|
||||||
cls.have_cbfstool = cls.cbfstool.is_present()
|
cls.have_cbfstool = cls.cbfstool.is_present()
|
||||||
|
|
||||||
cls.have_lz4 = True
|
cls.have_lz4 = comp_util.HAVE_LZ4
|
||||||
try:
|
|
||||||
tools.Run('lz4', '--no-frame-crc', '-c',
|
|
||||||
tools.GetInputFilename('u-boot.bin'), binary=True)
|
|
||||||
except:
|
|
||||||
cls.have_lz4 = False
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
@@ -6,8 +6,13 @@
|
|||||||
import struct
|
import struct
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from binman import bintool
|
||||||
from patman import tools
|
from patman import tools
|
||||||
|
|
||||||
|
LZ4 = bintool.Bintool.create('lz4')
|
||||||
|
HAVE_LZ4 = LZ4.is_present()
|
||||||
|
|
||||||
|
|
||||||
def compress(indata, algo, with_header=True):
|
def compress(indata, algo, with_header=True):
|
||||||
"""Compress some data using a given algorithm
|
"""Compress some data using a given algorithm
|
||||||
|
|
||||||
@@ -33,8 +38,7 @@ def compress(indata, algo, with_header=True):
|
|||||||
dir=tools.GetOutputDir()).name
|
dir=tools.GetOutputDir()).name
|
||||||
tools.WriteFile(fname, indata)
|
tools.WriteFile(fname, indata)
|
||||||
if algo == 'lz4':
|
if algo == 'lz4':
|
||||||
data = tools.Run('lz4', '--no-frame-crc', '-B4', '-5', '-c', fname,
|
data = LZ4.compress(indata)
|
||||||
binary=True)
|
|
||||||
# cbfstool uses a very old version of lzma
|
# cbfstool uses a very old version of lzma
|
||||||
elif algo == 'lzma':
|
elif algo == 'lzma':
|
||||||
outfname = tempfile.NamedTemporaryFile(prefix='%s.comp.otmp' % algo,
|
outfname = tempfile.NamedTemporaryFile(prefix='%s.comp.otmp' % algo,
|
||||||
@@ -75,7 +79,7 @@ def decompress(indata, algo, with_header=True):
|
|||||||
fname = tools.GetOutputFilename('%s.decomp.tmp' % algo)
|
fname = tools.GetOutputFilename('%s.decomp.tmp' % algo)
|
||||||
tools.WriteFile(fname, indata)
|
tools.WriteFile(fname, indata)
|
||||||
if algo == 'lz4':
|
if algo == 'lz4':
|
||||||
data = tools.Run('lz4', '-dc', fname, binary=True)
|
data = LZ4.decompress(indata)
|
||||||
elif algo == 'lzma':
|
elif algo == 'lzma':
|
||||||
outfname = tools.GetOutputFilename('%s.decomp.otmp' % algo)
|
outfname = tools.GetOutputFilename('%s.decomp.otmp' % algo)
|
||||||
tools.Run('lzma_alone', 'd', fname, outfname)
|
tools.Run('lzma_alone', 'd', fname, outfname)
|
||||||
|
@@ -197,13 +197,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
|
|
||||||
TestFunctional._MakeInputFile('env.txt', ENV_DATA)
|
TestFunctional._MakeInputFile('env.txt', ENV_DATA)
|
||||||
|
|
||||||
# Travis-CI may have an old lz4
|
cls.have_lz4 = comp_util.HAVE_LZ4
|
||||||
cls.have_lz4 = True
|
|
||||||
try:
|
|
||||||
tools.Run('lz4', '--no-frame-crc', '-c',
|
|
||||||
os.path.join(cls._indir, 'u-boot.bin'), binary=True)
|
|
||||||
except:
|
|
||||||
cls.have_lz4 = False
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
Reference in New Issue
Block a user