Mercurial > hg > aboriginal
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 |
rev | line source |
---|---|
972 | 1 #!/bin/bash |
2 | |
3 # Launch a system image under the emulator under the control of a filesystem | |
4 # image, with an FTP server to upload results to. | |
5 | |
6 # Parse arguments | |
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 | 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 | 11 exit 1 |
12 fi | |
13 | |
14 ARCH="$1" | |
15 if [ ! -f "$2" ] | |
16 then | |
17 echo "Filesystem image $2 missing" >&2 | |
18 exit 1 | |
19 fi | |
20 HDCFILE="$(readlink -f $2)" | |
21 mkdir -p "$3" || dienow | |
22 STAGE_DIR="$(readlink -f $3)" | |
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 | 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 | 51 |
52 # Run emulator as a child process, feeding in -hdc and some extra environment | |
53 # variables so it auto-launches the build process. | |
54 | |
55 echo === Begin native build for $ARCH | |
56 | |
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 | 60 |
61 echo === End native build for $ARCH |