Skip to contentSkip to conversation

defaultenv-2: add boot sequence

PATCH Superseded Jean-Christophe PLAGNIOL-VILLARD 3 participants 11 messages Aug 24, 2012 – Sep 1, 2012

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover defaultenv-2: add boot sequence

HI,

this patch series depends on fs-symlink send previously

please pull
The following changes since commit 64adf688f4f8cc6c0b7e1f3c4da29e881524c5f0:

defautenv: add support of symlink (2012-08-23 21:31:57 +0800)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git tags/defaultenv-2-boot-sequence

for you to fetch changes up to ae5c90abd8625d1f091a0a089ac29f886fb6c6f5:

defaultenv-2: add boot sequence (2012-08-24 12:02:36 +0800)

----------------------------------------------------------------
defaultenv-2: add boot sequence

Boot will boot run sequentially the script in /env/boot.d We store symlink in /env/boot.d on /env/boot

if not global.boot.defaul or global.boot.defaul == seq start the boot sequence

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (5):
globalbar: add inline when not enabled
globalvar: add support to set a value to of all globalvars beginning with 'match'
defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globarvar
defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globarvar
defaultenv-2: add boot sequence

 commands/global.c                          |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 common/globalvar.c                         |   10 ++++++++++
 defaultenv-2/base/bin/boot                 |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 defaultenv-2/base/bin/bootargs-ip          |    4 ++--
 defaultenv-2/base/bin/bootargs-ip-barebox  |    2 +-
 defaultenv-2/base/bin/bootargs-ip-dhcp     |    2 +-
 defaultenv-2/base/bin/bootargs-ip-none     |    2 +-
 defaultenv-2/base/bin/bootargs-root-disk   |    2 +-
 defaultenv-2/base/bin/bootargs-root-ext    |    2 +-
 defaultenv-2/base/bin/bootargs-root-initrd |    2 +-
 defaultenv-2/base/bin/bootargs-root-jffs2  |    2 +-
 defaultenv-2/base/bin/bootargs-root-nfs    |    2 +-
 defaultenv-2/base/bin/bootargs-root-ubi    |    2 +-
 defaultenv-2/base/bin/init                 |    5 +++--
 defaultenv-2/base/boot/initrd              |    2 +-
 defaultenv-2/base/init/general             |    2 +-
 include/globalvar.h                        |   23 +++++++++++++++++++++++
 17 files changed, 151 insertions(+), 27 deletions(-)

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH 1/5 globalbar: add inline when not enabled

---
 include/globalvar.h |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
include/globalvar.h +20 -0
index 7cc3976..a127a05 100644
@@ -1,6 +1,7 @@
 #ifndef __GLOBALVAR_H
 #define __GLOBALVAR_H
 
+#ifdef CONFIG_GLOBALVAR
 int globalvar_add_simple(const char *name);
 
 int globalvar_add(const char *name,
@@ -8,5 +9,24 @@ int globalvar_add(const char *name,
 		const char *(*get)(struct device_d *, struct param_d *p),
 		unsigned long flags);
 char *globalvar_get_match(const char *match, const char *seperator);
+#else
+static inline int globalvar_add_simple(const char *name)
+{
+	return 0;
+}
+
+static inline int globalvar_add(const char *name,
+		int (*set)(struct device_d *dev, struct param_d *p, const char *val),
+		const char *(*get)(struct device_d *, struct param_d *p),
+		unsigned long flags)
+{
+	return 0;
+}
+
+static inline char *globalvar_get_match(const char *match, const char *seperator)
+{
+	return NULL;
+}
+#endif
 
 #endif /* __GLOBALVAR_H */
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/5 globalvar: add support to set a value to of all globalvars beginning with 'match'

via c global_reset_match and global -r

---
 commands/global.c   |   58 ++++++++++++++++++++++++++++++++++++++++++++-------
 common/globalvar.c  |   10 +++++++++
 include/globalvar.h |    3 +++
 3 files changed, 64 insertions(+), 7 deletions(-)
commands/global.c +51 -7
index de6b13e..cb22e63 100644
@@ -24,25 +24,26 @@
 #include <command.h>
 #include <globalvar.h>
 #include <environment.h>
+#include <getopt.h>
 
-static int do_global(int argc, char *argv[])
+static int do_global_add(int argc, char *argv[])
 {
 	int ret;
 	char *value;
 
-	if (argc != 2)
+	if (argc != 1)
 		return COMMAND_ERROR_USAGE;
 
-	value = strchr(argv[1], '=');
+	value = strchr(argv[0], '=');
 	if (value) {
 		*value = 0;
 		value++;
 	}
 
-	ret = globalvar_add_simple(argv[1]);
+	ret = globalvar_add_simple(argv[0]);
 
 	if (value) {
-		char *name = asprintf("global.%s", argv[1]);
+		char *name = asprintf("global.%s", argv[0]);
 		ret = setenv(name, value);
 		free(name);
 	}
@@ -50,13 +51,56 @@ static int do_global(int argc, char *argv[])
 	return ret ? 1 : 0;
 }
 
+static int do_global_reset(int argc, char *argv[])
+{
+	char *value;
+
+	if (argc != 1)
+		return COMMAND_ERROR_USAGE;
+
+	value = strchr(argv[0], '=');
+	if (value) {
+		*value = 0;
+		value++;
+	} else {
+		value = "";
+	}
+
+	globalvar_reset_match(argv[0], value);
+
+	return 0;
+}
+
+static int do_global(int argc, char *argv[])
+{
+	int opt;
+	int do_reset = 0;
+
+	while ((opt = getopt(argc, argv, "r")) > 0) {
+		switch (opt) {
+		case 'r':
+			do_reset = 1;
+			break;
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+
+	if (do_reset)
+		return do_global_reset(argc, argv);
+
+	return do_global_add(argc, argv);
+}
+
 BAREBOX_CMD_HELP_START(global)
-BAREBOX_CMD_HELP_USAGE("global <var>[=<value]\n")
+BAREBOX_CMD_HELP_USAGE("global [-r] <var>[=<value]\n")
 BAREBOX_CMD_HELP_SHORT("add a new global variable named <var>, optionally set to <value>\n")
+BAREBOX_CMD_HELP_SHORT("-r to set a value to of all globalvars beginning with 'match'")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(global)
 	.cmd		= do_global,
-	.usage		= "create global variables",
+	.usage		= "create or reset global variables",
 	BAREBOX_CMD_HELP(cmd_global_help)
 BAREBOX_CMD_END
common/globalvar.c +10 -0
index 71296ff..99f055e 100644
@@ -46,6 +46,16 @@ char *globalvar_get_match(const char *match, const char *seperator)
 	return val;
 }
 
+void globalvar_reset_match(const char *match, const char *val)
+{
+	struct param_d *param;
+
+	list_for_each_entry(param, &global_device.parameters, list) {
+		if (!strncmp(match, param->name, strlen(match)))
+			dev_set_param(&global_device, param->name, val);
+	}
+}
+
 /*
  * globalvar_add_simple
  *
include/globalvar.h +3 -0
index a127a05..1935f83 100644
@@ -9,6 +9,7 @@ int globalvar_add(const char *name,
 		const char *(*get)(struct device_d *, struct param_d *p),
 		unsigned long flags);
 char *globalvar_get_match(const char *match, const char *seperator);
+void globalvar_reset_match(const char *match, const char *val);
 #else
 static inline int globalvar_add_simple(const char *name)
 {
@@ -27,6 +28,8 @@ static inline char *globalvar_get_match(const char *match, const char *seperator
 {
 	return NULL;
 }
+
+static inline void globalvar_reset_match(const char *match, const char *val) {}
 #endif
 
 #endif /* __GLOBALVAR_H */
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [PATCH 2/5] globalvar: add support to set a value to of all globalvars beginning with 'match'

Hi

Quoted 73 lines
 commands/global.c   |   58 ++++++++++++++++++++++++++++++++++++++++++++-------
 common/globalvar.c  |   10 +++++++++
 include/globalvar.h |    3 +++
 3 files changed, 64 insertions(+), 7 deletions(-)
commands/global.c +34 -5
index de6b13e..cb22e63 100644
@@ -24,25 +24,26 @@
 #include <command.h>
 #include <globalvar.h>
 #include <environment.h>
+#include <getopt.h>
 
-static int do_global(int argc, char *argv[])
+static int do_global_add(int argc, char *argv[])
 {
        int ret;
        char *value;
 
-       if (argc != 2)
+       if (argc != 1)
                return COMMAND_ERROR_USAGE;
 
-       value = strchr(argv[1], '=');
+       value = strchr(argv[0], '=');
        if (value) {
                *value = 0;
                value++;
        }
 
-       ret = globalvar_add_simple(argv[1]);
+       ret = globalvar_add_simple(argv[0]);
 
        if (value) {
-               char *name = asprintf("global.%s", argv[1]);
+               char *name = asprintf("global.%s", argv[0]);
                ret = setenv(name, value);
                free(name);
        }
@@ -50,13 +51,56 @@ static int do_global(int argc, char *argv[])
        return ret ? 1 : 0;
 }
 
+static int do_global_reset(int argc, char *argv[])
+{
+       char *value;
+
+       if (argc != 1)
+               return COMMAND_ERROR_USAGE;
+
+       value = strchr(argv[0], '=');
+       if (value) {
+               *value = 0;
+               value++;
+       } else {
+               value = "";
+       }
+
+       globalvar_reset_match(argv[0], value);
+
+       return 0;
+}
+
+static int do_global(int argc, char *argv[])
+{
+       int opt;
+       int do_reset = 0;
+
+       while ((opt = getopt(argc, argv, "r")) > 0) {
+               switch (opt) {
+               case 'r':

commands/global.c static int do_global(int argc, char *argv[]) · line 91

Quoted 10 lines
commands/global.c +10 -0
+                       do_reset = 1;
+                       break;
+               }
+       }
+
+       argc -= optind;
+       argv += optind;
+
+       if (do_reset)
+               return do_global_reset(argc, argv);

Since I just read the diff, I might fail to see the big picture, however, where's the call to globalvar_reset_match(), is it inside do_global_reset()?

commands/global.c static int do_global(int argc, char *argv[]) · line 99

Quoted 8 lines
commands/global.c +5 -1
+       return do_global_add(argc, argv);
+}
+
 BAREBOX_CMD_HELP_START(global)
-BAREBOX_CMD_HELP_USAGE("global <var>[=<value]\n")
+BAREBOX_CMD_HELP_USAGE("global [-r] <var>[=<value]\n")
 BAREBOX_CMD_HELP_SHORT("add a new global variable named <var>, optionally set to <value>\n")
+BAREBOX_CMD_HELP_SHORT("-r to set a value to of all globalvars beginning with 'match'")

Shouldn't this be REset instead of set? How about:

"-r to reset all matching global variables to a value."

Maybe giving an example could shed some light on the exact syntax of the exact kind of matching you had in mind.

Quoted 54 lines
commands/global.c +1 -1
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(global)
        .cmd            = do_global,
-       .usage          = "create global variables",
+       .usage          = "create or reset global variables",
        BAREBOX_CMD_HELP(cmd_global_help)
 BAREBOX_CMD_END
common/globalvar.c +10 -0
index 71296ff..99f055e 100644
@@ -46,6 +46,16 @@ char *globalvar_get_match(const char *match, const char *seperator)
        return val;
 }
 
+void globalvar_reset_match(const char *match, const char *val)
+{
+       struct param_d *param;
+
+       list_for_each_entry(param, &global_device.parameters, list) {
+               if (!strncmp(match, param->name, strlen(match)))
+                       dev_set_param(&global_device, param->name, val);
+       }
+}
+
 /*
  * globalvar_add_simple
  *
include/globalvar.h +3 -1
index a127a05..1935f83 100644
@@ -9,6 +9,7 @@ int globalvar_add(const char *name,
                const char *(*get)(struct device_d *, struct param_d *p),
                unsigned long flags);
 char *globalvar_get_match(const char *match, const char *seperator);
+void globalvar_reset_match(const char *match, const char *val);
 #else
 static inline int globalvar_add_simple(const char *name)
 {
@@ -27,6 +28,8 @@ static inline char *globalvar_get_match(const char *match, const char *seperator
 {
        return NULL;
 }
+
+static inline void globalvar_reset_match(const char *match, const char *val) {}
 #endif
 
 #endif /* __GLOBALVAR_H */
--

1.7.10.4

Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

Re: [PATCH 2/5] globalvar: add support to set a value to of all globalvars beginning with 'match'

Quoted 81 lines · Roberto Nibali

Hi

Quoted 79 lines
 commands/global.c   |   58 ++++++++++++++++++++++++++++++++++++++++++++-------
 common/globalvar.c  |   10 +++++++++
 include/globalvar.h |    3 +++
 3 files changed, 64 insertions(+), 7 deletions(-)
commands/global.c +40 -5
index de6b13e..cb22e63 100644
@@ -24,25 +24,26 @@
 #include <command.h>
 #include <globalvar.h>
 #include <environment.h>
+#include <getopt.h>
 
-static int do_global(int argc, char *argv[])
+static int do_global_add(int argc, char *argv[])
 {
        int ret;
        char *value;
 
-       if (argc != 2)
+       if (argc != 1)
                return COMMAND_ERROR_USAGE;
 
-       value = strchr(argv[1], '=');
+       value = strchr(argv[0], '=');
        if (value) {
                *value = 0;
                value++;
        }
 
-       ret = globalvar_add_simple(argv[1]);
+       ret = globalvar_add_simple(argv[0]);
 
        if (value) {
-               char *name = asprintf("global.%s", argv[1]);
+               char *name = asprintf("global.%s", argv[0]);
                ret = setenv(name, value);
                free(name);
        }
@@ -50,13 +51,56 @@ static int do_global(int argc, char *argv[])
        return ret ? 1 : 0;
 }
 
+static int do_global_reset(int argc, char *argv[])
+{
+       char *value;
+
+       if (argc != 1)
+               return COMMAND_ERROR_USAGE;
+
+       value = strchr(argv[0], '=');
+       if (value) {
+               *value = 0;
+               value++;
+       } else {
+               value = "";
+       }
+
+       globalvar_reset_match(argv[0], value);
+
+       return 0;
+}
+
+static int do_global(int argc, char *argv[])
+{
+       int opt;
+       int do_reset = 0;
+
+       while ((opt = getopt(argc, argv, "r")) > 0) {
+               switch (opt) {
+               case 'r':
+                       do_reset = 1;
+                       break;
+               }
+       }
+
+       argc -= optind;
Quoted 8 lines

commands/global.c static int do_global(int argc, char *argv[]) · line 91

Quoted 4 lines
commands/global.c +4 -0
+       argv += optind;
+
+       if (do_reset)
+               return do_global_reset(argc, argv);

Since I just read the diff, I might fail to see the big picture, however, where's the call to globalvar_reset_match(), is it inside do_global_reset()?

no can not

you do this

globalvar toto.l=t
globalvar toto=a

so you expect

global.toto.l=t
global.toto=a

and if we you the reset_match

you will have
global.toto.l=a
global.toto=a

Quoted 12 lines

commands/global.c static int do_global(int argc, char *argv[]) · line 99

Quoted 9 lines
commands/global.c +5 -1
+       return do_global_add(argc, argv);
+}
+
 BAREBOX_CMD_HELP_START(global)
-BAREBOX_CMD_HELP_USAGE("global <var>[=<value]\n")
+BAREBOX_CMD_HELP_USAGE("global [-r] <var>[=<value]\n")
 BAREBOX_CMD_HELP_SHORT("add a new global variable named <var>, optionally set to <value>\n")
+BAREBOX_CMD_HELP_SHORT("-r to set a value to of all globalvars beginning with 'match'")

Shouldn't this be REset instead of set? How about:

Quoted 4 lines

"-r to reset all matching global variables to a value."

Maybe giving an example could shed some light on the exact syntax of the exact kind of matching you had in mind.

it's realy set a value to a list of params

the text in english is clear

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#5 lore raw

PATCH 3/5 defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globarvar

In reply to Jean-Christophe PLAGNIOL-VILLARD

linux.bootargs.dyn.* will be clearer at the beginning of boot

This is need for boot sequence to do not have the previous boot param.

---
 defaultenv-2/base/bin/bootargs-ip          |    4 ++--
 defaultenv-2/base/bin/bootargs-ip-barebox  |    2 +-
 defaultenv-2/base/bin/bootargs-ip-dhcp     |    2 +-
 defaultenv-2/base/bin/bootargs-ip-none     |    2 +-
 defaultenv-2/base/bin/bootargs-root-disk   |    2 +-
 defaultenv-2/base/bin/bootargs-root-ext    |    2 +-
 defaultenv-2/base/bin/bootargs-root-initrd |    2 +-
 defaultenv-2/base/bin/bootargs-root-jffs2  |    2 +-
 defaultenv-2/base/bin/bootargs-root-nfs    |    2 +-
 defaultenv-2/base/bin/bootargs-root-ubi    |    2 +-
 defaultenv-2/base/bin/init                 |    5 +++--
 defaultenv-2/base/boot/initrd              |    2 +-
 12 files changed, 15 insertions(+), 14 deletions(-)
defaultenv-2/base/bin/bootargs-ip +2 -2
index 15041c6..2d4486c 100644
@@ -5,7 +5,7 @@
 . /env/network/eth0
 
 if [ $ip = dhcp ]; then
-	global.linux.bootargs.ip="ip=dhcp"
+	global.linux.bootargs.dyn.ip="ip=dhcp"
 else
-	global.linux.bootargs.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
+	global.linux.bootargs.dyn.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
 fi
defaultenv-2/base/bin/bootargs-ip-barebox +1 -1
index 986c142..5a3b984 100644
@@ -4,4 +4,4 @@
 
 ifup eth0
 
-global.linux.bootargs.ip="ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
+global.linux.bootargs.dyn.ip="ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
defaultenv-2/base/bin/bootargs-ip-dhcp +1 -1
index c542b24..dec8ae4 100644
@@ -2,4 +2,4 @@
 
 # Do dhcp in Linux
 
-global.linux.bootargs.ip="ip=dhcp"
+global.linux.bootargs.dyn.ip="ip=dhcp"
defaultenv-2/base/bin/bootargs-ip-none +1 -1
index c010154..88aaa21 100644
@@ -2,4 +2,4 @@
 
 # disable ip setup in Linux
 
-global.linux.bootargs.ip="ip=none"
+global.linux.bootargs.dyn.ip="ip=none"
defaultenv-2/base/bin/bootargs-root-disk +1 -1
index df8750e..aa60cf3 100644
@@ -23,4 +23,4 @@ if [ -z "${fstype}" ]; then
 	exit 1
 fi
 
-global.linux.bootargs.root="root=/dev/$part rootfstype=$fstype rootwait"
+global.linux.bootargs.dyn.root="root=/dev/$part rootfstype=$fstype rootwait"
defaultenv-2/base/bin/bootargs-root-ext +1 -1
index 45fcd5a..dbdddb9 100644
@@ -9,4 +9,4 @@ while getopt "m:r:" opt; do
 	fi
 done
 
-global.linux.bootargs.root="root=/dev/$part rootfstype=ext$type rootwait"
+global.linux.bootargs.dyn.root="root=/dev/$part rootfstype=ext$type rootwait"
defaultenv-2/base/bin/bootargs-root-initrd +1 -1
index 7072cea..cc711a1 100644
@@ -13,4 +13,4 @@ while getopt "i:h" opt; do
 	fi
 done
 
-global.linux.bootargs.root="root=/dev/ram0 rdinit=${rdinit}"
+global.linux.bootargs.dyn.root="root=/dev/ram0 rdinit=${rdinit}"
defaultenv-2/base/bin/bootargs-root-jffs2 +1 -1
index 74d59af..a8eb5e7 100644
@@ -18,4 +18,4 @@ if [ -z "$mtd" ]; then
 	exit 1
 fi
 
-global.linux.bootargs.root="root=$mtd rootfstype=jffs2"
+global.linux.bootargs.dyn.root="root=$mtd rootfstype=jffs2"
defaultenv-2/base/bin/bootargs-root-nfs +1 -1
index 27bb6c4..355f93d 100644
@@ -17,4 +17,4 @@ if [ -n ${serverip} ]; then
 	nfsroot="$serverip:$nfsroot"
 fi
 
-global.linux.bootargs.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
defaultenv-2/base/bin/bootargs-root-ubi +1 -1
index fb7f328..4260336 100644
@@ -21,4 +21,4 @@ if [ -z "$mtd" ]; then
 	exit 1
 fi
 
-global.linux.bootargs.root="root=ubi0:$ubiroot ubi.mtd=$mtd rootfstype=ubifs"
+global.linux.bootargs.dyn.root="root=ubi0:$ubiroot ubi.mtd=$mtd rootfstype=ubifs"
defaultenv-2/base/bin/init +3 -2
index 9d7eb2e..8e8871d 100644
@@ -8,8 +8,9 @@ global autoboot_timeout=3
 global boot.default=net
 global allow_color=true
 global linux.bootargs.base
-global linux.bootargs.ip
-global linux.bootargs.root
+#linux.bootargs.dyn.* will be clearer at the beginning of boot
+global linux.bootargs.dyn.ip
+global linux.bootargs.dyn.root
 global editcmd=sedit
 
 /env/init/general
defaultenv-2/base/boot/initrd +1 -1
index 79a353a..7c44d07 100644
@@ -11,7 +11,7 @@ global.bootm.initrd="${path}/initramfs"
 bootargs-root-initrd
 #global.bootm.oftree=<path to oftree>
 
-global.linux.bootargs.root="root=/dev/ram0"
+global.linux.bootargs.dyn.root="root=/dev/ram0"
 
 #bootargs-root-nfs -n "<path on server>" -s <serverip>
 #bootargs-root-ubi -r <volume> -m <mtdname>
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 4/5 defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globarvar

In reply to Jean-Christophe PLAGNIOL-VILLARD

This is need for boot sequence to do not have the previous boot param.

---
 defaultenv-2/base/bin/boot |    4 ++++
 1 file changed, 4 insertions(+)
defaultenv-2/base/bin/boot +4 -0
index 4ebda3f..103eb87 100644
@@ -33,6 +33,10 @@ while getopt "vdhl" opt; do
 	fi
 done
 
+# clear linux.bootargs.dyn.* and bootm.*
+global -r linux.bootargs.dyn.
+global -r bootm.
+
 if [ $# = 0 ]; then
 	scr="$global.boot.default"
 else
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 5/5 defaultenv-2: add boot sequence

In reply to Jean-Christophe PLAGNIOL-VILLARD

Boot will boot run sequentially the script in /env/boot.d

if not global.boot.defaul or global.boot.defaul == seq start the boot sequence

---
 defaultenv-2/base/bin/boot     |   52 ++++++++++++++++++++++++++++++++++++----
 defaultenv-2/base/init/general |    2 +-
 2 files changed, 48 insertions(+), 6 deletions(-)
defaultenv-2/base/bin/boot +47 -5
index 103eb87..ade555d 100644
@@ -2,20 +2,39 @@
 
 verbose=
 dryrun=
+sequence=
 
 usage="
 $0 [OPTIONS] [source]\n
  -v  verbose\n
  -d  dryrun\n
  -l  list boot sources\n
+ -s  start boot sequence in /env/boot.d/\n
  -h  help"
 
+if [ ${global.allow_color} = "true" ]; then
+	. /env/data/ansi-colors
+	ECHO=-e
+fi
+
 for i in /env/boot/*; do
 	basename $i s
 	sources="$sources$s "
 done
 
-while getopt "vdhl" opt; do
+if [ -d /env/boot.d ]; then
+	sources="$sources\nboot sequence:"
+	for i in /env/boot.d/*; do
+		readlink -f $i s
+		basename $s link
+		basename $i s
+		sources="$sources\n $s -> $link"
+	done
+else
+	sources="$sources\nboot sequence:\nnone"
+fi
+
+while getopt "vdhls" opt; do
 	if [ ${opt} = v ]; then
 		if [ -n "$verbose" ]; then
 			verbose="-v -v"
@@ -23,7 +42,9 @@ while getopt "vdhl" opt; do
 			verbose="-v"
 		fi
 	elif [ ${opt} = d ]; then
-		dryrun=1
+		dryrun="-d"
+	elif [ ${opt} = s ]; then
+		sequence=1
 	elif [ ${opt} = l ]; then
 		echo -e "boot sources:\n$sources"
 		exit 0
@@ -43,12 +64,33 @@ else
 	scr="$1"
 fi
 
+if [ -n "$sequence" -o "x$src" = "xseq" ]; then
+	if [ ! -d /env/boot.d ]; then
+		echo ${ECHO} "${GREEN}boot sequence ${RED}none${NC}"
+		exit 1
+	fi
+	echo ${ECHO} "${GREEN}Start boot sequence${NC}"
+	for i in /env/boot.d/*; do
+		readlink -f $i s
+		basename $s link
+		basename $i s
+		msg="${GREEN}boot${NC} ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
+		echo ${ECHO} "${msg}"
+		boot $dryrun $s
+		echo ${ECHO} "${msg} ${RED}failled${NC}"
+		ret=$?
+	done
+	echo ${ECHO} "${GREEN}boot sequence ${RED}failled${NC}"
+	exit $ret
+fi
+
 if [ -n "$scr" ]; then
-	if [ ! -f /env/boot/$scr ]; then
-		echo -e "/env/boot/$scr does not exist.Valid choices:\n$sources"
+	if [ ! -f /env/boot.d/$scr -a ! -f /env/boot/$scr ]; then
+		echo -e "/env/boot/$scr or /env/boot.d/$scr does not exist.Valid choices:\n$sources"
 		exit
 	fi
-	/env/boot/$scr
+	[ -f /env/boot.d/$scr ] && /env/boot.d/$scr
+	[ -f /env/boot/$scr ] && /env/boot/$scr
 fi
 
 if [ -n "$dryrun" ]; then
defaultenv-2/base/init/general +1 -1
index 98a92d1..2c0bd74 100644
@@ -11,5 +11,5 @@ global.user=sha
 # timeout in seconds before the default boot entry is started
 global.autoboot_timeout=3
 
-# default boot entry (one of /env/boot/*)
+# default boot entry (one of /env/boot/*) or seq to start the sequence
 global.boot.default=net
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

Hi

Quoted 12 lines
defaultenv-2/base/bin/boot +1 -0
index 103eb87..ade555d 100644
@@ -2,20 +2,39 @@
 
 verbose=
 dryrun=
+sequence=
 
 usage="
 $0 [OPTIONS] [source]\n

defaultenv-2/base/bin/boot line 18

Quoted 10 lines
defaultenv-2/base/bin/boot +5 -0
  -v  verbose\n
  -d  dryrun\n
  -l  list boot sources\n
+ -s  start boot sequence in /env/boot.d/\n
  -h  help"
 
+if [ ${global.allow_color} = "true" ]; then
+       . /env/data/ansi-colors
+       ECHO=-e
+fi

Since you seem to be using global.allow_color in other places as well, wouldn't it be advisable to move the whole if-block into /env/data/ansi-colors and subsequently just source it whenever a hush script needs it?

Also why not generally use $ECHO in scripts, however along the lines of (inside /env/data/ansi-colors/):

if [ ${global.allow_color} = "true" ]; then

   # color definitions
   ECHO = "echo -e"
else
   ECHO = "echo"
fi

You then only invoke $ECHO instead of 'echo $ECHO'.

Quoted 23 lines
defaultenv-2/base/bin/boot +13 -1
 for i in /env/boot/*; do
        basename $i s
        sources="$sources$s "
 done
 
-while getopt "vdhl" opt; do
+if [ -d /env/boot.d ]; then
+       sources="$sources\nboot sequence:"
+       for i in /env/boot.d/*; do
+               readlink -f $i s
+               basename $s link
+               basename $i s
+               sources="$sources\n $s -> $link"
+       done
+else
+       sources="$sources\nboot sequence:\nnone"
+fi
+
+while getopt "vdhls" opt; do
        if [ ${opt} = v ]; then
                if [ -n "$verbose" ]; then
                        verbose="-v -v"

defaultenv-2/base/bin/boot while getopt "vdhl" opt; do · line 45

Quoted 5 lines
defaultenv-2/base/bin/boot +1 -1
@@ -23,7 +42,9 @@ while getopt "vdhl" opt; do
                        verbose="-v"
                fi
        elif [ ${opt} = d ]; then
-               dryrun=1
+               dryrun="-d"

Why this change?

Quoted 57 lines
defaultenv-2/base/bin/boot +26 -3
+       elif [ ${opt} = s ]; then
+               sequence=1
        elif [ ${opt} = l ]; then
                echo -e "boot sources:\n$sources"
                exit 0
@@ -43,12 +64,33 @@ else
        scr="$1"
 fi
 
+if [ -n "$sequence" -o "x$src" = "xseq" ]; then
+       if [ ! -d /env/boot.d ]; then
+               echo ${ECHO} "${GREEN}boot sequence ${RED}none${NC}"
+               exit 1
+       fi
+       echo ${ECHO} "${GREEN}Start boot sequence${NC}"
+       for i in /env/boot.d/*; do
+               readlink -f $i s
+               basename $s link
+               basename $i s
+               msg="${GREEN}boot${NC} ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
+               echo ${ECHO} "${msg}"
+               boot $dryrun $s
+               echo ${ECHO} "${msg} ${RED}failled${NC}"
+               ret=$?
+       done
+       echo ${ECHO} "${GREEN}boot sequence ${RED}failled${NC}"
+       exit $ret
+fi
+
 if [ -n "$scr" ]; then
-       if [ ! -f /env/boot/$scr ]; then
-               echo -e "/env/boot/$scr does not exist.Valid choices:\n$sources"
+       if [ ! -f /env/boot.d/$scr -a ! -f /env/boot/$scr ]; then
+               echo -e "/env/boot/$scr or /env/boot.d/$scr does not exist.Valid choices:\n$sources"
                exit
        fi
-       /env/boot/$scr
+       [ -f /env/boot.d/$scr ] && /env/boot.d/$scr
+       [ -f /env/boot/$scr ] && /env/boot/$scr
 fi
 
 if [ -n "$dryrun" ]; then
defaultenv-2/base/init/general +1 -2
index 98a92d1..2c0bd74 100644
@@ -11,5 +11,5 @@ global.user=sha
 # timeout in seconds before the default boot entry is started
 global.autoboot_timeout=3
 
-# default boot entry (one of /env/boot/*)
+# default boot entry (one of /env/boot/*) or seq to start the sequence
 global.boot.default=net
--

1.7.10.4

Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#9 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 17 lines · Jean-Christophe PLAGNIOL-VILLARD

Boot will boot run sequentially the script in /env/boot.d

if not global.boot.defaul or global.boot.defaul == seq start the boot sequence

---
 defaultenv-2/base/bin/boot     |   52 ++++++++++++++++++++++++++++++++++++----
 defaultenv-2/base/init/general |    2 +-
 2 files changed, 48 insertions(+), 6 deletions(-)
defaultenv-2/base/bin/boot +0 -0
index 103eb87..ade555d 100644
@@ -2,20 +2,39 @@
 

defaultenv-2/base/bin/boot line 12

Quoted 10 lines
defaultenv-2/base/bin/boot +2 -0
 verbose=
 dryrun=
+sequence=
 
 usage="
 $0 [OPTIONS] [source]\n
  -v  verbose\n
  -d  dryrun\n
  -l  list boot sources\n
+ -s  start boot sequence in /env/boot.d/\n

I think there should not be a dedicated option for this. Instead, it should by default start the boot sequence. global.boot.default could then be dropped.

Sascha

Quoted 97 lines
defaultenv-2/base/bin/boot +45 -5
  -h  help"
 
+if [ ${global.allow_color} = "true" ]; then
+	. /env/data/ansi-colors
+	ECHO=-e
+fi
+
 for i in /env/boot/*; do
 	basename $i s
 	sources="$sources$s "
 done
 
-while getopt "vdhl" opt; do
+if [ -d /env/boot.d ]; then
+	sources="$sources\nboot sequence:"
+	for i in /env/boot.d/*; do
+		readlink -f $i s
+		basename $s link
+		basename $i s
+		sources="$sources\n $s -> $link"
+	done
+else
+	sources="$sources\nboot sequence:\nnone"
+fi
+
+while getopt "vdhls" opt; do
 	if [ ${opt} = v ]; then
 		if [ -n "$verbose" ]; then
 			verbose="-v -v"
@@ -23,7 +42,9 @@ while getopt "vdhl" opt; do
 			verbose="-v"
 		fi
 	elif [ ${opt} = d ]; then
-		dryrun=1
+		dryrun="-d"
+	elif [ ${opt} = s ]; then
+		sequence=1
 	elif [ ${opt} = l ]; then
 		echo -e "boot sources:\n$sources"
 		exit 0
@@ -43,12 +64,33 @@ else
 	scr="$1"
 fi
 
+if [ -n "$sequence" -o "x$src" = "xseq" ]; then
+	if [ ! -d /env/boot.d ]; then
+		echo ${ECHO} "${GREEN}boot sequence ${RED}none${NC}"
+		exit 1
+	fi
+	echo ${ECHO} "${GREEN}Start boot sequence${NC}"
+	for i in /env/boot.d/*; do
+		readlink -f $i s
+		basename $s link
+		basename $i s
+		msg="${GREEN}boot${NC} ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
+		echo ${ECHO} "${msg}"
+		boot $dryrun $s
+		echo ${ECHO} "${msg} ${RED}failled${NC}"
+		ret=$?
+	done
+	echo ${ECHO} "${GREEN}boot sequence ${RED}failled${NC}"
+	exit $ret
+fi
+
 if [ -n "$scr" ]; then
-	if [ ! -f /env/boot/$scr ]; then
-		echo -e "/env/boot/$scr does not exist.Valid choices:\n$sources"
+	if [ ! -f /env/boot.d/$scr -a ! -f /env/boot/$scr ]; then
+		echo -e "/env/boot/$scr or /env/boot.d/$scr does not exist.Valid choices:\n$sources"
 		exit
 	fi
-	/env/boot/$scr
+	[ -f /env/boot.d/$scr ] && /env/boot.d/$scr
+	[ -f /env/boot/$scr ] && /env/boot/$scr
 fi
 
 if [ -n "$dryrun" ]; then
defaultenv-2/base/init/general +1 -1
index 98a92d1..2c0bd74 100644
@@ -11,5 +11,5 @@ global.user=sha
 # timeout in seconds before the default boot entry is started
 global.autoboot_timeout=3
 
-# default boot entry (one of /env/boot/*)
+# default boot entry (one of /env/boot/*) or seq to start the sequence
 global.boot.default=net
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw
Quoted 22 lines · Sascha Hauer
Quoted 21 lines · Jean-Christophe PLAGNIOL-VILLARD

Boot will boot run sequentially the script in /env/boot.d

if not global.boot.defaul or global.boot.defaul == seq start the boot sequence

---
 defaultenv-2/base/bin/boot     |   52 ++++++++++++++++++++++++++++++++++++----
 defaultenv-2/base/init/general |    2 +-
 2 files changed, 48 insertions(+), 6 deletions(-)
defaultenv-2/base/bin/boot +1 -0
index 103eb87..ade555d 100644
@@ -2,20 +2,39 @@
 
 verbose=
 dryrun=
+sequence=
 
Quoted 10 lines

defaultenv-2/base/bin/boot line 12

Quoted 6 lines
defaultenv-2/base/bin/boot +1 -0
 usage="
 $0 [OPTIONS] [source]\n
  -v  verbose\n
  -d  dryrun\n
  -l  list boot sources\n
+ -s  start boot sequence in /env/boot.d/\n

I think there should not be a dedicated option for this. Instead, it should by default start the boot sequence. global.boot.default could then be dropped.

I was thinking about it too

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox