aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2022-11-07 13:54:54 +0100
committerSimon Glass <sjg@chromium.org>2022-11-22 15:13:34 -0700
commit478332a345428659c924b06ea59627a26c2f0ee2 (patch)
treeccff2db37f359d07b77fcb18869361aa1850716a
parent521277ec15eb794229403ec24b8c00a4ff02b0b6 (diff)
downloadu-boot-478332a345428659c924b06ea59627a26c2f0ee2.zip
u-boot-478332a345428659c924b06ea59627a26c2f0ee2.tar.gz
u-boot-478332a345428659c924b06ea59627a26c2f0ee2.tar.bz2
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>
-rw-r--r--tools/binman/bintool.py3
-rw-r--r--tools/binman/btool/btool_gzip.py2
2 files changed, 3 insertions, 2 deletions
diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
index a582d9d..8fda13f 100644
--- a/tools/binman/bintool.py
+++ b/tools/binman/bintool.py
@@ -85,7 +85,6 @@ class Bintool:
try:
# Deal with classes which must be renamed due to conflicts
# with Python libraries
- class_name = f'Bintoolbtool_{module_name}'
module = importlib.import_module('binman.btool.btool_' +
module_name)
except ImportError:
@@ -137,6 +136,8 @@ class Bintool:
names = [os.path.splitext(os.path.basename(fname))[0]
for fname in files]
names = [name for name in names if name[0] != '_']
+ names = [name[6:] if name.startswith('btool_') else name
+ for name in names]
if include_testing:
names.append('_testing')
return sorted(names)
diff --git a/tools/binman/btool/btool_gzip.py b/tools/binman/btool/btool_gzip.py
index 70cbc19..a7ce641 100644
--- a/tools/binman/btool/btool_gzip.py
+++ b/tools/binman/btool/btool_gzip.py
@@ -14,7 +14,7 @@ Documentation is available via::
from binman import bintool
# pylint: disable=C0103
-class Bintoolbtool_gzip(bintool.BintoolPacker):
+class Bintoolgzip(bintool.BintoolPacker):
"""Compression/decompression using the gzip algorithm
This bintool supports running `gzip` to compress and decompress data, as