diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-02-18 19:44:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-05 11:51:35 +0100 |
commit | 8be08d9cf2e9097308be4e1d39a4fd7d357356b5 (patch) | |
tree | fe0aedd51011d4da690095afdd54daf5eb45b8eb /defaultenv-2/base/bin/boot | |
parent | 94e71b843f6456abacc2fe76a5c375a461fabdf7 (diff) | |
download | barebox-8be08d9cf2e9097308be4e1d39a4fd7d357356b5.tar.gz barebox-8be08d9cf2e9097308be4e1d39a4fd7d357356b5.tar.xz |
defaultenv-2: add boot sequence
This allows to boot a sequence of boot entries until one succeeds.
boot sources can be passed in $global.boot.default, which is now treated
as a list. Also a list of boot entries can be specified as arguments
to the boot script. The entries can be:
- a plain filename from /env/boot/
- a full path to an arbitrary file
- a directory containing boot entries
With this this command:
boot net nand-ubi /env/boot.d
would first use the /env/boot/net entry, if this fails the /env/boot/nand-ubi
entry and if this also fails the files from /env/boot.d/ (which could also
be links to boot scripts)
To make the above the default, global.boot.default would be specified as:
global.boot.default="net nand-ubi /env/boot.d"
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'defaultenv-2/base/bin/boot')
-rw-r--r-- | defaultenv-2/base/bin/boot | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot index ebbd951703..f7f460ea06 100644 --- a/defaultenv-2/base/bin/boot +++ b/defaultenv-2/base/bin/boot @@ -1,7 +1,10 @@ #!/bin/sh -verbose= -dryrun= +BOOT_BOOTM_OPTS= +BOOT_DRYRUN= +BOOT_VERBOSE= +list= +bootsrc=${global.boot.default} usage=" $0 [OPTIONS] [source]\n @@ -10,49 +13,53 @@ $0 [OPTIONS] [source]\n -l list boot sources\n -h help" -for i in /env/boot/*; do - basename $i s - sources="$sources$s " -done +. /env/data/ansi-colors while getopt "vdhl" opt; do if [ ${opt} = v ]; then - if [ -n "$verbose" ]; then - verbose="-v -v" - else - verbose="-v" - fi + BOOT_BOOTMOPTS="$BOOT_BOOTMOPTS -v" + BOOT_VERBOSE=1 elif [ ${opt} = d ]; then - dryrun=1 + BOOT_DRYRUN=1 elif [ ${opt} = l ]; then - echo -e "boot sources:\n$sources" - exit 0 + list=1 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 [ -n "$list" ]; then + echo "boot sources:" + for i in /env/boot/*; do + basename $i s + echo $s + done + exit 0 +fi -if [ $# = 0 ]; then - scr="$global.boot.default" -else - scr="$1" +if [ -n "$1" ]; then + bootsrc="$*" fi -if [ -n "$scr" ]; then - if [ ! -f /env/boot/$scr ]; then - echo -e "/env/boot/$scr does not exist. Valid choices:\n$sources" - exit +export BOOT_BOOTM_OPTS +export BOOT_DRYRUN +export BOOT_VERBOSE + +for src in $bootsrc; do + if [ -d ${src} ]; then + realsrc="$realsrc $src/*" + else + realsrc="$realsrc $src" fi - /env/boot/$scr -fi +done -if [ -n "$dryrun" ]; then - exit 0 +if [ -n "$BOOT_VERBOSE" ]; then + echo -e "\nboot sequence:${YELLOW}$realsrc${NC}\n" fi -bootm $verbose +for s in $realsrc; do + _boot_list $s +done + +exit $ret |