diff options
Diffstat (limited to 'updater/updater.cpp')
-rw-r--r-- | updater/updater.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/updater/updater.cpp b/updater/updater.cpp index 0497d6a85..c222cee0d 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) { setbuf(stdout, NULL); setbuf(stderr, NULL); - if (argc != 4) { + if (argc != 4 && argc != 5) { printf("unexpected number of arguments (%d)\n", argc); return 1; } @@ -145,6 +145,14 @@ int main(int argc, char** argv) { state.script = script; state.errmsg = NULL; + if (argc == 5) { + if (strcmp(argv[4], "retry") == 0) { + state.is_retry = true; + } else { + printf("unexpected argument: %s", argv[4]); + } + } + char* result = Evaluate(&state, root); if (have_eio_error) { @@ -159,11 +167,28 @@ int main(int argc, char** argv) { printf("script aborted: %s\n", state.errmsg); char* line = strtok(state.errmsg, "\n"); while (line) { + // Parse the error code in abort message. + // Example: "E30: This package is for bullhead devices." + if (*line == 'E') { + if (sscanf(line, "E%u: ", &state.error_code) != 1) { + printf("Failed to parse error code: [%s]\n", line); + } + } fprintf(cmd_pipe, "ui_print %s\n", line); line = strtok(NULL, "\n"); } fprintf(cmd_pipe, "ui_print\n"); } + + if (state.error_code != kNoError) { + fprintf(cmd_pipe, "log error: %d\n", state.error_code); + // Cause code should provide additional information about the abort; + // report only when an error exists. + if (state.cause_code != kNoCause) { + fprintf(cmd_pipe, "log cause: %d\n", state.cause_code); + } + } + free(state.errmsg); return 7; } else { |