From 8436282e24df315a37bb0392fcf6212458239432 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 31 Jul 2024 08:49:00 -0600 Subject: mkeficapsule: Add a --version argument Tools should have an option to obtain the version, so add this to the mkeficapsule tool. Signed-off-by: Simon Glass Reviewed-by: Ilias Apalodimas --- tools/mkeficapsule.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index 6a261ff549d..c112ae2de8d 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -21,6 +21,8 @@ #include #include +#include + #include "eficapsule.h" static const char *tool_name = "mkeficapsule"; @@ -28,7 +30,7 @@ static const char *tool_name = "mkeficapsule"; efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID; -static const char *opts_short = "g:i:I:v:p:c:m:o:dhARD"; +static const char *opts_short = "g:i:I:v:p:c:m:o:dhARDV"; enum { CAPSULE_NORMAL_BLOB = 0, @@ -70,6 +72,7 @@ static void print_usage(void) "\t-R, --fw-revert firmware revert capsule, takes no GUID, no image blob\n" "\t-o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff\n" "\t-D, --dump-capsule dump the contents of the capsule headers\n" + "\t-V, --version show version number\n" "\t-h, --help print a help message\n", tool_name); } @@ -969,6 +972,9 @@ int main(int argc, char **argv) case 'D': capsule_dump = true; break; + case 'V': + printf("mkeficapsule version %s\n", PLAIN_VERSION); + exit(EXIT_SUCCESS); default: print_usage(); exit(EXIT_SUCCESS); -- cgit v1.2.3 From d0dbfd5299910a85c821b06ae8bd9a38818331c1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 31 Jul 2024 08:49:01 -0600 Subject: binman: Collect the version number for mkeficapsule Now that this tool has a version number, collect it. Signed-off-by: Simon Glass --- tools/binman/btool/mkeficapsule.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py index ef1da638df1..f7e5a886849 100644 --- a/tools/binman/btool/mkeficapsule.py +++ b/tools/binman/btool/mkeficapsule.py @@ -33,7 +33,8 @@ class Bintoolmkeficapsule(bintool.Bintool): commandline, or through a config file. """ def __init__(self, name): - super().__init__(name, 'mkeficapsule tool for generating capsules') + super().__init__(name, 'mkeficapsule tool for generating capsules', + r'mkeficapsule version (.*)') def generate_capsule(self, image_index, image_guid, hardware_instance, payload, output_fname, priv_key, pub_key, -- cgit v1.2.3 From 2e658c18096bc62840e081055a4e35f28c50ec2f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 31 Jul 2024 08:49:02 -0600 Subject: binman: Deal with mkeficapsule being missing Tools cannot be assumed to be present. Add a check for this with the mkeficpasule tool. Signed-off-by: Simon Glass Fixes: b617611b27a ("binman: capsule: Add support for generating...") --- tools/binman/etype/efi_capsule.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools') diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py index 751f654bf31..1c4d1bb0e2a 100644 --- a/tools/binman/etype/efi_capsule.py +++ b/tools/binman/etype/efi_capsule.py @@ -150,6 +150,10 @@ class Entry_efi_capsule(Entry_section): if ret is not None: os.remove(payload) return tools.read_file(capsule_fname) + else: + # Bintool is missing; just use the input data as the output + self.record_missing_bintool(self.mkeficapsule) + return data def AddBintools(self, btools): self.mkeficapsule = self.AddBintool(btools, 'mkeficapsule') -- cgit v1.2.3 From ba35f730e817153f07ea88355399ab336319f8a7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 31 Jul 2024 08:49:03 -0600 Subject: binman: Return failure when a usage() message is generated The tool must return an error code when invalid arguments are provided, otherwise binman has no way of knowing that anything went wrong. Correct this. Signed-off-by: Simon Glass Fixes: fab430be2f4 ("tools: add mkeficapsule command for UEFI...") --- tools/mkeficapsule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c112ae2de8d..f28008a0829 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -977,7 +977,7 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); default: print_usage(); - exit(EXIT_SUCCESS); + exit(EXIT_FAILURE); } } -- cgit v1.2.3 From cbf3d274cf3b5f4623f73a784337ab4f50b3a10b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 31 Jul 2024 08:49:04 -0600 Subject: binman: Keep the efi_capsule input file There is no need to remove input files. It makes it harder to diagnose failures. Keep the payload file. There is no test for this condition, but one could be added. Signed-off-by: Simon Glass Acked-by: Sughosh Ganu --- tools/binman/etype/efi_capsule.py | 1 - 1 file changed, 1 deletion(-) (limited to 'tools') diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py index 1c4d1bb0e2a..5941545d0b2 100644 --- a/tools/binman/etype/efi_capsule.py +++ b/tools/binman/etype/efi_capsule.py @@ -148,7 +148,6 @@ class Entry_efi_capsule(Entry_section): self.fw_version, self.oem_flags) if ret is not None: - os.remove(payload) return tools.read_file(capsule_fname) else: # Bintool is missing; just use the input data as the output -- cgit v1.2.3