summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-07-04 23:50:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-07-05 20:50:45 +0200
commit4604923f0c7d4f1954d1cc5dfe0f3a2ef5b9b074 (patch)
treeb18d9dd07ded155726576f4c1091cfd2b23b37db
parent4561eae51ae7a750d4d215ea6cc6e63c20a6c3e5 (diff)
downloadbarebox-4604923f0c7d4f1954d1cc5dfe0f3a2ef5b9b074.tar.gz
barebox-4604923f0c7d4f1954d1cc5dfe0f3a2ef5b9b074.tar.xz
defenv-2: improve boot script
- add usage information - add option parsing: -v verbose -v -v more verbose -l list bĀ“possible boot sources -d dryrun The dryrun option sets the global variables necessary for booting but does not actually boot the system. This way it is possible to make additional adjustments to the boot variables and then invoke bootm manually. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/Kconfig1
-rw-r--r--defaultenv-2/base/bin/boot42
2 files changed, 40 insertions, 3 deletions
diff --git a/common/Kconfig b/common/Kconfig
index b776031bad..763983e7d5 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -508,6 +508,7 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
select GLOB_SORT
select CMD_GLOBAL
select CMD_AUTOMOUNT
+ select CMD_BASENAME
select FLEXIBLE_BOOTARGS
prompt "Generic environment template"
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index c5ad73dde8..4ebda3f4b2 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -1,5 +1,38 @@
#!/bin/sh
+verbose=
+dryrun=
+
+usage="
+$0 [OPTIONS] [source]\n
+ -v verbose\n
+ -d dryrun\n
+ -l list boot sources\n
+ -h help"
+
+for i in /env/boot/*; do
+ basename $i s
+ sources="$sources$s "
+done
+
+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=1
+ elif [ ${opt} = l ]; then
+ echo -e "boot sources:\n$sources"
+ exit 0
+ elif [ ${opt} = h ]; then
+ echo -e "$usage"
+ exit 0
+ fi
+done
+
if [ $# = 0 ]; then
scr="$global.boot.default"
else
@@ -8,11 +41,14 @@ fi
if [ -n "$scr" ]; then
if [ ! -f /env/boot/$scr ]; then
- echo -e "/env/boot/$scr does not exist.\nValid choices:"
- ls /env/boot
+ echo -e "/env/boot/$scr does not exist.Valid choices:\n$sources"
exit
fi
/env/boot/$scr
fi
-bootm
+if [ -n "$dryrun" ]; then
+ exit 0
+fi
+
+bootm $verbose