Name of the barebox boot state can be set by user in bootchooser
framework. barebox-state application has -n parameter to change
boot state name. This patch add possibility to change barebox boot
state name over rauc configuration file.

Signed-off-by: Andreas Schmidt <m...@schmidt-andreas.de>
---
Hi!
I have several states in barebox state framework. Of course, I named them with 
different 
names. By default barebox-state without -n parameter search for /state or 
/aliases/state,
but my boot state get the name "bootstate". I created this patch to have a 
simple possibility
using rauc with not default barebox boot state names.

Regards,
Andreas
---
 include/config_file.h | 1 +
 src/bootchooser.c     | 8 ++++++++
 src/config_file.c     | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/include/config_file.h b/include/config_file.h
index 972dd48..eb71e2a 100644
--- a/include/config_file.h
+++ b/include/config_file.h
@@ -27,6 +27,7 @@ typedef struct {
        RConfigSysVariant system_variant_type;
        gchar *system_variant;
        gchar *system_bootloader;
+       gchar *system_bb_statename;
        /* path prefix where rauc may create mount directories */
        gchar *mount_prefix;
        gchar *store_path;
diff --git a/src/bootchooser.c b/src/bootchooser.c
index d9b2830..16f45d5 100644
--- a/src/bootchooser.c
+++ b/src/bootchooser.c
@@ -69,6 +69,10 @@ static gboolean barebox_state_get(const gchar* bootname, 
BareboxSlotState *bb_st
        g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
 
        g_ptr_array_add(args, g_strdup(BAREBOX_STATE_NAME));
+       if (r_context()->config->system_bb_statename) {
+               g_ptr_array_add(args, g_strdup("-n"));
+               g_ptr_array_add(args, 
g_strdup(r_context()->config->system_bb_statename));
+       }
        g_ptr_array_add(args, g_strdup("-g"));
        g_ptr_array_add(args, g_strdup_printf(BOOTSTATE_PREFIX ".%s.priority", 
bootname));
        g_ptr_array_add(args, g_strdup("-g"));
@@ -157,6 +161,10 @@ static gboolean barebox_state_set(GPtrArray *pairs, GError 
**error) {
        g_assert_cmpuint(pairs->len, >, 0);
        
        g_ptr_array_add(args, g_strdup(BAREBOX_STATE_NAME));
+       if (r_context()->config->system_bb_statename) {
+               g_ptr_array_add(args, g_strdup("-n"));
+               g_ptr_array_add(args, 
g_strdup(r_context()->config->system_bb_statename));
+       }
        for (guint i = 0; i < pairs->len; i++) {
                g_ptr_array_add(args, g_strdup("-s"));
                g_ptr_array_add(args, g_strdup(pairs->pdata[i]));
diff --git a/src/config_file.c b/src/config_file.c
index 34d9dcf..f28b59e 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -124,6 +124,10 @@ gboolean load_config(const gchar *filename, RaucConfig 
**config, GError **error)
                goto free;
        }
 
+       if (g_strcmp0(c->system_bootloader, "barebox") == 0) {
+               c->system_bb_statename = g_key_file_get_string(key_file, 
"system", "barebox-statename", NULL);
+       }
+
        c->mount_prefix = g_key_file_get_string(key_file, "system", 
"mountprefix", NULL);
        if (!c->mount_prefix) {
                g_debug("No mount prefix provided, using /mnt/rauc/ as 
default");
-- 
2.14.1


_______________________________________________
RAUC mailing list

Reply via email to