
From: Stefan Herbrechtsmeier stefan.herbrechtsmeier@weidmueller.com
Add lzop bintool to binman to support on-the-fly compression.
Signed-off-by: Stefan Herbrechtsmeier stefan.herbrechtsmeier@weidmueller.com
---
Changes in v2: - Added
tools/binman/btool/lzop.py | 30 ++++++++++++++++++++++++++++++ tools/binman/comp_util.py | 18 ++++++++++-------- 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 tools/binman/btool/lzop.py
diff --git a/tools/binman/btool/lzop.py b/tools/binman/btool/lzop.py new file mode 100644 index 0000000000..f6903b4db7 --- /dev/null +++ b/tools/binman/btool/lzop.py @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (C) 2022 Weidmüller Interface GmbH & Co. KG +# Stefan Herbrechtsmeier stefan.herbrechtsmeier@weidmueller.com +# +"""Bintool implementation for lzop + +lzop allows compression and decompression of files. + +Documentation is available via:: + + man lzop +""" + +from binman import bintool + +# pylint: disable=C0103 +class Bintoollzop(bintool.BintoolPacker): + """Compression/decompression using the lzop algorithm + + This bintool supports running `lzop` to compress and decompress data, as + used by binman. + + It is also possible to fetch the tool, which uses `apt` to install it. + + Documentation is available via:: + + man lzop + """ + def __init__(self, name): + super().__init__(name, 'lzo', compress_args=[]) diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py index 4fbd80e2ff..e7cba23aa8 100644 --- a/tools/binman/comp_util.py +++ b/tools/binman/comp_util.py @@ -11,12 +11,12 @@ from binman import bintool from patman import tools
# Supported compressions -COMPRESSIONS = ['bzip2', 'gzip', 'lz4', 'lzma'] +COMPRESSIONS = ['bzip2', 'gzip', 'lz4', 'lzma', 'lzo']
bintools = {}
def _get_tool_name(algo): - names = {'lzma': 'lzma_alone'} + names = {'lzma': 'lzma_alone', 'lzo': 'lzop'} return names.get(algo, algo)
def _get_tool(algo): @@ -34,13 +34,14 @@ def compress(indata, algo): Note that for lzma this uses an old version of the algorithm, not that provided by xz.
- This requires 'bzip2', 'gzip', 'lz4' and 'lzma_alone' tools. It also - requires an output directory to be previously set up, by calling + This requires 'bzip2', 'gzip', 'lz4', 'lzma_alone' and 'lzop' tools. It + also requires an output directory to be previously set up, by calling PrepareOutputDir().
Args: indata (bytes): Input data to compress - algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4' or 'lzma') + algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4', 'lzma' or + 'lzo')
Returns: bytes: Compressed data @@ -61,13 +62,14 @@ def decompress(indata, algo): Note that for lzma this uses an old version of the algorithm, not that provided by xz.
- This requires 'bzip2', 'gzip', 'lz4' and 'lzma_alone' tools. It also - requires an output directory to be previously set up, by calling + This requires 'bzip2', 'gzip', 'lz4', 'lzma_alone' and 'lzop' tools. It + also requires an output directory to be previously set up, by calling PrepareOutputDir().
Args: indata (bytes): Input data to decompress - algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4' or 'lzma') + algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4', 'lzma' or + 'lzo')
Returns: (bytes) Compressed data