diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2010-10-11 16:34:41 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-10-12 21:32:44 +0200 |
commit | 5c3538f44d9912e013844b3fe82c51ce62a8247f (patch) | |
tree | 8b636a266f0c00dae9694f95166aa5f7c44518a7 /defaultenv | |
parent | a828cef9b5bc5f1b3c50193dda069697e5b9691b (diff) | |
download | barebox-5c3538f44d9912e013844b3fe82c51ce62a8247f.tar.gz barebox-5c3538f44d9912e013844b3fe82c51ce62a8247f.tar.xz |
defaultenv/update: merge update_rootfs and update_kernel
use getopt to simplify it and prepare for xmodem support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'defaultenv')
-rw-r--r-- | defaultenv/bin/_update | 4 | ||||
-rw-r--r-- | defaultenv/bin/_update_help | 8 | ||||
-rw-r--r-- | defaultenv/bin/init | 3 | ||||
-rw-r--r-- | defaultenv/bin/update | 45 | ||||
-rw-r--r-- | defaultenv/bin/update_kernel | 15 | ||||
-rw-r--r-- | defaultenv/bin/update_rootfs | 16 |
6 files changed, 54 insertions, 37 deletions
diff --git a/defaultenv/bin/_update b/defaultenv/bin/_update index ddd6b84f72..6f2ebd3157 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 0000000000..e6ea64cf80 --- /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 526e3db86b..96a5716628 100644 --- a/defaultenv/bin/init +++ b/defaultenv/bin/init @@ -29,8 +29,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 0000000000..bdac11f209 --- /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 1d35ed9727..0000000000 --- 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 63663150c2..0000000000 --- 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 |