diff mbox series

[U-Boot,v2,25/37] binman: Use tools compression function for blob handling

Message ID 20190708191856.138863-26-sjg@chromium.org
State Accepted
Commit c444b1a54f139a8e3fa1fc9d60300b73573d455f
Delegated to: Simon Glass
Headers show
Series binman: Add CBFS support | expand

Commit Message

Simon Glass July 8, 2019, 7:18 p.m. UTC
Avoid duplicate code here by using the new compression function in the
tools module.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 tools/binman/etype/blob.py | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Comments

Simon Glass July 18, 2019, 1:59 a.m. UTC | #1
Avoid duplicate code here by using the new compression function in the
tools module.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 tools/binman/etype/blob.py | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index f56a1f87688..a91e7847009 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -49,18 +49,10 @@  class Entry_blob(Entry):
         # new Entry method which can read in chunks. Then we could copy
         # the data in chunks and avoid reading it all at once. For now
         # this seems like an unnecessary complication.
-        data = tools.ReadFile(self._pathname)
-        if self._compress == 'lz4':
-            self._uncompressed_size = len(data)
-            '''
-            import lz4  # Import this only if needed (python-lz4 dependency)
-
-            try:
-                data = lz4.frame.compress(data)
-            except AttributeError:
-                data = lz4.compress(data)
-            '''
-            data = tools.Run('lz4', '-c', self._pathname, binary=True)
+        indata = tools.ReadFile(self._pathname)
+        if self._compress != 'none':
+            self._uncompressed_size = len(indata)
+        data = tools.Compress(indata, self._compress)
         self.SetContents(data)
         return True