@@ -32,6 +32,7 @@
#include "swupdate_settings.h"
#include "swupdate_dict.h"
#include "swupdate_vars.h"
+#include "bootloader.h"
#define INITIAL_STATUS_REPORT_WAIT_DELAY 10
@@ -868,7 +869,14 @@ static void get_action_id_from_env(int *action_id)
* stored.
*/
*action_id = -1;
- char *action_str = swupdate_vars_get("action_id", NULL);
+ char *action_str = NULL;
+
+ if (is_bootloader(BOOTLOADER_GRUB)) {
+ action_str = bootloader_env_get("action_id");
+ } else {
+ action_str = swupdate_vars_get("action_id", NULL);
+ }
+
if (action_str) {
int tmp = ustrtoull(action_str, NULL, 10);
if (errno)
@@ -882,6 +890,8 @@ static void get_action_id_from_env(int *action_id)
TRACE("Retrieve action_id from previous run: %d", *action_id);
}
free(action_str);
+ } else {
+ INFO("'action_id' not found in environment.");
}
}
@@ -951,7 +961,11 @@ server_op_res_t server_handle_initial_state(update_state_t stateovrrd)
/*
* Everything fine, reset action_id if any
*/
- swupdate_vars_set("action_id", NULL, NULL);
+ if (is_bootloader(BOOTLOADER_GRUB)) {
+ bootloader_env_unset("action_id");
+ } else {
+ swupdate_vars_set("action_id", NULL, NULL);
+ }
/* NOTE (Re-)setting STATE_KEY=STATE_OK == '0' instead of deleting it
* as it may be required for the switchback/recovery U-Boot logics.
@@ -1112,9 +1126,17 @@ server_op_res_t server_process_update_artifact(int action_id,
ERROR("OOM reached when saving action_id");
return SERVER_EERR;
}
- if (swupdate_vars_set("action_id", action_id_str, NULL)) {
- WARN("Action_id cannot be stored, do yourself");
- }
+
+ int ret;
+ if (is_bootloader(BOOTLOADER_GRUB)) {
+ ret = bootloader_env_set("action_id", action_id_str);
+ } else {
+ ret = swupdate_vars_set("action_id", action_id_str, NULL);
+ }
+ if (ret) {
+ WARN("Action_id cannot be stored, do yourself");
+ }
+
free(action_id_str);
for (int json_data_artifact_count = 0;