diff options
-rwxr-xr-x | scripts/runqemu | 71 |
1 files changed, 25 insertions, 46 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index dfa7f4bc2d..231b1bf517 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
@@ -46,6 +46,11 @@ if [ "x$1" = "x" ]; then | |||
46 | usage | 46 | usage |
47 | fi | 47 | fi |
48 | 48 | ||
49 | error() { | ||
50 | echo "Error: "$* | ||
51 | usage | ||
52 | } | ||
53 | |||
49 | MACHINE=${MACHINE:=""} | 54 | MACHINE=${MACHINE:=""} |
50 | KERNEL="" | 55 | KERNEL="" |
51 | FSTYPE="" | 56 | FSTYPE="" |
@@ -65,12 +70,8 @@ process_filename() { | |||
65 | case /$EXT/ in | 70 | case /$EXT/ in |
66 | /bin/) | 71 | /bin/) |
67 | # A file ending in .bin is a kernel | 72 | # A file ending in .bin is a kernel |
68 | if [ -z "$KERNEL" ]; then | 73 | [ -z "$KERNEL" ] && KERNEL=$filename || \ |
69 | KERNEL=$filename | 74 | error "conflicting KERNEL args [$KERNEL] and [$filename]" |
70 | else | ||
71 | echo "Error: conflicting KERNEL args [$KERNEL] and [$filename]" | ||
72 | usage | ||
73 | fi | ||
74 | ;; | 75 | ;; |
75 | /ext[234]/|/jffs2/|/btrfs/) | 76 | /ext[234]/|/jffs2/|/btrfs/) |
76 | # A file ending in a supportted fs type is a rootfs image | 77 | # A file ending in a supportted fs type is a rootfs image |
@@ -78,13 +79,11 @@ process_filename() { | |||
78 | FSTYPE=$EXT | 79 | FSTYPE=$EXT |
79 | ROOTFS=$filename | 80 | ROOTFS=$filename |
80 | else | 81 | else |
81 | echo "Error: conflicting FSTYPE types [$FSTYPE] and [$EXT]" | 82 | error "conflicting FSTYPE types [$FSTYPE] and [$EXT]" |
82 | usage | ||
83 | fi | 83 | fi |
84 | ;; | 84 | ;; |
85 | *) | 85 | *) |
86 | echo "Error: unknown file arg [$filename]" | 86 | error "unknown file arg [$filename]" |
87 | usage | ||
88 | ;; | 87 | ;; |
89 | esac | 88 | esac |
90 | } | 89 | } |
@@ -97,20 +96,12 @@ while [ $i -le $# ]; do | |||
97 | arg=${!i} | 96 | arg=${!i} |
98 | case $arg in | 97 | case $arg in |
99 | "qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemuppc") | 98 | "qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemuppc") |
100 | if [ -z "$MACHINE" ]; then | 99 | [ -z "$MACHINE" ] && MACHINE=$arg || \ |
101 | MACHINE=$arg | 100 | error "conflicting MACHINE types [$MACHINE] and [$arg]" |
102 | else | ||
103 | echo "Error: conflicting MACHINE types [$MACHINE] and [$arg]" | ||
104 | usage | ||
105 | fi | ||
106 | ;; | 101 | ;; |
107 | "ext2" | "ext3" | "jffs2" | "nfs" | "btrfs") | 102 | "ext2" | "ext3" | "jffs2" | "nfs" | "btrfs") |
108 | if [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ]; then | 103 | [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \ |
109 | FSTYPE=$arg | 104 | error "conflicting FSTYPE types [$FSTYPE] and [$arg]" |
110 | else | ||
111 | echo "Error: conflicting FSTYPE types [$FSTYPE] and [$arg]" | ||
112 | usage | ||
113 | fi | ||
114 | ;; | 105 | ;; |
115 | *-image*) | 106 | *-image*) |
116 | if [ -z "$ROOTFS" ]; then | 107 | if [ -z "$ROOTFS" ]; then |
@@ -127,8 +118,7 @@ while [ $i -le $# ]; do | |||
127 | LAZY_ROOTFS="true" | 118 | LAZY_ROOTFS="true" |
128 | fi | 119 | fi |
129 | else | 120 | else |
130 | echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]" | 121 | error "conflicting ROOTFS args [$ROOTFS] and [$arg]" |
131 | usage | ||
132 | fi | 122 | fi |
133 | ;; | 123 | ;; |
134 | "nographic") | 124 | "nographic") |
@@ -146,10 +136,8 @@ while [ $i -le $# ]; do | |||
146 | # to use simplified options instead | 136 | # to use simplified options instead |
147 | serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'` | 137 | serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'` |
148 | kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'` | 138 | kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'` |
149 | if [ ! -z "$serial_option" -o ! -z "$kvm_option" ]; then | 139 | [ ! -z "$serial_option" -o ! -z "$kvm_option" ] && \ |
150 | echo "Error: Please use simplified serial or kvm options instead" | 140 | error "Please use simplified serial or kvm options instead" |
151 | usage | ||
152 | fi | ||
153 | ;; | 141 | ;; |
154 | "bootparams="*) | 142 | "bootparams="*) |
155 | SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}" | 143 | SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}" |
@@ -172,21 +160,18 @@ while [ $i -le $# ]; do | |||
172 | if [ -z "$FSTYPE" -o "$FSTYPE" = "nfs" ]; then | 160 | if [ -z "$FSTYPE" -o "$FSTYPE" = "nfs" ]; then |
173 | FSTYPE=nfs | 161 | FSTYPE=nfs |
174 | else | 162 | else |
175 | echo "Error: conflicting FSTYPE types [$arg] and nfs" | 163 | error "conflicting FSTYPE types [$arg] and nfs" |
176 | usage | ||
177 | fi | 164 | fi |
178 | 165 | ||
179 | if [ -z "$ROOTFS" ]; then | 166 | if [ -z "$ROOTFS" ]; then |
180 | ROOTFS=$arg | 167 | ROOTFS=$arg |
181 | else | 168 | else |
182 | echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]" | 169 | error "conflicting ROOTFS args [$ROOTFS] and [$arg]" |
183 | usage | ||
184 | fi | 170 | fi |
185 | elif [ -f "$arg" ]; then | 171 | elif [ -f "$arg" ]; then |
186 | process_filename $arg | 172 | process_filename $arg |
187 | else | 173 | else |
188 | echo "Error: unable to classify arg [$arg]" | 174 | error "unable to classify arg [$arg]" |
189 | usage | ||
190 | fi | 175 | fi |
191 | ;; | 176 | ;; |
192 | esac | 177 | esac |
@@ -229,19 +214,16 @@ fi | |||
229 | 214 | ||
230 | # Report errors for missing combinations of options | 215 | # Report errors for missing combinations of options |
231 | if [ -z "$MACHINE" -a -z "$KERNEL" ]; then | 216 | if [ -z "$MACHINE" -a -z "$KERNEL" ]; then |
232 | echo "Error: you must specify at least a MACHINE or KERNEL argument" | 217 | error "you must specify at least a MACHINE or KERNEL argument" |
233 | usage | ||
234 | fi | 218 | fi |
235 | if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then | 219 | if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then |
236 | echo "Error: NFS booting without an explicit ROOTFS path is not yet supported" | 220 | error "NFS booting without an explicit ROOTFS path is not yet supported" |
237 | usage | ||
238 | fi | 221 | fi |
239 | 222 | ||
240 | if [ -z "$MACHINE" ]; then | 223 | if [ -z "$MACHINE" ]; then |
241 | MACHINE=`basename $KERNEL | sed 's/.*-\(qemux86-64\|qemux86\|qemuarm\|qemumips\|qemuppc\).*/\1/'` | 224 | MACHINE=`basename $KERNEL | sed 's/.*-\(qemux86-64\|qemux86\|qemuarm\|qemumips\|qemuppc\).*/\1/'` |
242 | if [ -z "$MACHINE" ]; then | 225 | if [ -z "$MACHINE" ]; then |
243 | echo "Error: Unable to set MACHINE from kernel filename [$KERNEL]" | 226 | error "Unable to set MACHINE from kernel filename [$KERNEL]" |
244 | usage | ||
245 | fi | 227 | fi |
246 | echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]" | 228 | echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]" |
247 | fi | 229 | fi |
@@ -349,8 +331,7 @@ if [ -z "$KERNEL" ]; then | |||
349 | KERNEL=$OE_TMPDIR/deploy/images/$kernel_file | 331 | KERNEL=$OE_TMPDIR/deploy/images/$kernel_file |
350 | 332 | ||
351 | if [ -z "$KERNEL" ]; then | 333 | if [ -z "$KERNEL" ]; then |
352 | echo "Error: Unable to determine default kernel for MACHINE [$MACHINE]" | 334 | error "Unable to determine default kernel for MACHINE [$MACHINE]" |
353 | usage | ||
354 | fi | 335 | fi |
355 | fi | 336 | fi |
356 | # KERNEL is now set for all cases | 337 | # KERNEL is now set for all cases |
@@ -359,8 +340,7 @@ if [ -z "$FSTYPE" ]; then | |||
359 | eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE | 340 | eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE |
360 | 341 | ||
361 | if [ -z "$FSTYPE" ]; then | 342 | if [ -z "$FSTYPE" ]; then |
362 | echo "Error: Unable to determine default fstype for MACHINE [$MACHINE]" | 343 | error "Unable to determine default fstype for MACHINE [$MACHINE]" |
363 | usage | ||
364 | fi | 344 | fi |
365 | fi | 345 | fi |
366 | 346 | ||
@@ -381,8 +361,7 @@ if [ -z "$ROOTFS" ]; then | |||
381 | findimage $T $MACHINE $FSTYPE | 361 | findimage $T $MACHINE $FSTYPE |
382 | 362 | ||
383 | if [ -z "$ROOTFS" ]; then | 363 | if [ -z "$ROOTFS" ]; then |
384 | echo "Error: Unable to determine default rootfs for MACHINE [$MACHINE]" | 364 | error "Unable to determine default rootfs for MACHINE [$MACHINE]" |
385 | usage | ||
386 | fi | 365 | fi |
387 | fi | 366 | fi |
388 | # ROOTFS is now set for all cases | 367 | # ROOTFS is now set for all cases |