tools: Add ignoreUpdate parameter
Adds ignoreUpdate flag to skip checking the update status and always
return success instead. This is needed for platforms that use the reboot
json and encounters an update failure due to IPMI going down during
shutdown.
Tested: Tried out an update with and without --ignore-update to verify
that the flag ignores the update status and returns success.
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: Ie20774f997229cd5ff8ae9082dc8a747079f9a2c
diff --git a/tools/main.cpp b/tools/main.cpp
index ae85c1b..f73bcad 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -53,7 +53,8 @@
std::fprintf(
stderr,
"Usage: %s --command <command> --interface <interface> --image "
- "<image file> --sig <signature file> --type <layout>\n",
+ "<image file> --sig <signature file> --type <layout> "
+ "[--ignore-update]\n",
program);
std::fprintf(stderr, "interfaces: ");
@@ -86,6 +87,7 @@
long length = 0;
std::uint32_t hostAddress = 0;
std::uint32_t hostLength = 0;
+ bool ignoreUpdate = false;
while (1)
{
@@ -98,12 +100,13 @@
{"address", required_argument, 0, 'a'},
{"length", required_argument, 0, 'l'},
{"type", required_argument, 0, 't'},
+ {"ignore-update", no_argument, 0, 'u'},
{0, 0, 0, 0}
};
// clang-format on
int option_index = 0;
- int c = getopt_long(argc, argv, "c:i:m:s:a:l:t:", long_options,
+ int c = getopt_long(argc, argv, "c:i:m:s:a:l:t:u", long_options,
&option_index);
if (c == -1)
{
@@ -168,6 +171,9 @@
case 't':
type = std::string{optarg};
break;
+ case 'u':
+ ignoreUpdate = true;
+ break;
default:
usage(argv[0]);
exit(EXIT_FAILURE);
@@ -232,7 +238,8 @@
try
{
host_tool::UpdateHandler updater(&blob, handler.get());
- host_tool::updaterMain(&updater, imagePath, signaturePath, type);
+ host_tool::updaterMain(&updater, imagePath, signaturePath, type,
+ ignoreUpdate);
}
catch (const host_tool::ToolException& e)
{