annotate sources/more/native-build.sh @ 1003:6d3db5bf731a

Make the native build timeout configurable.
author Rob Landley <rob@landley.net>
date Thu, 18 Mar 2010 05:44:47 -0500
parents cfa6262528f3
children d62c5c8734b2
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 # setup hdc.sqf
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 # find build -name "hdb.img" | xargs rm
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 # 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
7 # image, with an FTP server to upload results to.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
8
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 . sources/functions.sh || exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
10
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 # Parse arguments
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
12
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
13 if [ $# -lt 3 ]
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 then
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
15 echo "usage: $0 ARCH HDCFILE OUTPUTDIR [TIMEOUT_SECONDS]" >&2
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 fi
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
18
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 ARCH="$1"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 if [ ! -f "$2" ]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 then
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 echo "Filesystem image $2 missing" >&2
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 fi
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 HDCFILE="$(readlink -f $2)"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 mkdir -p "$3" || dienow
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 STAGE_DIR="$(readlink -f $3)"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
28
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
29 [ ! -z "$4" ] && DO_TIMEOUT="sources/timeout.sh $4"
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
30
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 # Fire off the ftp daemon, making sure it's killed when this script exits
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
32
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 . sources/toys/unique-port.sh || exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 PORT=$(unique_port)
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 build/host/netcat -s 127.0.0.1 -p $PORT -L build/host/ftpd -w "$STAGE_DIR" &
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 trap "kill $(jobs -p)" EXIT
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 disown $(jobs -p)
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
38
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 # 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
40 # variables so it auto-launches the build process.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
41
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 echo === Begin native build for $ARCH
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
43
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 rm -f sources/system-image-"$ARCH"/hdb.img
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 HDC="$HDCFILE" KERNEL_EXTRA="OUTPORT=$PORT ARCH=$ARCH" \
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
46 $DO_TIMEOUT ./run-from-build.sh "$ARCH"
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
47
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 echo === End native build for $ARCH