aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/entry.py
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2022-08-19 16:25:30 +0200
committerSimon Glass <sjg@chromium.org>2022-08-20 18:07:33 -0600
commitec7d27d3a83023af37e4fd42f67ec328d27b20c7 (patch)
treeda1f6bf5b23e6bee94086128832e2b3a341b7012 /tools/binman/entry.py
parentedafeb8da6b92957fdbb00d709a55ac62ec6d0d7 (diff)
binman: Move compression bintool management into entry class
Move management of the bintool to compress and decompress data into the entry class and add the bintool to the list of required bintools. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/entry.py')
-rw-r--r--tools/binman/entry.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index f448adbcfe..af8e277995 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -12,7 +12,6 @@ import sys
import time
from binman import bintool
-from binman import comp_util
from dtoc import fdt_util
from patman import tools
from patman.tools import to_hex, to_hex_size
@@ -83,6 +82,7 @@ class Entry(object):
missing_bintools: List of missing bintools for this entry
update_hash: True if this entry's "hash" subnode should be
updated with a hash of the entry contents
+ comp_bintool: Bintools used for compress and decompress data
fake_fname: Fake filename, if one was created, else None
required_props (dict of str): Properties which must be present. This can
be added to by subclasses
@@ -124,6 +124,7 @@ class Entry(object):
self.update_hash = True
self.fake_fname = None
self.required_props = []
+ self.comp_bintool = None
@staticmethod
def FindEntryClass(etype, expanded):
@@ -1117,7 +1118,9 @@ features to produce new behaviours.
self.uncomp_data = indata
if self.compress != 'none':
self.uncomp_size = len(indata)
- data = comp_util.compress(indata, self.compress)
+ data = self.comp_bintool.compress(indata)
+ else:
+ data = indata
return data
def DecompressData(self, indata):
@@ -1129,9 +1132,11 @@ features to produce new behaviours.
Returns:
Decompressed data
"""
- data = comp_util.decompress(indata, self.compress)
if self.compress != 'none':
+ data = self.comp_bintool.decompress(indata)
self.uncomp_size = len(data)
+ else:
+ data = indata
self.uncomp_data = data
return data
@@ -1172,8 +1177,18 @@ features to produce new behaviours.
Args:
btools (dict of Bintool):
+
+ Raise:
+ ValueError if compression algorithm is not supported
"""
- pass
+ algo = self.compress
+ if algo != 'none':
+ algos = ['lz4', 'lzma']
+ if algo not in algos:
+ raise ValueError("Unknown algorithm '%s'" % algo)
+ names = {'lzma': 'lzma_alone'}
+ name = names.get(self.compress, self.compress)
+ self.comp_bintool = self.AddBintool(btools, name)
@classmethod
def AddBintool(self, tools, name):