diff mbox series

Unify bootloader script format

Message ID 20190315103958.4238-1-sbabic@denx.de
State Accepted
Headers show
Series Unify bootloader script format | expand

Commit Message

Stefano Babic March 15, 2019, 10:39 a.m. UTC
Former script had the syntax:

	<variable> <value>

but it was changed to be confor to u-boot format, also used by U-Boot
tools to generate an environment from a script:

	<variable>=<value>

This is the format used when the environment is updated from handler.
Internally, a script was still generated with the old format and then
passed to the bootloader API. Switch to the new format in all cases and
adjust code in Grub and EBG code.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 bootloader/ebg.c    | 2 +-
 bootloader/grub.c   | 2 +-
 corelib/installer.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/bootloader/ebg.c b/bootloader/ebg.c
index dd4387e..5987d6a 100644
--- a/bootloader/ebg.c
+++ b/bootloader/ebg.c
@@ -162,7 +162,7 @@  int bootloader_apply_list(const char *filename)
 	}
 
 	while ((getline(&line, &len, fp)) != -1) {
-		key = strtok(line, " \t\n");
+		key = strtok(line, "=");
 		value = strtok(NULL, "\t\n");
 		if (value != NULL && key != NULL) {
 			if ((ret = bootloader_env_set(key, value)) != 0) {
diff --git a/bootloader/grub.c b/bootloader/grub.c
index 6a03d2b..dbe5ec9 100644
--- a/bootloader/grub.c
+++ b/bootloader/grub.c
@@ -122,7 +122,7 @@  static int grubenv_parse_script(struct grubenv_t *grubenv, const char *script)
 	 * turns out to be desired
 	 */
 	while ((getline(&line, &len, fp)) != -1) {
-		key = strtok(line, " \t\n");
+		key = strtok(line, "=");
 		value = strtok(NULL, "\t\n");
 		if (value != NULL && key != NULL) {
 			ret = dict_set_value(&grubenv->vars, key, value);
diff --git a/corelib/installer.c b/corelib/installer.c
index f7809d4..edfcb6a 100644
--- a/corelib/installer.c
+++ b/corelib/installer.c
@@ -169,7 +169,7 @@  static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script)
 
 		if (!key || !value)
 			continue;
-		snprintf(buf, sizeof(buf), "%s %s\n", key, value);
+		snprintf(buf, sizeof(buf), "%s=%s\n", key, value);
 		if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
 			  TRACE("Error saving temporary bootloader environment file");
 			  close(fd);