* [PATCH 1/1] defaultenv-2: add boot sequence
@ 2013-02-15 18:29 Jean-Christophe PLAGNIOL-VILLARD
2013-02-18 9:57 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-15 18:29 UTC (permalink / raw)
To: barebox
Boot will boot run sequentially the script in /env/boot.d
if not global.boot.default or global.boot.default == seq
or -s is sepecified
start the boot sequence
we do not boot the boot sequence by default t keep retro compatibility
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
common/Kconfig | 2 +
defaultenv-2/base/bin/_boot | 42 +++++++++++++++
defaultenv-2/base/bin/boot | 78 ++++++++++++++++++++-------
| 6 +--
4 files changed, 104 insertions(+), 24 deletions(-)
create mode 100644 defaultenv-2/base/bin/_boot
diff --git a/common/Kconfig b/common/Kconfig
index 3a55e01..683460b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -532,6 +532,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
new file mode 100644
index 0000000..a9a6799
--- /dev/null
+++ b/defaultenv-2/base/bin/_boot
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+verbose=
+dryrun=
+
+. /env/data/ansi-colors
+
+# clear linux.bootargs.dyn.* and bootm.*
+global -r linux.bootargs.dyn.
+global -r bootm.
+
+while getopt "vdl" opt; do
+ if [ ${opt} = v ]; then
+ if [ -n "$verbose" ]; then
+ verbose="-v -v"
+ else
+ verbose="-v"
+ fi
+ elif [ ${opt} = d ]; then
+ dryrun="-d"
+ fi
+done
+
+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
+ exit 2
+fi
+
+$scr
+
+if [ -n "$dryrun" ]; then
+ exit 0
+fi
+
+${global.bootm.image} $verbose
+bootm $verbose
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index ebbd951..746607e 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -2,20 +2,38 @@
verbose=
dryrun=
+bootsequence=n
usage="
$0 [OPTIONS] [source]\n
-v verbose\n
-d dryrun\n
-l list boot sources\n
+ -s start the boot sequence\n
-h help"
+. /env/data/ansi-colors
+
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\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
+ bootsequence=y
+else
+ sources="$sources\n\nboot sequence:\n${GREEN}none${NC}"
+ bootsequence=n
+fi
+
+while getopt "vdhls" opt; do
if [ ${opt} = v ]; then
if [ -n "$verbose" ]; then
verbose="-v -v"
@@ -23,7 +41,9 @@ while getopt "vdhl" opt; do
verbose="-v"
fi
elif [ ${opt} = d ]; then
- dryrun=1
+ dryrun="-d"
+ elif [ ${opt} = s ]; then
+ do_sequence=y
elif [ ${opt} = l ]; then
echo -e "boot sources:\n$sources"
exit 0
@@ -33,26 +53,46 @@ while getopt "vdhl" opt; do
fi
done
-# clear linux.bootargs.dyn.* and bootm.*
-global -r linux.bootargs.dyn.
-global -r bootm.
+boot=$1
-if [ $# = 0 ]; then
- scr="$global.boot.default"
+if [ $# != 0 ]; then
+ do_sequence=n
else
- scr="$1"
-fi
-
-if [ -n "$scr" ]; then
- if [ ! -f /env/boot/$scr ]; then
- echo -e "/env/boot/$scr does not exist. Valid choices:\n$sources"
- exit
+ if [ "${global.boot.default}" = "seq" -o "${global.boot.default}" = "" ]; then
+ do_sequence=y
+ else
+ boot=${global.boot.default}
+ do_sequence=n
fi
- /env/boot/$scr
fi
-if [ -n "$dryrun" ]; then
- exit 0
+{if [ "${do_sequence}" = y ]; then
+ if [ "${bootsequence}" != y ]; 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 $boot link
+ basename $i boot
+ msg="${GREEN}boot${NC} ${YELLOW}${boot}${NC} -> ${CYAN}${link}${NC}"
+ echo -e "${msg}"
+ _boot $verbose $dryrun $boot
+ ret=$?
+ echo ${ret}
+ if [ $ret -eq 2 ]; then
+ echo -e "${RED}/env/boot/${boot}{${NC} or ${RED}/env/boot.d/${boot}${NC} does not exist. Valid choices:\n$sources"
+ fi
+ echo -e "${msg} ${RED}failled${NC}"
+ done
+ echo -e "${GREEN}boot sequence ${RED}failed${NC}"
+ exit $ret
+else
+ _boot $verbose $dryrun $boot
+ ret=$?
+ if [ $ret -eq 2 ]; then
+ echo -e "${RED}/env/boot/${boot}{${NC} or ${RED}/env/boot.d/${boot}${NC} does not exist. Valid choices:\n$sources"
+ fi
+ exit $ret
fi
-
-bootm $verbose
--git a/defaultenv-2/menu/menu/boot-entries-collect b/defaultenv-2/menu/menu/boot-entries-collect
index c066c93..b0d3d9f 100644
--- a/defaultenv-2/menu/menu/boot-entries-collect
+++ b/defaultenv-2/menu/menu/boot-entries-collect
@@ -2,12 +2,8 @@
cd /env/boot
-./$global.boot.default menu
-
for i in *; do
- if [ "$i" != "$global.boot.default" ]; then
- ./$i menu
- fi
+ ./$i menu
done
cd /
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] defaultenv-2: add boot sequence
2013-02-15 18:29 [PATCH 1/1] defaultenv-2: add boot sequence Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-18 9:57 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-02-18 9:57 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Fri, Feb 15, 2013 at 07:29:32PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Boot will boot run sequentially the script in /env/boot.d
>
> if not global.boot.default or global.boot.default == seq
> or -s is sepecified
> start the boot sequence
>
> we do not boot the boot sequence by default t keep retro compatibility
This patch is too big, does multiple things and it's not clear to me how
it's supposed to work. Trying it resulted in error messages from the
basename command.
I also don't understand why you want to implement this using links which
makes the whole stuff very complicated. Why don't you just allow to pass
in multiple boot sources?
The following is not ready to be committed, but it should be able to
boot in a sequence in a much more straight forward way.
Sascha
8<------------------------------------------------
From 656303af01f9a686aa33bbe353aff5d9ab5d58a5 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Mon, 18 Feb 2013 10:52:36 +0100
Subject: [PATCH] add bootsequence support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/hush.c | 21 +++++++++++++++++++++
defaultenv-2/base/bin/boot | 28 +++++++++++++++-------------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/common/hush.c b/common/hush.c
index 1f468f6..2d52372 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -335,6 +335,19 @@ static int b_addchr(o_string *o, int ch)
return 0;
}
+static int b_addstr(o_string *o, const char *str)
+{
+ int ret;
+
+ while (*str) {
+ ret = b_addchr(o, *str++);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static void b_reset(o_string *o)
{
o->length = 0;
@@ -1406,6 +1419,14 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
}
b_addchr(dest, SPECIAL_VAR_SYMBOL);
break;
+ case '*':
+ for (i = 1; i < ctx->global_argc; i++) {
+ b_addstr(dest, ctx->global_argv[i]);
+ b_addchr(dest, ' ');
+ }
+
+ advance = 1;
+ break;
default:
b_addchr(dest, '$');
}
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index ebbd951..d5cae0f 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -33,26 +33,28 @@ 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
- scr="$1"
+ scr="$*"
fi
-if [ -n "$scr" ]; then
- if [ ! -f /env/boot/$scr ]; then
+for i in $scr; do
+ echo $i
+
+ # clear linux.bootargs.dyn.* and bootm.*
+ global -r linux.bootargs.dyn.
+ global -r bootm.
+
+ if [ ! -f /env/boot/$i ]; then
echo -e "/env/boot/$scr does not exist. Valid choices:\n$sources"
exit
fi
- /env/boot/$scr
-fi
+ /env/boot/$i
-if [ -n "$dryrun" ]; then
- exit 0
-fi
+ if [ -n "$dryrun" ]; then
+ exit 0
+ fi
-bootm $verbose
+ bootm $verbose
+done
--
1.7.10.4
--
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] 2+ messages in thread
end of thread, other threads:[~2013-02-18 9:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 18:29 [PATCH 1/1] defaultenv-2: add boot sequence Jean-Christophe PLAGNIOL-VILLARD
2013-02-18 9:57 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox