Running 'west blobs fetch' does not verify the digest of downloaded files:
1. if the checksum of the previously downloaded file does match
that in the blob metadata (status BLOB_PRESENT), do nothing
2. if the checksum of the previously downloaded file does not match
that in the blob metadata (status BLOB_OUTDATED),
download the "up to date" file
3. if the blob has not yet been downloaded (status BLOB_NOT_PRESENT),
download it
None of the 2) and 3) code paths will verify that the checksum of the file
just downloaded actually matches the digest in the blob's metadata.
In the event that the metadata of a module is incorrect, then the user
will not notice anything, and may rely on an unexpected binary,
e.g. a static library for a different architecture.
According to the Binary Blobs documentation [1], the expected
behavior is to check the blob digest after downloading.
[1] Fetching blobs, Zephyr 3.6.0 (still applies to Zephyr 3.7.0rc3)
docs.zephyrproject.org/3.6.0/contribute/bin_blobs.html#fetching-blobs
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Instead of blindly using the module names provided by the user via
command-line arguments, check if those actually exist in the current
manifest, and error out if any of them does not.
Fixes#73901.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In preparation for the handling of taint flags in zephyr_module.py, move
blob-processing code from the west command to it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Turns out that `Namespace.format` was not a good fix to the issue
described in f033040812, it was returning
the default format even when the user specified -f/--format.
Replace "getattr" with a simple logical operation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
There were two issues with the original commit
e04487cad2b98385c850fa478e1d1ca97bf0e836:
- getattr() doesn't seem to work properly with args
- Comparison between bound methods with "is" seems not to work, so
replace it with a simpler string comparison
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Make some no-op log messages require 'west -v blobs ...'.
The current implementation won't scale as the number of blobs goes up.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This option does not apply to 'west blobs clean' or 'west blobs
fetch'. Error out if it is given to either of those.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Make it consistent with the usual argparse style by using lower case
and no period at the end.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The help text is mixing up 'blobs' with 'modules', and doesn't
document the new behavior that uses all modules when nothing is
mentioned. Fix both issues.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Without this patch, "west blobs -h" says:
{list,fetch,clean} Select the sub-command to execute. Sub-commands
available: - list: list binary blobs - fetch: fetch and store binary
blobs - clean: remove fetched binary blobs
With this patch:
{list,fetch,clean} sub-command to execute
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The `<module>/zephyr/blobs/` folder, as well as any additional
sub-folders that might be required under `blobs/` may not exist when
fetching a blob. Ensure that the folder exists, create it if it doesn't.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The new "clean" blobs sub-command deletes any blobs present on the
filesystem.
Also improve the help text for sub-commands.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To align with other commands, such as "west update", convert the
accumulative -m option into an nargs="*"-type one that takes the list of
modules directly without a flag.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Instead of both listing and fetching only the blobs in the
modules listed by the user in the command-line, default to
listing/fetching them all for ease-of-use and consistency with other
commands. Remove the --all options since it's meaningless now.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This patch introduces the basic infrastructure to list and fetch binary
blobs. This includes:
- The new 'blobs' extension command
- An implementation of the `west blobs list` command
with custom formatting
- A very simple mechanism for loading fetchers
- A basic implementation of an HTTP fetcher
In order to ensure consistency among the west extension commands in the
main zephyr tree, we reuse a similar class factory pattern that is present
for ZephyrBinaryRunner instances in the ZephyrBlobFetcher case. This
could be achieved with a simpler mechanism, but opted for consistency
before simplicity.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>