summaryrefslogtreecommitdiff
path: root/tools/binman/bintool.py
AgeCommit message (Collapse)Author
12 daysbinman: bintool: run 'apt-get update -y' on first invocation of apt_install()Jerome Forissier
'apt-get update -y' may be required to make sure that the list of packages is up-to-date and that the subsequent 'apt-get install' operations can find the requested packages. Fixes the following CI error: Fetch: zstd - trying method: binary download - sudo apt-get install -y zstd Exception: Error 100 running 'sudo apt-get install -y zstd': E: Unable to locate package zstd Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Bryan Brattlof <bb@ti.com>
12 daysbinman: bintool: use apt-get instead of aptJerome Forissier
The 'apt' command is not meant to be used in scripts or tools. Please see the man page [1] for details. Therefore, use 'apt-get' instead. This avoids the following warning: WARNING: apt does not have a stable CLI interface. Use with caution in scripts. [1] https://manpages.debian.org/bookworm/apt/apt.8.en.html#SCRIPT_USAGE_AND_DIFFERENCES_FROM_OTHER_APT_TOOLS Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bryan Brattlof <bb@ti.com>
2025-03-12binman: build_from_git: Add optional make path inside git repoLeonard Anderweit
Add optional argument make_path to build_from git. The new argument allows specifying the path to a Makefile in case it is not in the root of the git repo. Also adjust the corresponding test. Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2025-03-12binman: build_from_git: Add argument specifying branchLeonard Anderweit
Add optional argument git_branch to build_from_git. The new argument allows specifying which branch of the repo to use. Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-29binman: bintool: Build a tool from a list of commandsSughosh Ganu
Add support to build a tool from source with a list of commands. This is useful when a tool can be built with multiple commands instead of a single command. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-20binman: Reduce state.SetInt and bintool cmd to debug levelSimon Glass
These are not very important message. Change them to use the 'debug' level instead of 'detail'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass
The patman directory has a number of modules which are used by other tools in U-Boot. This makes it hard to package the tools using pypi since the common files must be copied along with the tool that uses them. To address this, move these files into a new u_boot_pylib library. This can be packaged separately and listed as a dependency of each tool. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08binman: Make the tooldir configurableSimon Glass
Add a command-line argument for setting the tooldir, so that the default can be overridden. Add this directory to the toolpath automatically. Create the directory if it does not already exist. Put the default in the argument parser instead of the class, so that it is more obvious. Update a few tests that expect the utility name to be provided without any path (e.g. 'futility'), so they can accept a path, e.g. /path/to/futility Update the documentation and add a few tests. Improve the help for --toolpath while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08binman: Use a private directory for bintoolsSimon Glass
At present binman writes tools into the ~/bin directory. This is convenient but some may be concerned about downloading unverified binaries and running them. Place then in a special ~/.binman-tools directory instead. Mention this in the documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-03-08binman: Move the tools directory into the Bintool classSimon Glass
We want to be able to change this directory. Use a class member to hold the value, since changing a constant is not good. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08binman: Correct an 'aot' typoSimon Glass
Fix this typo. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08binman: Avoid requiring a home directory on startupSimon Glass
This is needed to download tools, but we may not need to do this. At present binman fails to start if HOME is not set. Use the current directory as a default to avoid this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22binman: bintool: remove btool_ prefix from btool namesQuentin Schulz
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-09-21binman: Get futility by building itSimon Glass
A binary download is not great, since it depends on libraries being present in the system. Build futility from source instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-01binman: bintool: parametrize args to pass to binary for returning versionQuentin Schulz
The code to check the version is very similar between binaries, the most likely only needed variables are the regex to find the version (already supported) and the args to pass to the binary so that it prints this version (e.g. --version, -V or similar). Let's make it a parameter of Bintool so that code duplication can be avoided for simple changes. Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
2022-09-01binman: bintool: move version check implementation into bintool classQuentin Schulz
Version checking has nothing specific to compression/decompression tools so let's move it to the Bintool class. Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-20binman: Add gzip bintoolStefan Herbrechtsmeier
Add gzip bintool to binman to support on-the-fly compression of Linux kernel images and FPGA bitstreams. The SPL basic fitImage implementation supports only gzip decompression. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org> Rename the module and support this, since gzip.py is a system module: Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-20binman: Add BintoolPacker class to bintoolStefan Herbrechtsmeier
Add a bintools base class for packers which compression / decompression entry contents. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org> Dropped dead/untested code in version(): Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Rename Color() method to build()Simon Glass
This method has the same name as its class which is confusing. It is also annoying when searching the code. It builds a string with a colour, so rename it to build(). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tout.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in command.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tools.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25binman: Add a command to generate bintool docsSimon Glass
Each bintool has some documentation which can be useful for the user. Add a new command that collects this and writes it into a .rst file. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25binman: Add support for bintoolsSimon Glass
Binman requires various tools to actually work, such as 'lz4' to compress data and 'futility' to sign Chrome OS firmware. At present these are handled in an ad-hoc manner and there is no easy way to find out what tools are needd to build an image, nor where to obtain them. Add an implementation of 'bintool', a base class which implements this functionality. When a bintool is required, it can be requested from this module, then executed. When the tool is missing, it can provide a way to obtain it. Note that this uses Command directly, not the tools.Run() function. This allows proper handling of missing tools and avoids needing to catch and re-raise exceptions. Signed-off-by: Simon Glass <sjg@chromium.org>