mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] defenv-2: improve boot script
Date: Thu,  5 Jul 2012 09:18:40 +0200	[thread overview]
Message-ID: <1341472720-3248-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1341472720-3248-1-git-send-email-s.hauer@pengutronix.de>

- 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>
---
 common/Kconfig             |    1 +
 defaultenv-2/base/bin/boot |   42 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index b776031..763983e 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 c5ad73d..4ebda3f 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
-- 
1.7.10


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

      parent reply	other threads:[~2012-07-05  7:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05  7:18 [PATCH] defenv-2 updates Sascha Hauer
2012-07-05  7:18 ` [PATCH 1/3] hush getopt: shift argv arguments Sascha Hauer
2012-07-05  7:18 ` [PATCH 2/3] defenv-2: Add usage information for bootargs scripts Sascha Hauer
2012-07-05  7:22   ` Eric Bénard
2012-07-05  7:35     ` Sascha Hauer
2012-07-05  7:18 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341472720-3248-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox