2022-08-19 14:25:35 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
|
|
|
# Copyright (C) 2022 Weidmüller Interface GmbH & Co. KG
|
|
|
|
# Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
|
|
|
|
#
|
|
|
|
"""Bintool implementation for gzip
|
|
|
|
|
|
|
|
gzip allows compression and decompression of files.
|
|
|
|
|
|
|
|
Documentation is available via::
|
|
|
|
|
|
|
|
man gzip
|
|
|
|
"""
|
|
|
|
|
|
|
|
from binman import bintool
|
|
|
|
|
|
|
|
# pylint: disable=C0103
|
binman: bintool: remove btool_ prefix from btool names
The binary is looked on the system by the suffix of the packer class.
This means binman was looking for btool_gzip on the system and not gzip.
Since a btool can have its btool_ prefix missing but its module and
binary presence on the system appropriately found, there's no need to
actually keep this prefix after listing all possible btools, so let's
remove it.
This fixes gzip btool by letting Bintool.find_bintool_class handle the
missing prefix and still return the correct class which is then init
with gzip name instead of btool_gzip.
Additionally, there was an issue with the cached module global variable.
The variable only stores the module and not the associated class name
when calling find_bintool_class.
This means that when caching the module on the first call to
find_bintool_class, class_name would be set to Bintoolbtool_gzip but the
module_name gzip only, adding the module in the gzip key in the module
dictionary. When hitting the cache on next calls, the gzip key would be
found, so its value (the module) is used. However the default class_name
(Bintoolgzip) is used, failing the getattr call.
Instead, let's enforce the same class name: Bintool<packer>, whatever
the filename it is contained in.
Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-11-07 12:54:54 +00:00
|
|
|
class Bintoolgzip(bintool.BintoolPacker):
|
2022-08-19 14:25:35 +00:00
|
|
|
"""Compression/decompression using the gzip algorithm
|
|
|
|
|
|
|
|
This bintool supports running `gzip` 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 gzip
|
|
|
|
"""
|
|
|
|
def __init__(self, name):
|
2022-11-07 12:54:56 +00:00
|
|
|
super().__init__(name, compress_args=[],
|
2022-08-19 14:25:35 +00:00
|
|
|
version_regex=r'gzip ([0-9.]+)')
|