annotate sources/toys/native-build.sh @ 1218:fd67d5a442c9

Switch from toybox netcat to busybox netcat.
author Rob Landley <rob@landley.net>
date Sat, 21 Aug 2010 02:46:30 -0500
parents e81a9b8b3b93
children 82a4e3d3a5ff
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
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
3 # Launch a system image in the emulator with a control image to drive an
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
4 # automated native build, plus an FTP server on the host to upload results to.
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
5
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
6 # If you already have an FTP server, export FTP_SERVER and/or FTP_PORT.
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 # Parse arguments
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
10 if [ $# -ne 1 ]
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 then
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
12 echo "usage: $0 CONTROL_IMAGE" >&2
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 fi
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
16 if [ ! -f "$1" ]
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 then
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
18 echo "Filesystem image $1 missing" >&2
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 exit 1
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 fi
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
21 HDCFILE="$(readlink -f $1)"
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
22
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
23 TOP="$(pwd)"
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
24
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
25 # If we're running from the build directory, add build/host and cross compiler
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
26 # to the path.
1003
6d3db5bf731a Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents: 972
diff changeset
27
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
28 [ -d ../host ] &&
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
29 PATH="$TOP/../host:$TOP/../cross-compiler-$1/bin:$TOP/../simple-cross-compiler-$1/bin:$PATH"
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
30
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
31 INCLUDE unique-port.sh
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
32
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
33 # Do we already have an FTP daemon?
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
34
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
35 if [ -z "$FTP_SERVER" ]
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
36 then
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
37 FTP_SERVER=127.0.0.1
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
38 elif [ -z "$FTP_PORT" ]
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
39 then
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
40 FTP_PORT=21
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
41 fi
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
42
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
43 if [ -z "$FTP_PORT" ]
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
44 then
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
45 if [ -z "$(which busybox)" ]
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
46 then
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
47 echo "Warning: can't find busybox, no ftp daemon launched." >&2
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
48 else
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
49 FTP_PORT=$(unique_port)
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
50
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
51 echo === launching FTP daemon on port "$FTP_PORT"
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
52
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
53 # Fire off an ftp daemon, making sure it's killed when this script exits.
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
54 # (We use the busybox version because no two ftp daemons have quite the same
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
55 # command line arguments, and this one's a known quantity.)
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
56
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
57 mkdir -p upload
1218
fd67d5a442c9 Switch from toybox netcat to busybox netcat.
Rob Landley <rob@landley.net>
parents: 1078
diff changeset
58 # Busybox needs -s 127.0.0.1 support here
fd67d5a442c9 Switch from toybox netcat to busybox netcat.
Rob Landley <rob@landley.net>
parents: 1078
diff changeset
59 busybox nc -p $FTP_PORT -lle busybox ftpd -w upload &
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
60 trap "kill $(jobs -p)" EXIT
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
61 disown $(jobs -p)
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
62
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
63 # QEMU's alias for host loopback
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
64
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
65 FTP_SERVER=10.0.2.2
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
66 fi
1043
d62c5c8734b2 Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents: 1003
diff changeset
67 fi
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
68
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
69 # 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
70 # variables so it auto-launches the build process.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
71
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
72 rm -f hdb.img
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
73 HDC="$HDCFILE" KERNEL_EXTRA="FTP_SERVER=$FTP_SERVER FTP_PORT=$FTP_PORT" \
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
74 ./dev-environment.sh
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
75
1072
94b0b4ef1157 Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents: 1055
diff changeset
76 echo === End native build