annotate sources/more/native-build.sh @ 1043:d62c5c8734b2

Reduce native-build.sh reliance on run-from-build.sh.
author Rob Landley <rob@landley.net>
date Sat, 01 May 2010 00:56:44 -0500
parents 6d3db5bf731a
children 5cce9954d37f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Launch a system image under the emulator under the control of a filesystem
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 # image, with an FTP server to upload results to.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
5
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 # Parse arguments
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
8 if [ $# -ne 3 ]
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 then
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
10 echo "usage: $0 ARCH HDCFILE OUTPUTDIR" >&2
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 fi
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 ARCH="$1"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 if [ ! -f "$2" ]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 then
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 echo "Filesystem image $2 missing" >&2
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 fi
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 HDCFILE="$(readlink -f $2)"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 mkdir -p "$3" || dienow
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 STAGE_DIR="$(readlink -f $3)"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
23
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
24 TOP="$(pwd)"
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
25
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
26 # If running from the source directory, add build/host and cross compiler
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
27 # to the path.
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
28
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
29 [ -d build/host ] &&
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
30 PATH="$TOP/build/host:$TOP/build/cross-compiler-$1/bin:$TOP/build/simple-cross-compiler-$1/bin:$PATH"
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
31
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
32 if [ -z "$(which busybox)" ]
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
33 then
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
34 echo "Warning: can't find busybox, no ftp daemon launched." >&2
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
35 else
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
36
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
37 # Fire off an ftp daemon, making sure it's killed when this script exits.
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
38 # (We use the busybox version because no two ftp daemons have quite the same
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
39 # command line arguments, and this one's a known quantity.)
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
40
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
41 . sources/toys/unique-port.sh 2>/dev/null &&
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
42 FTP_PORT=$(unique_port) ||
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
43 FTP_PORT=12345+$$
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
44
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
45 # Replace toybox with busybox once -L is supported.
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
46
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
47 toybox nc -s 127.0.0.1 -p $FTP_PORT -L busybox ftpd -w "$STAGE_DIR" &
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
48 trap "kill $(jobs -p)" EXIT
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
49 disown $(jobs -p)
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
50 fi
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
51
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 # Run emulator as a child process, feeding in -hdc and some extra environment
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 # variables so it auto-launches the build process.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
54
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 echo === Begin native build for $ARCH
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
56
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 rm -f sources/system-image-"$ARCH"/hdb.img
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
58 HDC="$HDCFILE" KERNEL_EXTRA="OUTPORT=$FTP_PORT ARCH=$ARCH" \
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
59 $DO_TIMEOUT ./run-from-build.sh "$ARCH"
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
60
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 echo === End native build for $ARCH