annotate sources/toys/run-emulator.sh @ 939:abff74b958a1

Once again add /sbin:/usr/sbin to $PATH when mke2fs isn't in $PATH.
author Rob Landley <rob@landley.net>
date Sun, 20 Dec 2009 00:32:17 -0600
parents 4bfe2b34dd9f
children fc134a13357e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
3 # The following environment variables affect the behavior of this script:
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
4
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
5 # HDB - Image file to use for -hdb on /home (none if blank)
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
6 # HDBMEGS - Number of megabytes to create
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
7 # HDC - Image file to use for -hdc on /mnt (none of blank)
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
8 # QEMU_MEMORY - number of megabytes of memory for qemu (defaults to 128)
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
10 # Also, to use the distcc accelerator you need to have distccd and $ARCH-cc
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
11 # in the $PATH.
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
12
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
13 [ ! -z "$QEMU_MEMORY" ] && QEMU_EXTRA="-m $QEMU_MEMORY $QEMU_EXTRA"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
14
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
15 # Should we set up an ext3 image as a second virtual hard drive for /home?
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
16
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
17 if [ ! -z "$HDB" ]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
18 then
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
19 if [ ! -e "$HDB" ]
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 then
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
21
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
22 # If we don't already have an hdb image, should we set up a sparse file and
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
23 # format it ext3?
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
24
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
25 if [ ! -z "$HDBMEGS" ]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
26 then
939
abff74b958a1 Once again add /sbin:/usr/sbin to $PATH when mke2fs isn't in $PATH.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
27 # Some distros don't put /sbin:/usr/sbin in the $PATH for non-root users.
abff74b958a1 Once again add /sbin:/usr/sbin to $PATH when mke2fs isn't in $PATH.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
28 [ -z "$(which mke2fs)" ] && export PATH=/sbin:/usr/bin:$PATH
abff74b958a1 Once again add /sbin:/usr/sbin to $PATH when mke2fs isn't in $PATH.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
29
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
30 dd if=/dev/zero of="$HDB" bs=1024 seek=$[$HDBMEGS*1024-1] count=1 &&
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
31 mke2fs -b 1024 -F "$HDB" -i 4096 &&
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
32 tune2fs -j -c 0 -i 0 "$HDB"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
33
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
34 [ $? -ne 0 ] && exit 1
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
35 fi
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 fi
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
37 WITH_HDB="-hdb $HDB"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
38 fi
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
39
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
40 [ ! -z "$HDC" ] && [ -e "$HDC" ] && WITH_HDC="-hdc $HDC"
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
41
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
42 # Start of distcc setup
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
43
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
44 unique_port()
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
45 {
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 # Try to find a unique port number for each running instance of the program.
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
47
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 # To reduce the chance of the port already being in use by another program,
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 # we use a range either before or after that used by normal programs, but
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 # beyond that allocated to most persistent demons. There's a small chance
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 # even these ports are already in use, but this at least prevents
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 # simultaneous run-emulator instances for different targets from
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 # trivially interfering with each other.
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
54
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 START=8192
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 RANGE=$[$(awk '{print $1}' /proc/sys/net/ipv4/ip_local_port_range)-$START]
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 if [ $RANGE -lt 1 ]
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 then
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 START=$[$(awk '{print $2}' /proc/sys/net/ipv4/ip_local_port_range)]
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 RANGE=$[65535-$START]
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 fi
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
62 echo $[($$%$RANGE)+$START]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
63 }
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
64
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
65 # The ARCH gets substituted in here by system-image.sh
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
66
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
67 ARCH=
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
68
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
69 # If the cross compiler isn't in the $PATH, look for it in the current
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
70 # directory and the user's home directory.
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
71
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
72 DISTCC_PATH="$(which $ARCH-cc 2>/dev/null | sed 's@\(.*\)/.*@\1@')"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
73
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
74 if [ -z "$DISTCC_PATH" ]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
75 then
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
76 [ ! -f "cross-compiler-$ARCH/bin/$ARCH-cc" ] &&
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
77 DISTCC_PATH="$(pwd)/cross-compiler-$ARCH/bin"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
78
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
79 [ ! -f "$HOME/cross-compiler-$ARCH/bin/$ARCH-cc" ] &&
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
80 DISTCC_PATH="$HOME/cross-compiler-$ARCH/bin"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
81 fi
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
82
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
83 if [ -z "$(which distccd)" ]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
84 then
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
85 echo 'No distccd in $PATH, acceleration disabled.'
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
86 elif [ -z "$DISTCC_PATH" ]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
87 then
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
88 echo "No $ARCH-cc in "'$PATH'", acceleration disabled."
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
89 else
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
90
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
91 # Populate a directory full of symlinks to the cross compiler using the
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
92 # unprefixed names distccd will try to use.
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
93
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
94 mkdir -p "distcc_links" &&
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
95 for i in $(cd "$DISTCC_PATH"; ls $ARCH-* | sed "s/^$ARCH-//" )
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
96 do
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
97 ln -sf "$DISTCC_PATH/$ARCH-$i" "distcc_links/$i"
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
98 done
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
99 if [ -e "$DISTCC_PATH/$ARCH-rawgcc" ]
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
100 then
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
101 for i in cc gcc g++ c++
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
102 do
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
103 ln -sf "$DISTCC_PATH/$ARCH-rawgcc" distcc_links/$i
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
104 done
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
105 fi
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
106
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
107 # Run the distcc daemon on the host system with $PATH restricted to the
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
108 # cross compiler binaries.
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
109
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
110 # Note that we tell it --no-detach and background it ourselves so jobs -p can
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
111 # find it later to kill it after the emulator exits.
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
112
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
113 PORT=$(unique_port)
613
518c8e257b3d Fixes Mark Miller sent for distcc support.
Rob Landley <rob@landley.net>
parents: 612
diff changeset
114 CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)*2]
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
115 PATH="$(pwd)/distcc_links" "$(which distccd)" --no-detach --daemon \
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
116 --listen 127.0.0.1 -a 127.0.0.1 -p $PORT --jobs $CPUS \
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
117 --log-stderr --verbose 2>distccd.log &
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
118
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
119 # Clean up afterwards: Kill child processes we started (I.E. distccd).
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
120 trap "kill $(jobs -p)" EXIT
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
121
835
f0b5901bca48 Cosmetic tweaks. (Make title bar changing callable from elsewhere, make run-emulator.sh kill distccd quietly.)
Rob Landley <rob@landley.net>
parents: 790
diff changeset
122 # When background processes die, they should do so silently.
f0b5901bca48 Cosmetic tweaks. (Make title bar changing callable from elsewhere, make run-emulator.sh kill distccd quietly.)
Rob Landley <rob@landley.net>
parents: 790
diff changeset
123 disown $(jobs -p)
f0b5901bca48 Cosmetic tweaks. (Make title bar changing callable from elsewhere, make run-emulator.sh kill distccd quietly.)
Rob Landley <rob@landley.net>
parents: 790
diff changeset
124
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
125 # Let the QEMU launch know we're using distcc.
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
126
790
188a182b1a7f Remove some leftover /tools residue.
Rob Landley <rob@landley.net>
parents: 751
diff changeset
127 DISTCC_PATH_PREFIX=/usr/distcc:
614
d771a938c673 Mark points out that DISTCC_HOSTS needs /$CPUS at the end, otherwise it only distributes 4 jobs/host.
Rob Landley <rob@landley.net>
parents: 613
diff changeset
128 KERNEL_EXTRA="DISTCC_HOSTS=10.0.2.2:$PORT/$CPUS CPUS=$CPUS $KERNEL_EXTRA"
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
129 fi
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
130
751
d0157468f73d Prevent smoketest-all.sh from hanging if an individual smoketest.sh doesn't exit properly.
Rob Landley <rob@landley.net>
parents: 659
diff changeset
131 # Kill our child processes on exit.
d0157468f73d Prevent smoketest-all.sh from hanging if an individual smoketest.sh doesn't exit properly.
Rob Landley <rob@landley.net>
parents: 659
diff changeset
132
d0157468f73d Prevent smoketest-all.sh from hanging if an individual smoketest.sh doesn't exit properly.
Rob Landley <rob@landley.net>
parents: 659
diff changeset
133 trap "pkill -P$$" EXIT
d0157468f73d Prevent smoketest-all.sh from hanging if an individual smoketest.sh doesn't exit properly.
Rob Landley <rob@landley.net>
parents: 659
diff changeset
134
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 843
diff changeset
135 # The actual emulator invocation command gets appended here by system-image.sh
499
9d5fd8e1467b Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
diff changeset
136