mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/7] globalbar: add inline when not enabled
@ 2012-09-11 10:19 Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 2/7] globalvar: add support to set a value to of all globalvars beginning with 'match' Jean-Christophe PLAGNIOL-VILLARD
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/globalvar.h |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/globalvar.h b/include/globalvar.h
index 7cc3976..a127a05 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -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 */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/7] globalvar: add support to set a value to of all globalvars beginning with 'match'
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 10:19 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 3/7] defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globalvar Jean-Christophe PLAGNIOL-VILLARD
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

via c global_set_match and global -r

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/global.c   |   51 ++++++++++++++++++++++++++++++++++++++++-----------
 common/globalvar.c  |   10 ++++++++++
 include/globalvar.h |    3 +++
 3 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/commands/global.c b/commands/global.c
index de6b13e..b7c3743 100644
--- a/commands/global.c
+++ b/commands/global.c
@@ -24,39 +24,68 @@
 #include <command.h>
 #include <globalvar.h>
 #include <environment.h>
+#include <getopt.h>
 
-static int do_global(int argc, char *argv[])
+static int globalvar_set(char* name, char* value)
 {
 	int ret;
+
+	ret = globalvar_add_simple(name);
+
+	if (value) {
+		char *tmp = asprintf("global.%s", name);
+		ret = setenv(tmp, value);
+		free(tmp);
+	}
+
+	return ret ? 1 : 0;
+}
+
+static int do_global(int argc, char *argv[])
+{
+	int opt;
+	int do_set_match = 0;
 	char *value;
 
-	if (argc != 2)
+	while ((opt = getopt(argc, argv, "r")) > 0) {
+		switch (opt) {
+		case 'r':
+			do_set_match = 1;
+			break;
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+
+	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]);
+	if (do_set_match) {
+		if (!value)
+			value = "";
 
-	if (value) {
-		char *name = asprintf("global.%s", argv[1]);
-		ret = setenv(name, value);
-		free(name);
+		globalvar_set_match(argv[0], value);
+		return 0;
 	}
 
-	return ret ? 1 : 0;
+	return globalvar_set(argv[0], value);
 }
 
 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 set global variables",
 	BAREBOX_CMD_HELP(cmd_global_help)
 BAREBOX_CMD_END
diff --git a/common/globalvar.c b/common/globalvar.c
index 71296ff..a8aaa72 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -46,6 +46,16 @@ char *globalvar_get_match(const char *match, const char *seperator)
 	return val;
 }
 
+void globalvar_set_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
  *
diff --git a/include/globalvar.h b/include/globalvar.h
index a127a05..ddf885f 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -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_set_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_set_match(const char *match, const char *val) {}
 #endif
 
 #endif /* __GLOBALVAR_H */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/7] defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globalvar
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 2/7] globalvar: add support to set a value to of all globalvars beginning with 'match' Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 10:19 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 4/7] defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globalvar Jean-Christophe PLAGNIOL-VILLARD
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

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

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

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 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(-)

diff --git a/defaultenv-2/base/bin/bootargs-ip b/defaultenv-2/base/bin/bootargs-ip
index 15041c6..2d4486c 100644
--- a/defaultenv-2/base/bin/bootargs-ip
+++ b/defaultenv-2/base/bin/bootargs-ip
@@ -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
diff --git a/defaultenv-2/base/bin/bootargs-ip-barebox b/defaultenv-2/base/bin/bootargs-ip-barebox
index 986c142..5a3b984 100644
--- a/defaultenv-2/base/bin/bootargs-ip-barebox
+++ b/defaultenv-2/base/bin/bootargs-ip-barebox
@@ -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:"
diff --git a/defaultenv-2/base/bin/bootargs-ip-dhcp b/defaultenv-2/base/bin/bootargs-ip-dhcp
index c542b24..dec8ae4 100644
--- a/defaultenv-2/base/bin/bootargs-ip-dhcp
+++ b/defaultenv-2/base/bin/bootargs-ip-dhcp
@@ -2,4 +2,4 @@
 
 # Do dhcp in Linux
 
-global.linux.bootargs.ip="ip=dhcp"
+global.linux.bootargs.dyn.ip="ip=dhcp"
diff --git a/defaultenv-2/base/bin/bootargs-ip-none b/defaultenv-2/base/bin/bootargs-ip-none
index c010154..88aaa21 100644
--- a/defaultenv-2/base/bin/bootargs-ip-none
+++ b/defaultenv-2/base/bin/bootargs-ip-none
@@ -2,4 +2,4 @@
 
 # disable ip setup in Linux
 
-global.linux.bootargs.ip="ip=none"
+global.linux.bootargs.dyn.ip="ip=none"
diff --git a/defaultenv-2/base/bin/bootargs-root-disk b/defaultenv-2/base/bin/bootargs-root-disk
index df8750e..aa60cf3 100644
--- a/defaultenv-2/base/bin/bootargs-root-disk
+++ b/defaultenv-2/base/bin/bootargs-root-disk
@@ -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"
diff --git a/defaultenv-2/base/bin/bootargs-root-ext b/defaultenv-2/base/bin/bootargs-root-ext
index 45fcd5a..dbdddb9 100644
--- a/defaultenv-2/base/bin/bootargs-root-ext
+++ b/defaultenv-2/base/bin/bootargs-root-ext
@@ -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"
diff --git a/defaultenv-2/base/bin/bootargs-root-initrd b/defaultenv-2/base/bin/bootargs-root-initrd
index 7072cea..cc711a1 100644
--- a/defaultenv-2/base/bin/bootargs-root-initrd
+++ b/defaultenv-2/base/bin/bootargs-root-initrd
@@ -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}"
diff --git a/defaultenv-2/base/bin/bootargs-root-jffs2 b/defaultenv-2/base/bin/bootargs-root-jffs2
index 74d59af..a8eb5e7 100644
--- a/defaultenv-2/base/bin/bootargs-root-jffs2
+++ b/defaultenv-2/base/bin/bootargs-root-jffs2
@@ -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"
diff --git a/defaultenv-2/base/bin/bootargs-root-nfs b/defaultenv-2/base/bin/bootargs-root-nfs
index 27bb6c4..355f93d 100644
--- a/defaultenv-2/base/bin/bootargs-root-nfs
+++ b/defaultenv-2/base/bin/bootargs-root-nfs
@@ -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"
diff --git a/defaultenv-2/base/bin/bootargs-root-ubi b/defaultenv-2/base/bin/bootargs-root-ubi
index fb7f328..4260336 100644
--- a/defaultenv-2/base/bin/bootargs-root-ubi
+++ b/defaultenv-2/base/bin/bootargs-root-ubi
@@ -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"
diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init
index 9d7eb2e..8e8871d 100644
--- a/defaultenv-2/base/bin/init
+++ b/defaultenv-2/base/bin/init
@@ -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
diff --git a/defaultenv-2/base/boot/initrd b/defaultenv-2/base/boot/initrd
index 79a353a..7c44d07 100644
--- a/defaultenv-2/base/boot/initrd
+++ b/defaultenv-2/base/boot/initrd
@@ -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>
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/7] defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globalvar
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 2/7] globalvar: add support to set a value to of all globalvars beginning with 'match' Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 3/7] defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globalvar Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 10:19 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 5/7] echo: always allow to pass -e option Jean-Christophe PLAGNIOL-VILLARD
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

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

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 defaultenv-2/base/bin/boot |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index 4ebda3f..103eb87 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -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
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/7] echo: always allow to pass -e option
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 preceding siblings ...)
  2012-09-11 10:19 ` [PATCH 4/7] defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globalvar Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 10:19 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 6/7] defaultenv-2/ansi-colors: export color only if enable Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

This will allow to do not taint if not enabled

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/echo.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/commands/echo.c b/commands/echo.c
index a19d992..4a5c981 100644
--- a/commands/echo.c
+++ b/commands/echo.c
@@ -33,10 +33,9 @@ static int do_echo(int argc, char *argv[])
 	int fd = stdout, opt, newline = 1;
 	char *file = NULL;
 	int oflags = O_WRONLY | O_CREAT;
-#ifdef CONFIG_CMD_ECHO_E
 	char str[CONFIG_CBSIZE];
 	int process_escape = 0;
-#endif
+
 	/* We can't use getopt() here because we want to
 	 * echo all things we don't understand.
 	 */
@@ -66,11 +65,9 @@ static int do_echo(int argc, char *argv[])
 				goto no_optarg_out;
 			optind++;
 			break;
-#ifdef CONFIG_CMD_ECHO_E
 		case 'e':
-			process_escape = 1;
+			process_escape = IS_ENABLED(CONFIG_CMD_ECHO_E);
 			break;
-#endif
 		default:
 			goto exit_parse;
 		}
@@ -89,13 +86,12 @@ exit_parse:
 	for (i = optind; i < argc; i++) {
 		if (i > optind)
 			fputc(fd, ' ');
-#ifdef CONFIG_CMD_ECHO_E
 		if (process_escape) {
 			process_escape_sequence(argv[i], str, CONFIG_CBSIZE);
 			fputs(fd, str);
-		} else
-#endif
+		} else {
 			fputs(fd, argv[i]);
+		}
 	}
 
 	if (newline)
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/7] defaultenv-2/ansi-colors: export color only if enable
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
                   ` (3 preceding siblings ...)
  2012-09-11 10:19 ` [PATCH 5/7] echo: always allow to pass -e option Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 10:19 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 10:19 ` [PATCH 7/7] defaultenv-2: add boot sequence Jean-Christophe PLAGNIOL-VILLARD
  2012-09-11 11:21 ` [PATCH 1/7] globalbar: add inline when not enabled Sascha Hauer
  6 siblings, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

This will allow to do not check it everywhere

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 defaultenv-2/base/data/ansi-colors |    4 ++++
 defaultenv-2/menu/menu/mainmenu    |    4 +---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/defaultenv-2/base/data/ansi-colors b/defaultenv-2/base/data/ansi-colors
index c71b6b7..6365329 100644
--- a/defaultenv-2/base/data/ansi-colors
+++ b/defaultenv-2/base/data/ansi-colors
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+if [ ${global.allow_color} != "true" ]; then
+	exit
+fi
+
 # Colors
 export RED='\e[1;31m'
 export BLUE='\e[1;34m'
diff --git a/defaultenv-2/menu/menu/mainmenu b/defaultenv-2/menu/menu/mainmenu
index d7b0033..5bd7027 100644
--- a/defaultenv-2/menu/menu/mainmenu
+++ b/defaultenv-2/menu/menu/mainmenu
@@ -3,9 +3,7 @@
 savepath=$PATH
 export menupath=$PATH:/env/menu
 
-if [ ${global.allow_color} = "true" ]; then
-	. /env/data/ansi-colors
-fi
+. /env/data/ansi-colors
 
 while true; do
 	export PATH=${menupath}
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
                   ` (4 preceding siblings ...)
  2012-09-11 10:19 ` [PATCH 6/7] defaultenv-2/ansi-colors: export color only if enable Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 10:19 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-12  7:20   ` Sascha Hauer
  2012-09-11 11:21 ` [PATCH 1/7] globalbar: add inline when not enabled Sascha Hauer
  6 siblings, 1 reply; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 10:19 UTC (permalink / raw)
  To: barebox

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

drop global.boot.default as we start the boot sequence by default

update the current board using the defaultenv-2 at the sametime

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 .../arm/boards/crystalfontz-cfa10036/env/boot.d/01 |    1 +
 .../arm/boards/crystalfontz-cfa10036/env/boot.d/02 |    1 +
 .../arm/boards/crystalfontz-cfa10036/env/boot.d/03 |    1 +
 .../boards/crystalfontz-cfa10036/env/init/general  |    3 --
 .../boards/freescale-mx6-sabrelite/env/boot.d/01   |    1 +
 .../boards/freescale-mx6-sabrelite/env/boot.d/02   |    1 +
 arch/arm/boards/pcm038/env/boot.d/01               |    1 +
 arch/arm/boards/pcm038/env/boot.d/02               |    1 +
 arch/arm/boards/pcm038/env/boot.d/03               |    1 +
 arch/arm/boards/tqma53/env/boot.d/01               |    1 +
 arch/arm/boards/tqma53/env/boot.d/02               |    1 +
 common/Kconfig                                     |    2 +
 defaultenv-2/base/bin/boot                         |   51 +++++++++++++++++---
 defaultenv-2/base/init/general                     |    3 --
 14 files changed, 57 insertions(+), 12 deletions(-)
 create mode 120000 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
 create mode 120000 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
 create mode 120000 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
 create mode 120000 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
 create mode 120000 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
 create mode 120000 arch/arm/boards/pcm038/env/boot.d/01
 create mode 120000 arch/arm/boards/pcm038/env/boot.d/02
 create mode 120000 arch/arm/boards/pcm038/env/boot.d/03
 create mode 120000 arch/arm/boards/tqma53/env/boot.d/01
 create mode 120000 arch/arm/boards/tqma53/env/boot.d/02

diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01 b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
new file mode 120000
index 0000000..1e6fecc
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
@@ -0,0 +1 @@
+../boot/mmc-ext3
\ No newline at end of file
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02 b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
new file mode 120000
index 0000000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03 b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
new file mode 120000
index 0000000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/general b/arch/arm/boards/crystalfontz-cfa10036/env/init/general
index 5cb3a75..125de5d 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/env/init/general
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/init/general
@@ -7,6 +7,3 @@ fi
 
 # timeout in seconds before the default boot entry is started
 global.autoboot_timeout=3
-
-# default boot entry (one of /env/boot/*)
-global.boot.default=mmc-ext3
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01 b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
new file mode 120000
index 0000000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02 b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
new file mode 120000
index 0000000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/arch/arm/boards/pcm038/env/boot.d/01 b/arch/arm/boards/pcm038/env/boot.d/01
new file mode 120000
index 0000000..d1b275c
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/boot.d/01
@@ -0,0 +1 @@
+../boot/nand-ubi
\ No newline at end of file
diff --git a/arch/arm/boards/pcm038/env/boot.d/02 b/arch/arm/boards/pcm038/env/boot.d/02
new file mode 120000
index 0000000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/boot.d/02
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/pcm038/env/boot.d/03 b/arch/arm/boards/pcm038/env/boot.d/03
new file mode 120000
index 0000000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/boot.d/03
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/arch/arm/boards/tqma53/env/boot.d/01 b/arch/arm/boards/tqma53/env/boot.d/01
new file mode 120000
index 0000000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/tqma53/env/boot.d/01
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/tqma53/env/boot.d/02 b/arch/arm/boards/tqma53/env/boot.d/02
new file mode 120000
index 0000000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/tqma53/env/boot.d/02
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/common/Kconfig b/common/Kconfig
index b97392c..f411719 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -563,6 +563,8 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
 	select CMD_GLOBAL
 	select CMD_AUTOMOUNT
 	select CMD_BASENAME
+	select CMD_READLINK
+	select CMD_DIRNAME
 	select FLEXIBLE_BOOTARGS
 	prompt "Generic environment template"
 
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index 103eb87..68e9e89 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -2,6 +2,8 @@
 
 verbose=
 dryrun=
+# ensure sequence is init at something
+sequence=t
 
 usage="
 $0 [OPTIONS] [source]\n
@@ -10,11 +12,27 @@ $0 [OPTIONS] [source]\n
  -l  list boot sources\n
  -h  help"
 
+. /env/data/ansi-colors
+
 for i in /env/boot/*; do
 	basename $i s
 	sources="$sources$s "
 done
 
+if [ -d /env/boot.d ]; then
+	sources="$sources\n\nboot sequence:"
+	for i in /env/boot.d/*; do
+		readlink -f $i s
+		basename $s link
+		basename $i s
+		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
+	done
+else
+	sequence=n
+	sources="$sources\n\nboot sequence:\nnone"
+	echo "${RED}WARNING: boot sequence: none${NC}"
+fi
+
 while getopt "vdhl" opt; do
 	if [ ${opt} = v ]; then
 		if [ -n "$verbose" ]; then
@@ -23,7 +41,7 @@ while getopt "vdhl" opt; do
 			verbose="-v"
 		fi
 	elif [ ${opt} = d ]; then
-		dryrun=1
+		dryrun="-d"
 	elif [ ${opt} = l ]; then
 		echo -e "boot sources:\n$sources"
 		exit 0
@@ -37,18 +55,39 @@ done
 global -r linux.bootargs.dyn.
 global -r bootm.
 
-if [ $# = 0 ]; then
-	scr="$global.boot.default"
+if [ $# = 0 -a "x$sequence" = "xt" ]; then
+	sequence=y
 else
 	scr="$1"
 fi
 
+if [ "x$sequence" = "xy" ]; then
+	if [ ! -d /env/boot.d ]; then
+		echo -e "${GREEN}boot sequence ${RED}none${NC}"
+		exit 1
+	fi
+	echo -e "${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 -e "${msg}"
+		boot $dryrun $s
+		echo -e "${msg} ${RED}failled${NC}"
+		ret=$?
+	done
+	echo -e "${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
diff --git a/defaultenv-2/base/init/general b/defaultenv-2/base/init/general
index 98a92d1..e7fffdd 100644
--- a/defaultenv-2/base/init/general
+++ b/defaultenv-2/base/init/general
@@ -10,6 +10,3 @@ global.user=sha
 
 # timeout in seconds before the default boot entry is started
 global.autoboot_timeout=3
-
-# default boot entry (one of /env/boot/*)
-global.boot.default=net
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/7] globalbar: add inline when not enabled
  2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
                   ` (5 preceding siblings ...)
  2012-09-11 10:19 ` [PATCH 7/7] defaultenv-2: add boot sequence Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-11 11:21 ` Sascha Hauer
  2012-09-11 12:12   ` Jean-Christophe PLAGNIOL-VILLARD
  6 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2012-09-11 11:21 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Repeating my comment I made last time:

Subject: s/globalbar/globalvar/

Sascha

On Tue, Sep 11, 2012 at 12:19:21PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  include/globalvar.h |   20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/include/globalvar.h b/include/globalvar.h
> index 7cc3976..a127a05 100644
> --- a/include/globalvar.h
> +++ b/include/globalvar.h
> @@ -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 */
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/7] globalbar: add inline when not enabled
  2012-09-11 11:21 ` [PATCH 1/7] globalbar: add inline when not enabled Sascha Hauer
@ 2012-09-11 12:12   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-11 12:12 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 13:21 Tue 11 Sep     , Sascha Hauer wrote:
> Repeating my comment I made last time:
> 
> Subject: s/globalbar/globalvar/
> 
I change the oherone forget this one tag updated

Best Regards,
J.
> Sascha
> 
> On Tue, Sep 11, 2012 at 12:19:21PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  include/globalvar.h |   20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> > 
> > diff --git a/include/globalvar.h b/include/globalvar.h
> > index 7cc3976..a127a05 100644
> > --- a/include/globalvar.h
> > +++ b/include/globalvar.h
> > @@ -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 */
> > -- 
> > 1.7.10.4
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 
> -- 
> 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-11 10:19 ` [PATCH 7/7] defaultenv-2: add boot sequence Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-12  7:20   ` Sascha Hauer
  2012-09-12  9:01     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2012-09-12  7:20 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Tue, Sep 11, 2012 at 12:19:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Boot will boot run sequentially the script in /env/boot.d
> 
> diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
> index 103eb87..68e9e89 100644
> --- a/defaultenv-2/base/bin/boot
> +++ b/defaultenv-2/base/bin/boot
> @@ -2,6 +2,8 @@
>  
>  verbose=
>  dryrun=
> +# ensure sequence is init at something
> +sequence=t

This looks unnecessary.

>  
>  usage="
>  $0 [OPTIONS] [source]\n
> @@ -10,11 +12,27 @@ $0 [OPTIONS] [source]\n
>   -l  list boot sources\n
>   -h  help"
>  
> +. /env/data/ansi-colors
> +
>  for i in /env/boot/*; do
>  	basename $i s
>  	sources="$sources$s "
>  done
>  
> +if [ -d /env/boot.d ]; then
> +	sources="$sources\n\nboot sequence:"
> +	for i in /env/boot.d/*; do
> +		readlink -f $i s
> +		basename $s link
> +		basename $i s
> +		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
> +	done
> +else
> +	sequence=n
> +	sources="$sources\n\nboot sequence:\nnone"
> +	echo "${RED}WARNING: boot sequence: none${NC}"
> +fi
> +
>  while getopt "vdhl" opt; do
>  	if [ ${opt} = v ]; then
>  		if [ -n "$verbose" ]; then
> @@ -23,7 +41,7 @@ while getopt "vdhl" opt; do
>  			verbose="-v"
>  		fi
>  	elif [ ${opt} = d ]; then
> -		dryrun=1
> +		dryrun="-d"
>  	elif [ ${opt} = l ]; then
>  		echo -e "boot sources:\n$sources"
>  		exit 0
> @@ -37,18 +55,39 @@ done
>  global -r linux.bootargs.dyn.
>  global -r bootm.
>  
> -if [ $# = 0 ]; then
> -	scr="$global.boot.default"
> +if [ $# = 0 -a "x$sequence" = "xt" ]; then
> +	sequence=y
>  else
>  	scr="$1"
>  fi

You could merge the 'if [ -d /env/boot.d ]' above with this if/else. The
result would be easier to read IMO.
Also you don't seem to catch the case when no /env/boot.d/* exist and
nothing is given on the command line.

>  
> +if [ "x$sequence" = "xy" ]; then

This x quirk is not necessary anymore. Do if [ "$sequence" = y ]
instead.

> +	if [ ! -d /env/boot.d ]; then
> +		echo -e "${GREEN}boot sequence ${RED}none${NC}"
> +		exit 1
> +	fi
> +	echo -e "${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 -e "${msg}"
> +		boot $dryrun $s
> +		echo -e "${msg} ${RED}failled${NC}"
> +		ret=$?
> +	done
> +	echo -e "${GREEN}boot sequence ${RED}failled${NC}"

s/failled/failed/

> +	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"

You could add the missing whitespace between 'exist' and 'valid'

>  		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
> diff --git a/defaultenv-2/base/init/general b/defaultenv-2/base/init/general
> index 98a92d1..e7fffdd 100644
> --- a/defaultenv-2/base/init/general
> +++ b/defaultenv-2/base/init/general
> @@ -10,6 +10,3 @@ global.user=sha
>  
>  # timeout in seconds before the default boot entry is started
>  global.autoboot_timeout=3
> -
> -# default boot entry (one of /env/boot/*)
> -global.boot.default=net
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-12  7:20   ` Sascha Hauer
@ 2012-09-12  9:01     ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-12  9:44       ` Sascha Hauer
  0 siblings, 1 reply; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-12  9:01 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 09:20 Wed 12 Sep     , Sascha Hauer wrote:
> On Tue, Sep 11, 2012 at 12:19:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Boot will boot run sequentially the script in /env/boot.d
> > 
> > diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
> > index 103eb87..68e9e89 100644
> > --- a/defaultenv-2/base/bin/boot
> > +++ b/defaultenv-2/base/bin/boot
> > @@ -2,6 +2,8 @@
> >  
> >  verbose=
> >  dryrun=
> > +# ensure sequence is init at something
> > +sequence=t
> 
> This looks unnecessary.
I beleive it too but 
no as you run boot again the sequence keep the previous set I set it after
trial
> 
> >  
> >  usage="
> >  $0 [OPTIONS] [source]\n
> > @@ -10,11 +12,27 @@ $0 [OPTIONS] [source]\n
> >   -l  list boot sources\n
> >   -h  help"
> >  
> > +. /env/data/ansi-colors
> > +
> >  for i in /env/boot/*; do
> >  	basename $i s
> >  	sources="$sources$s "
> >  done
> >  
> > +if [ -d /env/boot.d ]; then
> > +	sources="$sources\n\nboot sequence:"
> > +	for i in /env/boot.d/*; do
> > +		readlink -f $i s
> > +		basename $s link
> > +		basename $i s
> > +		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
> > +	done
> > +else
> > +	sequence=n
> > +	sources="$sources\n\nboot sequence:\nnone"
> > +	echo "${RED}WARNING: boot sequence: none${NC}"
> > +fi
> > +
> >  while getopt "vdhl" opt; do
> >  	if [ ${opt} = v ]; then
> >  		if [ -n "$verbose" ]; then
> > @@ -23,7 +41,7 @@ while getopt "vdhl" opt; do
> >  			verbose="-v"
> >  		fi
> >  	elif [ ${opt} = d ]; then
> > -		dryrun=1
> > +		dryrun="-d"
> >  	elif [ ${opt} = l ]; then
> >  		echo -e "boot sources:\n$sources"
> >  		exit 0
> > @@ -37,18 +55,39 @@ done
> >  global -r linux.bootargs.dyn.
> >  global -r bootm.
> >  
> > -if [ $# = 0 ]; then
> > -	scr="$global.boot.default"
> > +if [ $# = 0 -a "x$sequence" = "xt" ]; then
> > +	sequence=y
> >  else
> >  	scr="$1"
> >  fi
> 
> You could merge the 'if [ -d /env/boot.d ]' above with this if/else. The
> result would be easier to read IMO.
> Also you don't seem to catch the case when no /env/boot.d/* exist and
> nothing is given on the command line.
the idea it to check bot /env/boot.d and /env/boot as you may want to boot
something no in the boot sequence but for test as example
> 
> >  
> > +if [ "x$sequence" = "xy" ]; then
> 
> This x quirk is not necessary anymore. Do if [ "$sequence" = y ]
> instead.
> 
> > +	if [ ! -d /env/boot.d ]; then
> > +		echo -e "${GREEN}boot sequence ${RED}none${NC}"
> > +		exit 1
> > +	fi
> > +	echo -e "${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 -e "${msg}"
> > +		boot $dryrun $s
> > +		echo -e "${msg} ${RED}failled${NC}"
> > +		ret=$?
> > +	done
> > +	echo -e "${GREEN}boot sequence ${RED}failled${NC}"
> 
> s/failled/failed/
> 
> > +	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"
> 
> You could add the missing whitespace between 'exist' and 'valid'
> 
> >  		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
> > diff --git a/defaultenv-2/base/init/general b/defaultenv-2/base/init/general
> > index 98a92d1..e7fffdd 100644
> > --- a/defaultenv-2/base/init/general
> > +++ b/defaultenv-2/base/init/general
> > @@ -10,6 +10,3 @@ global.user=sha
> >  
> >  # timeout in seconds before the default boot entry is started
> >  global.autoboot_timeout=3
> > -
> > -# default boot entry (one of /env/boot/*)
> > -global.boot.default=net
> > -- 
> > 1.7.10.4
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 
> -- 
> 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-12  9:01     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-12  9:44       ` Sascha Hauer
  2012-09-12 10:42         ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-13 17:16         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 15+ messages in thread
From: Sascha Hauer @ 2012-09-12  9:44 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Wed, Sep 12, 2012 at 11:01:28AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 09:20 Wed 12 Sep     , Sascha Hauer wrote:
> > On Tue, Sep 11, 2012 at 12:19:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > Boot will boot run sequentially the script in /env/boot.d
> > > 
> > > diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
> > > index 103eb87..68e9e89 100644
> > > --- a/defaultenv-2/base/bin/boot
> > > +++ b/defaultenv-2/base/bin/boot
> > > @@ -2,6 +2,8 @@
> > >  
> > >  verbose=
> > >  dryrun=
> > > +# ensure sequence is init at something
> > > +sequence=t
> > 
> > This looks unnecessary.
> I beleive it too but 
> no as you run boot again the sequence keep the previous set I set it after
> trial

Then you must have exported it from the command line before calling the
script. Initializing variables is a good idea, but you should set it to
be empty.

> > 
> > >  
> > >  usage="
> > >  $0 [OPTIONS] [source]\n
> > > @@ -10,11 +12,27 @@ $0 [OPTIONS] [source]\n
> > >   -l  list boot sources\n
> > >   -h  help"
> > >  
> > > +. /env/data/ansi-colors
> > > +
> > >  for i in /env/boot/*; do
> > >  	basename $i s
> > >  	sources="$sources$s "
> > >  done
> > >  
> > > +if [ -d /env/boot.d ]; then
> > > +	sources="$sources\n\nboot sequence:"
> > > +	for i in /env/boot.d/*; do
> > > +		readlink -f $i s
> > > +		basename $s link
> > > +		basename $i s
> > > +		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
> > > +	done
> > > +else
> > > +	sequence=n
> > > +	sources="$sources\n\nboot sequence:\nnone"
> > > +	echo "${RED}WARNING: boot sequence: none${NC}"

-e missing here.

> > > +fi
> > > +
> > >  while getopt "vdhl" opt; do
> > >  	if [ ${opt} = v ]; then
> > >  		if [ -n "$verbose" ]; then
> > > @@ -23,7 +41,7 @@ while getopt "vdhl" opt; do
> > >  			verbose="-v"
> > >  		fi
> > >  	elif [ ${opt} = d ]; then
> > > -		dryrun=1
> > > +		dryrun="-d"
> > >  	elif [ ${opt} = l ]; then
> > >  		echo -e "boot sources:\n$sources"
> > >  		exit 0
> > > @@ -37,18 +55,39 @@ done
> > >  global -r linux.bootargs.dyn.
> > >  global -r bootm.
> > >  
> > > -if [ $# = 0 ]; then
> > > -	scr="$global.boot.default"
> > > +if [ $# = 0 -a "x$sequence" = "xt" ]; then
> > > +	sequence=y
> > >  else
> > >  	scr="$1"
> > >  fi
> > 
> > You could merge the 'if [ -d /env/boot.d ]' above with this if/else. The
> > result would be easier to read IMO.
> > Also you don't seem to catch the case when no /env/boot.d/* exist and
> > nothing is given on the command line.
> the idea it to check bot /env/boot.d and /env/boot as you may want to boot
> something no in the boot sequence but for test as example

> > 
> > >  
> > > +if [ "x$sequence" = "xy" ]; then
> > 
> > This x quirk is not necessary anymore. Do if [ "$sequence" = y ]
> > instead.
> > 
> > > +	if [ ! -d /env/boot.d ]; then
> > > +		echo -e "${GREEN}boot sequence ${RED}none${NC}"
> > > +		exit 1
> > > +	fi
> > > +	echo -e "${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 -e "${msg}"
> > > +		boot $dryrun $s
> > > +		echo -e "${msg} ${RED}failled${NC}"
> > > +		ret=$?
> > > +	done
> > > +	echo -e "${GREEN}boot sequence ${RED}failled${NC}"
> > 
> > s/failled/failed/
> > 
> > > +	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

This check does not work as expected, probably a bug in the test
command.

Check out this:


#!/bin/sh

verbose=
dryrun=

usage="
$0 [OPTIONS] [source]\n
 -v  verbose\n
 -d  dryrun\n
 -l  list boot sources\n
 -h  help"

. /env/data/ansi-colors

for i in /env/boot/*; do
	basename $i s
	sources="$sources$s "
done

if [ -d /env/boot.d ]; then
	sources="$sources\n\nboot sequence:"
	for i in /env/boot.d/*; do
		readlink -f $i s
		basename $s link
		basename $i s
		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
	done
	sequence=y
else
	sources="$sources\n\nboot sequence:\nnone"
	echo -e "${RED}WARNING: boot sequence: none${NC}"
	sequence=n
fi

while getopt "vdhl" opt; do
	if [ ${opt} = v ]; then
		if [ -n "$verbose" ]; then
			verbose="-v -v"
		else
			verbose="-v"
		fi
	elif [ ${opt} = d ]; then
		dryrun="-d"
	elif [ ${opt} = l ]; then
		echo -e "boot sources:\n$sources"
		exit 0
	elif [ ${opt} = h ]; then
		echo -e "$usage"
		exit 0
	fi
done

# clear linux.bootargs.dyn.* and bootm.*
global -r linux.bootargs.dyn.
global -r bootm.

if [ $# != 0 ]; then
	sequence=n
fi

if [ "$sequence" = y ]; then
	if [ ! -d /env/boot.d ]; then
		echo -e "${GREEN}boot sequence ${RED}none${NC}"
		exit 1
	fi
	echo -e "${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 -e "${msg}"
		boot $dryrun $s
		echo -e "${msg} ${RED}failled${NC}"
		ret=$?
	done
	echo -e "${GREEN}boot sequence ${RED}failed${NC}"
	exit $ret
else
	file=$1
	scr=
	echo -e "${GREEN}booting ${YELLOW}$file${NC}"
	[ -f /env/boot.d/$file ] && scr=/env/boot.d/$file
	[ -f /env/boot/$file ] && scr=/env/boot/$file

	if [ -z "$scr" ]; then
		echo -e "/env/boot/$file or /env/boot.d/$file does not exist. Valid choices:\n$sources"
		exit
	fi
	/env/boot/$scr
fi

if [ -n "$dryrun" ]; then
	exit 0
fi

bootm $verbose

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-12  9:44       ` Sascha Hauer
@ 2012-09-12 10:42         ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-12 10:55           ` Sascha Hauer
  2012-09-13 17:16         ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-12 10:42 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 11:44 Wed 12 Sep     , Sascha Hauer wrote:
> On Wed, Sep 12, 2012 at 11:01:28AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 09:20 Wed 12 Sep     , Sascha Hauer wrote:
> > > On Tue, Sep 11, 2012 at 12:19:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > Boot will boot run sequentially the script in /env/boot.d
> > > > 
> > > > diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
> > > > index 103eb87..68e9e89 100644
> > > > --- a/defaultenv-2/base/bin/boot
> > > > +++ b/defaultenv-2/base/bin/boot
> > > > @@ -2,6 +2,8 @@
> > > >  
> > > >  verbose=
> > > >  dryrun=
> > > > +# ensure sequence is init at something
> > > > +sequence=t
> > > 
> > > This looks unnecessary.
> > I beleive it too but 
> > no as you run boot again the sequence keep the previous set I set it after
> > trial
> 
> Then you must have exported it from the command line before calling the
> script. Initializing variables is a good idea, but you should set it to
> be empty.
agreed except this does not work that's why I for to a value

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-12 10:42         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-12 10:55           ` Sascha Hauer
  0 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2012-09-12 10:55 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Wed, Sep 12, 2012 at 12:42:34PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 11:44 Wed 12 Sep     , Sascha Hauer wrote:
> > On Wed, Sep 12, 2012 at 11:01:28AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 09:20 Wed 12 Sep     , Sascha Hauer wrote:
> > > > On Tue, Sep 11, 2012 at 12:19:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > Boot will boot run sequentially the script in /env/boot.d
> > > > > 
> > > > > diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
> > > > > index 103eb87..68e9e89 100644
> > > > > --- a/defaultenv-2/base/bin/boot
> > > > > +++ b/defaultenv-2/base/bin/boot
> > > > > @@ -2,6 +2,8 @@
> > > > >  
> > > > >  verbose=
> > > > >  dryrun=
> > > > > +# ensure sequence is init at something
> > > > > +sequence=t
> > > > 
> > > > This looks unnecessary.
> > > I beleive it too but 
> > > no as you run boot again the sequence keep the previous set I set it after
> > > trial
> > 
> > Then you must have exported it from the command line before calling the
> > script. Initializing variables is a good idea, but you should set it to
> > be empty.
> agreed except this does not work that's why I for to a value

What exactly does not work? Can you give an example script and how you
call it?

Sascha

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] defaultenv-2: add boot sequence
  2012-09-12  9:44       ` Sascha Hauer
  2012-09-12 10:42         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-13 17:16         ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 15+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-13 17:16 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 11:44 Wed 12 Sep     , Sascha Hauer wrote:
> On Wed, Sep 12, 2012 at 11:01:28AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 09:20 Wed 12 Sep     , Sascha Hauer wrote:
> > > On Tue, Sep 11, 2012 at 12:19:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > Boot will boot run sequentially the script in /env/boot.d
> > > > 
> > > > diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
> > > > index 103eb87..68e9e89 100644
> > > > --- a/defaultenv-2/base/bin/boot
> > > > +++ b/defaultenv-2/base/bin/boot
> > > > @@ -2,6 +2,8 @@
> > > >  
> > > >  verbose=
> > > >  dryrun=
> > > > +# ensure sequence is init at something
> > > > +sequence=t
> > > 
> > > This looks unnecessary.
> > I beleive it too but 
> > no as you run boot again the sequence keep the previous set I set it after
> > trial
> 
> Then you must have exported it from the command line before calling the
> script. Initializing variables is a good idea, but you should set it to
> be empty.
> 
> > > 
> > > >  
> > > >  usage="
> > > >  $0 [OPTIONS] [source]\n
> > > > @@ -10,11 +12,27 @@ $0 [OPTIONS] [source]\n
> > > >   -l  list boot sources\n
> > > >   -h  help"
> > > >  
> > > > +. /env/data/ansi-colors
> > > > +
> > > >  for i in /env/boot/*; do
> > > >  	basename $i s
> > > >  	sources="$sources$s "
> > > >  done
> > > >  
> > > > +if [ -d /env/boot.d ]; then
> > > > +	sources="$sources\n\nboot sequence:"
> > > > +	for i in /env/boot.d/*; do
> > > > +		readlink -f $i s
> > > > +		basename $s link
> > > > +		basename $i s
> > > > +		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
> > > > +	done
> > > > +else
> > > > +	sequence=n
> > > > +	sources="$sources\n\nboot sequence:\nnone"
> > > > +	echo "${RED}WARNING: boot sequence: none${NC}"
> 
> -e missing here.
> 
> > > > +fi
> > > > +
> > > >  while getopt "vdhl" opt; do
> > > >  	if [ ${opt} = v ]; then
> > > >  		if [ -n "$verbose" ]; then
> > > > @@ -23,7 +41,7 @@ while getopt "vdhl" opt; do
> > > >  			verbose="-v"
> > > >  		fi
> > > >  	elif [ ${opt} = d ]; then
> > > > -		dryrun=1
> > > > +		dryrun="-d"
> > > >  	elif [ ${opt} = l ]; then
> > > >  		echo -e "boot sources:\n$sources"
> > > >  		exit 0
> > > > @@ -37,18 +55,39 @@ done
> > > >  global -r linux.bootargs.dyn.
> > > >  global -r bootm.
> > > >  
> > > > -if [ $# = 0 ]; then
> > > > -	scr="$global.boot.default"
> > > > +if [ $# = 0 -a "x$sequence" = "xt" ]; then
> > > > +	sequence=y
> > > >  else
> > > >  	scr="$1"
> > > >  fi
> > > 
> > > You could merge the 'if [ -d /env/boot.d ]' above with this if/else. The
> > > result would be easier to read IMO.
> > > Also you don't seem to catch the case when no /env/boot.d/* exist and
> > > nothing is given on the command line.
> > the idea it to check bot /env/boot.d and /env/boot as you may want to boot
> > something no in the boot sequence but for test as example
> 
> > > 
> > > >  
> > > > +if [ "x$sequence" = "xy" ]; then
> > > 
> > > This x quirk is not necessary anymore. Do if [ "$sequence" = y ]
> > > instead.
> > > 
> > > > +	if [ ! -d /env/boot.d ]; then
> > > > +		echo -e "${GREEN}boot sequence ${RED}none${NC}"
> > > > +		exit 1
> > > > +	fi
> > > > +	echo -e "${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 -e "${msg}"
> > > > +		boot $dryrun $s
> > > > +		echo -e "${msg} ${RED}failled${NC}"
> > > > +		ret=$?
> > > > +	done
> > > > +	echo -e "${GREEN}boot sequence ${RED}failled${NC}"
> > > 
> > > s/failled/failed/
> > > 
> > > > +	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
> 
> This check does not work as expected, probably a bug in the test
> command.
> 
> Check out this:
> 
> 
> #!/bin/sh
> 
> verbose=
> dryrun=
> 
> usage="
> $0 [OPTIONS] [source]\n
>  -v  verbose\n
>  -d  dryrun\n
>  -l  list boot sources\n
>  -h  help"
> 
> . /env/data/ansi-colors
> 
> for i in /env/boot/*; do
> 	basename $i s
> 	sources="$sources$s "
> done
> 
> if [ -d /env/boot.d ]; then
> 	sources="$sources\n\nboot sequence:"
> 	for i in /env/boot.d/*; do
> 		readlink -f $i s
> 		basename $s link
> 		basename $i s
> 		sources="$sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}"
> 	done
> 	sequence=y
> else
> 	sources="$sources\n\nboot sequence:\nnone"
> 	echo -e "${RED}WARNING: boot sequence: none${NC}"
> 	sequence=n
> fi
> 
> while getopt "vdhl" opt; do
> 	if [ ${opt} = v ]; then
> 		if [ -n "$verbose" ]; then
> 			verbose="-v -v"
> 		else
> 			verbose="-v"
> 		fi
> 	elif [ ${opt} = d ]; then
> 		dryrun="-d"
> 	elif [ ${opt} = l ]; then
> 		echo -e "boot sources:\n$sources"
> 		exit 0
> 	elif [ ${opt} = h ]; then
> 		echo -e "$usage"
> 		exit 0
> 	fi
> done
> 
> # clear linux.bootargs.dyn.* and bootm.*
> global -r linux.bootargs.dyn.
> global -r bootm.
> 
> if [ $# != 0 ]; then
> 	sequence=n
> fi
> 
> if [ "$sequence" = y ]; then
> 	if [ ! -d /env/boot.d ]; then
> 		echo -e "${GREEN}boot sequence ${RED}none${NC}"
> 		exit 1
> 	fi
> 	echo -e "${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 -e "${msg}"
> 		boot $dryrun $s
> 		echo -e "${msg} ${RED}failled${NC}"
> 		ret=$?
> 	done
> 	echo -e "${GREEN}boot sequence ${RED}failed${NC}"
> 	exit $ret
> else
> 	file=$1
> 	scr=
> 	echo -e "${GREEN}booting ${YELLOW}$file${NC}"
> 	[ -f /env/boot.d/$file ] && scr=/env/boot.d/$file
> 	[ -f /env/boot/$file ] && scr=/env/boot/$file
> 
> 	if [ -z "$scr" ]; then
> 		echo -e "/env/boot/$file or /env/boot.d/$file does not exist. Valid choices:\n$sources"
> 		exit
> 	fi
> 	/env/boot/$scr
	$src

and it work

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-09-13 17:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-11 10:19 [PATCH 1/7] globalbar: add inline when not enabled Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 10:19 ` [PATCH 2/7] globalvar: add support to set a value to of all globalvars beginning with 'match' Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 10:19 ` [PATCH 3/7] defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globalvar Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 10:19 ` [PATCH 4/7] defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globalvar Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 10:19 ` [PATCH 5/7] echo: always allow to pass -e option Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 10:19 ` [PATCH 6/7] defaultenv-2/ansi-colors: export color only if enable Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 10:19 ` [PATCH 7/7] defaultenv-2: add boot sequence Jean-Christophe PLAGNIOL-VILLARD
2012-09-12  7:20   ` Sascha Hauer
2012-09-12  9:01     ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-12  9:44       ` Sascha Hauer
2012-09-12 10:42         ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-12 10:55           ` Sascha Hauer
2012-09-13 17:16         ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 11:21 ` [PATCH 1/7] globalbar: add inline when not enabled Sascha Hauer
2012-09-11 12:12   ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox