Mercurial > hg > aboriginal
annotate sources/toys/native-build.sh @ 1541:e4f766efa39f
Sort busybox config entries to group stuff toybox can replace. Also add ps.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 06 Sep 2012 03:44:47 -0500 |
parents | 29109240fd6d |
children | e78cb789519b |
rev | line source |
---|---|
972 | 1 #!/bin/bash |
2 | |
1538
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1306
diff
changeset
|
3 # Wrapper around dev-environment.sh which runs an automated native build |
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1306
diff
changeset
|
4 # using a control image, and sets up an FTP server on the host to upload |
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1306
diff
changeset
|
5 # results to. |
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
|
6 |
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
|
7 # If you already have an FTP server, export FTP_SERVER and/or FTP_PORT. |
972 | 8 |
9 # Parse arguments | |
10 | |
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
|
11 if [ $# -ne 1 ] |
972 | 12 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
|
13 echo "usage: $0 CONTROL_IMAGE" >&2 |
972 | 14 exit 1 |
15 fi | |
16 | |
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
|
17 if [ ! -f "$1" ] |
972 | 18 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
|
19 echo "Filesystem image $1 missing" >&2 |
972 | 20 exit 1 |
21 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
|
22 HDCFILE="$(readlink -f $1)" |
972 | 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 |
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
|
26 # 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
|
27 # to the path. |
1003
6d3db5bf731a
Make the native build timeout configurable.
Rob Landley <rob@landley.net>
parents:
972
diff
changeset
|
28 |
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
|
29 [ -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
|
30 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
|
31 |
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 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
|
33 |
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
|
34 # 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
|
35 |
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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 fi |
972 | 43 |
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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 |
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
|
52 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
|
53 |
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
|
54 # 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
|
55 # (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
|
56 # 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
|
57 |
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
|
58 mkdir -p upload |
1218
fd67d5a442c9
Switch from toybox netcat to busybox netcat.
Rob Landley <rob@landley.net>
parents:
1078
diff
changeset
|
59 # 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
|
60 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
|
61 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
|
62 disown $(jobs -p) |
1043
d62c5c8734b2
Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents:
1003
diff
changeset
|
63 |
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
|
64 # 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
|
65 |
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 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
|
67 fi |
1043
d62c5c8734b2
Reduce native-build.sh reliance on run-from-build.sh.
Rob Landley <rob@landley.net>
parents:
1003
diff
changeset
|
68 fi |
972 | 69 |
70 # Run emulator as a child process, feeding in -hdc and some extra environment | |
71 # variables so it auto-launches the build process. | |
72 | |
1263
82a4e3d3a5ff
Teach native-build.sh to pass in the name of the build control image.
Rob Landley <rob@landley.net>
parents:
1218
diff
changeset
|
73 export HDC="$HDCFILE" |
82a4e3d3a5ff
Teach native-build.sh to pass in the name of the build control image.
Rob Landley <rob@landley.net>
parents:
1218
diff
changeset
|
74 NATIVE_BUILD="$(echo "$HDCFILE" | sed -e 's@.*/@@' -e 's@[.]hdc$@@')" |
82a4e3d3a5ff
Teach native-build.sh to pass in the name of the build control image.
Rob Landley <rob@landley.net>
parents:
1218
diff
changeset
|
75 export KERNEL_EXTRA="FTP_SERVER=$FTP_SERVER FTP_PORT=$FTP_PORT NATIVE_BUILD=$NATIVE_BUILD $KERNEL_EXTRA" |
82a4e3d3a5ff
Teach native-build.sh to pass in the name of the build control image.
Rob Landley <rob@landley.net>
parents:
1218
diff
changeset
|
76 |
1306
8e10d025f1a5
Don't delete hdb.img if user specified an $HDB image. (It's caller's responsibility to make sure that the scratch disk is in a usable state.)
Rob Landley <rob@landley.net>
parents:
1263
diff
changeset
|
77 [ -z "$HDB" ] && rm -f hdb.img |
1263
82a4e3d3a5ff
Teach native-build.sh to pass in the name of the build control image.
Rob Landley <rob@landley.net>
parents:
1218
diff
changeset
|
78 ./dev-environment.sh |
972 | 79 |
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
|
80 echo === End native build |