From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: openembedded-core@openembedded.org
Subject: [PATCH 4/6] runqemu: add and use error()
Date: Thu, 3 May 2012 19:12:32 +0200 [thread overview]
Message-ID: <1336065154-8513-4-git-send-email-rep.dot.nop@gmail.com> (raw)
In-Reply-To: <1336065154-8513-1-git-send-email-rep.dot.nop@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
scripts/runqemu | 71 ++++++++++++++++++++-----------------------------------
1 file changed, 25 insertions(+), 46 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index dfa7f4b..231b1bf 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -46,6 +46,11 @@ if [ "x$1" = "x" ]; then
usage
fi
+error() {
+ echo "Error: "$*
+ usage
+}
+
MACHINE=${MACHINE:=""}
KERNEL=""
FSTYPE=""
@@ -65,12 +70,8 @@ process_filename() {
case /$EXT/ in
/bin/)
# A file ending in .bin is a kernel
- if [ -z "$KERNEL" ]; then
- KERNEL=$filename
- else
- echo "Error: conflicting KERNEL args [$KERNEL] and [$filename]"
- usage
- fi
+ [ -z "$KERNEL" ] && KERNEL=$filename || \
+ error "conflicting KERNEL args [$KERNEL] and [$filename]"
;;
/ext[234]/|/jffs2/|/btrfs/)
# A file ending in a supportted fs type is a rootfs image
@@ -78,13 +79,11 @@ process_filename() {
FSTYPE=$EXT
ROOTFS=$filename
else
- echo "Error: conflicting FSTYPE types [$FSTYPE] and [$EXT]"
- usage
+ error "conflicting FSTYPE types [$FSTYPE] and [$EXT]"
fi
;;
*)
- echo "Error: unknown file arg [$filename]"
- usage
+ error "unknown file arg [$filename]"
;;
esac
}
@@ -97,20 +96,12 @@ while [ $i -le $# ]; do
arg=${!i}
case $arg in
"qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemuppc")
- if [ -z "$MACHINE" ]; then
- MACHINE=$arg
- else
- echo "Error: conflicting MACHINE types [$MACHINE] and [$arg]"
- usage
- fi
+ [ -z "$MACHINE" ] && MACHINE=$arg || \
+ error "conflicting MACHINE types [$MACHINE] and [$arg]"
;;
"ext2" | "ext3" | "jffs2" | "nfs" | "btrfs")
- if [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ]; then
- FSTYPE=$arg
- else
- echo "Error: conflicting FSTYPE types [$FSTYPE] and [$arg]"
- usage
- fi
+ [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \
+ error "conflicting FSTYPE types [$FSTYPE] and [$arg]"
;;
*-image*)
if [ -z "$ROOTFS" ]; then
@@ -127,8 +118,7 @@ while [ $i -le $# ]; do
LAZY_ROOTFS="true"
fi
else
- echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
- usage
+ error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
fi
;;
"nographic")
@@ -146,10 +136,8 @@ while [ $i -le $# ]; do
# to use simplified options instead
serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'`
kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'`
- if [ ! -z "$serial_option" -o ! -z "$kvm_option" ]; then
- echo "Error: Please use simplified serial or kvm options instead"
- usage
- fi
+ [ ! -z "$serial_option" -o ! -z "$kvm_option" ] && \
+ error "Please use simplified serial or kvm options instead"
;;
"bootparams="*)
SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}"
@@ -172,21 +160,18 @@ while [ $i -le $# ]; do
if [ -z "$FSTYPE" -o "$FSTYPE" = "nfs" ]; then
FSTYPE=nfs
else
- echo "Error: conflicting FSTYPE types [$arg] and nfs"
- usage
+ error "conflicting FSTYPE types [$arg] and nfs"
fi
if [ -z "$ROOTFS" ]; then
ROOTFS=$arg
else
- echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
- usage
+ error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
fi
elif [ -f "$arg" ]; then
process_filename $arg
else
- echo "Error: unable to classify arg [$arg]"
- usage
+ error "unable to classify arg [$arg]"
fi
;;
esac
@@ -229,19 +214,16 @@ fi
# Report errors for missing combinations of options
if [ -z "$MACHINE" -a -z "$KERNEL" ]; then
- echo "Error: you must specify at least a MACHINE or KERNEL argument"
- usage
+ error "you must specify at least a MACHINE or KERNEL argument"
fi
if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then
- echo "Error: NFS booting without an explicit ROOTFS path is not yet supported"
- usage
+ error "NFS booting without an explicit ROOTFS path is not yet supported"
fi
if [ -z "$MACHINE" ]; then
MACHINE=`basename $KERNEL | sed 's/.*-\(qemux86-64\|qemux86\|qemuarm\|qemumips\|qemuppc\).*/\1/'`
if [ -z "$MACHINE" ]; then
- echo "Error: Unable to set MACHINE from kernel filename [$KERNEL]"
- usage
+ error "Unable to set MACHINE from kernel filename [$KERNEL]"
fi
echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]"
fi
@@ -349,8 +331,7 @@ if [ -z "$KERNEL" ]; then
KERNEL=$OE_TMPDIR/deploy/images/$kernel_file
if [ -z "$KERNEL" ]; then
- echo "Error: Unable to determine default kernel for MACHINE [$MACHINE]"
- usage
+ error "Unable to determine default kernel for MACHINE [$MACHINE]"
fi
fi
# KERNEL is now set for all cases
@@ -359,8 +340,7 @@ if [ -z "$FSTYPE" ]; then
eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE
if [ -z "$FSTYPE" ]; then
- echo "Error: Unable to determine default fstype for MACHINE [$MACHINE]"
- usage
+ error "Unable to determine default fstype for MACHINE [$MACHINE]"
fi
fi
@@ -381,8 +361,7 @@ if [ -z "$ROOTFS" ]; then
findimage $T $MACHINE $FSTYPE
if [ -z "$ROOTFS" ]; then
- echo "Error: Unable to determine default rootfs for MACHINE [$MACHINE]"
- usage
+ error "Unable to determine default rootfs for MACHINE [$MACHINE]"
fi
fi
# ROOTFS is now set for all cases
--
1.7.10
next prev parent reply other threads:[~2012-05-03 17:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 17:12 [PATCH 1/6] runqemu: Use OE_TMPDIR Bernhard Reutner-Fischer
2012-05-03 17:12 ` [PATCH 2/6] runqemu: use modern, single-char name of test(1) Bernhard Reutner-Fischer
2012-05-07 23:25 ` Joshua Lock
2012-05-15 19:59 ` Bernhard Reutner-Fischer
2012-05-15 20:58 ` Khem Raj
2012-05-15 22:03 ` Peter Seebach
2012-05-03 17:12 ` [PATCH 3/6] runqemu: simplify process_filename() Bernhard Reutner-Fischer
2012-05-03 17:12 ` Bernhard Reutner-Fischer [this message]
2012-05-03 17:12 ` [PATCH 5/6] runqemu: minor tweaks Bernhard Reutner-Fischer
2012-05-03 17:12 ` [PATCH 6/6] runqemu: be sh neutral Bernhard Reutner-Fischer
2012-05-04 21:18 ` [PATCH 1/6] runqemu: Use OE_TMPDIR Scott Garman
2012-05-07 23:56 ` Scott Garman
2012-05-08 7:07 ` Peter Seebach
2012-05-14 22:34 ` Mark Hatle
2012-05-14 22:40 ` Khem Raj
2012-05-14 22:51 ` Marko Lindqvist
2012-05-14 23:15 ` Mark Hatle
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=1336065154-8513-4-git-send-email-rep.dot.nop@gmail.com \
--to=rep.dot.nop@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=openembedded-core@openembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.