From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/6] defaultenv/update: merge update_rootfs and update_kernel
Date: Mon, 11 Oct 2010 16:34:41 +0200 [thread overview]
Message-ID: <1286807684-17355-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20101011135329.GA7412@game.jcrosoft.org>
use getopt to simplify it and prepare for xmodem support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
common/Kconfig | 1 +
defaultenv/bin/_update | 4 ---
defaultenv/bin/_update_help | 8 +++++++
defaultenv/bin/init | 3 +-
defaultenv/bin/update | 45 ++++++++++++++++++++++++++++++++++++++++++
defaultenv/bin/update_kernel | 15 --------------
defaultenv/bin/update_rootfs | 16 --------------
7 files changed, 55 insertions(+), 37 deletions(-)
create mode 100644 defaultenv/bin/_update_help
create mode 100644 defaultenv/bin/update
delete mode 100644 defaultenv/bin/update_kernel
delete mode 100644 defaultenv/bin/update_rootfs
diff --git a/common/Kconfig b/common/Kconfig
index fb47397..e8d467e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -393,6 +393,7 @@ config DEFAULT_ENVIRONMENT_GENERIC
bool
depends on DEFAULT_ENVIRONMENT
select SHELL_HUSH
+ select HUSH_GETOPT
prompt "Default environment generic"
help
With this option barebox will use the generic default
diff --git a/defaultenv/bin/_update b/defaultenv/bin/_update
index ddd6b84..6f2ebd3 100644
--- a/defaultenv/bin/_update
+++ b/defaultenv/bin/_update
@@ -10,10 +10,6 @@ if [ ! -e "$part" ]; then
exit 1
fi
-if [ $# = 1 ]; then
- image=$1
-fi
-
if [ x$ip = xdhcp ]; then
dhcp
fi
diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help
new file mode 100644
index 0000000..e6ea64c
--- /dev/null
+++ b/defaultenv/bin/_update_help
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-f imagename]"
+echo "update tools."
+echo""
+echo "type update -t kernel -d <nor|nand> [-f imagename] to update kernel into flash"
+echo "type update -t rootfs -d <nor|nand> [-f imagename] to update rootfs into flash"
+
diff --git a/defaultenv/bin/init b/defaultenv/bin/init
index a55e8e6..a39e5bd 100644
--- a/defaultenv/bin/init
+++ b/defaultenv/bin/init
@@ -25,8 +25,7 @@ echo -n "Hit any key to stop autoboot: "
timeout -a $autoboot_timeout
if [ $? != 0 ]; then
echo
- echo "type update_kernel nand|nor [<imagename>] to update kernel into flash"
- echo "type update_rootfs nand|nor [<imagename>] to update rootfs into flash"
+ update -h
echo
exit
fi
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
new file mode 100644
index 0000000..bdac11f
--- /dev/null
+++ b/defaultenv/bin/update
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+. /env/config
+
+type=""
+device_type=""
+
+while getopt "ht:d:f:" Option
+do
+if [ ${Option} = t ]; then
+ type=${OPTARG}
+elif [ ${Option} = d ]; then
+ device_type=${OPTARG}
+elif [ ${Option} = f ]; then
+ imagename=${OPTARG}
+else
+ . /env/bin/_update_help
+ exit 0
+fi
+done
+
+if [ x${type} = xkernel ]; then
+ image=$kernelimage
+elif [ x${type} = xrootfs ]; then
+ image=$rootfsimage
+ type=root
+else
+ . /env/bin/_update_help
+ exit 1
+fi
+
+if [ x${imagename} != x ]; then
+ image=${imagename}
+fi
+
+if [ x${device_type} = xnand ]; then
+ part=/dev/nand0.${type}.bb
+elif [ x${device_type} = xnor ]; then
+ part=/dev/nor0.${type}
+else
+ . /env/bin/_update_help
+ exit 1
+fi
+
+. /env/bin/_update
diff --git a/defaultenv/bin/update_kernel b/defaultenv/bin/update_kernel
deleted file mode 100644
index 1d35ed9..0000000
--- a/defaultenv/bin/update_kernel
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. /env/config
-image=$kernelimage
-
-if [ x$1 = xnand ]; then
- part=/dev/nand0.kernel.bb
-elif [ x$1 = xnor ]; then
- part=/dev/nor0.kernel
-else
- echo "usage: $0 nor|nand [imagename]"
- exit 1
-fi
-
-. /env/bin/_update $2
diff --git a/defaultenv/bin/update_rootfs b/defaultenv/bin/update_rootfs
deleted file mode 100644
index 6366315..0000000
--- a/defaultenv/bin/update_rootfs
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$rootfsimage
-
-if [ x$1 = xnand ]; then
- part=/dev/nand0.root.bb
-elif [ x$1 = xnor ]; then
- part=/dev/nor0.root
-else
- echo "usage: $0 nor|nand [imagename]"
- exit 1
-fi
-
-. /env/bin/_update $2
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2010-10-11 14:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 1/6] defaultenv: introduce CONFIG_DEFAULT_ENVIRONMENT_GENERIC to enable it Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 2/6] commands/crc32: add compare 2 files crc Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2010-10-11 14:34 ` [PATCH 4/6] defaultenv/update: add check crc32 options Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 5/6] defaultenv: add xmodem support for update Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 6/6] defaultenv: add update_barebox to update barebox easly via tftp or xmodem Jean-Christophe PLAGNIOL-VILLARD
2010-10-12 8:13 ` [PATCH] nhk8815: use defaultenv Jean-Christophe PLAGNIOL-VILLARD
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=1286807684-17355-3-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--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