Mercurial > hg > aboriginal
annotate sources/native/bin/qemu-setup.sh @ 415:acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 20 Oct 2008 18:02:21 -0500 |
parents | 37c8a6c9a493 |
children | 6a8f6cecce7c |
rev | line source |
---|---|
190
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/tools/bin/bash |
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
3 # If you're doing a Linux From Scratch build, the /tools directory is |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
4 # sufficient. (Start by installing kernel headers and building a C library.) |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
5 |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
6 # Otherwise, building source packages wants things like /bin/bash and |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
7 # running the results wants /lib/ld-uClibc.so.0, so set up some directories |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
8 # and symlinks to let you easily compile source packages. |
190
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 |
415
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
10 # Add /tools to $PATH if it's not there |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
11 |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
12 if [ -d tools/bin ] && [ -z "$(echo :$PATH | tools/bin/grep :/tools/bin)" ] |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
13 then |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
14 [ -z "$PATH" ] && PATH=/tools/bin || PATH="$PATH":/tools/bin |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
15 export PATH |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
16 fi |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
17 |
190
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 # Create some temporary directories at the root level |
415
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
19 mkdir -p {proc,sys,dev,etc,tmp} |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
20 [ ! -e bin ] && ln -s tools/bin bin |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
21 [ ! -e lib ] && ln -s tools/lib lib |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
22 [ ! -e usr ] && ln -s tools usr |
190
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 |
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 # Populate /dev |
415
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
25 mountpoint -q sys || mount -t sysfs sys sys |
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
26 mountpoint -q dev || mount -t tmpfs dev dev |
190
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 mdev -s |
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
29 # Mount /proc is there |
415
acb61c298000
Make setup script reentrant, don't require preset PATH. Based on changes by Vladimir Dronnikov.
Rob Landley <rob@landley.net>
parents:
372
diff
changeset
|
30 mountpoint -q proc || mount -t proc proc proc |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
31 |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
32 # If we're running under qemu, do some more setup |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
33 if [ `echo $0 | sed 's@.*/@@'` == "qemu-setup.sh" ] |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
34 then |
302
eb2aa88277e2
If a second block device exists, mount it on /home.
Rob Landley <rob@landley.net>
parents:
286
diff
changeset
|
35 |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
36 # Note that 10.0.2.2 forwards to 127.0.0.1 on the host. |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
37 |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
38 # Setup networking for QEMU (needs /proc) |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
39 echo "nameserver 10.0.2.3" > /etc/resolv.conf |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
40 ifconfig eth0 10.0.2.15 |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
41 route add default gw 10.0.2.2 |
190
12b7ecb79ad0
A little init script for mini-native.sh that gets it read to build stuff.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
43 # If we have no RTC, try rdate instead: |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
44 [[ `date +%s` < 1000 ]] && rdate 10.0.2.2 # or time-b.nist.gov |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
45 |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
46 # If there's a /dev/hdb or /dev/sdb, mount it on home |
302
eb2aa88277e2
If a second block device exists, mount it on /home.
Rob Landley <rob@landley.net>
parents:
286
diff
changeset
|
47 |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
48 [ -b /dev/hdb ] && HOMEDEV=/dev/hdb |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
49 [ -b /dev/sdb ] && HOMEDEV=/dev/sdb |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
50 if [ ! -z "$HOMEDEV" ] |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
51 then |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
52 mkdir -p /home |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
53 mount $HOMEDEV /home |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
54 export HOME=/home |
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
55 fi |
302
eb2aa88277e2
If a second block device exists, mount it on /home.
Rob Landley <rob@landley.net>
parents:
286
diff
changeset
|
56 fi |
eb2aa88277e2
If a second block device exists, mount it on /home.
Rob Landley <rob@landley.net>
parents:
286
diff
changeset
|
57 |
372
37c8a6c9a493
Teach qemu-setup.sh to use oneit so ctrl-c works under the emulator. Also
Rob Landley <rob@landley.net>
parents:
369
diff
changeset
|
58 echo Type exit when done. |
37c8a6c9a493
Teach qemu-setup.sh to use oneit so ctrl-c works under the emulator. Also
Rob Landley <rob@landley.net>
parents:
369
diff
changeset
|
59 |
361
13e35e130783
Let qemu-setup.sh be called under the name chroot-setup.sh, which skips the
Rob Landley <rob@landley.net>
parents:
359
diff
changeset
|
60 # Switch to a shell with command history. |
372
37c8a6c9a493
Teach qemu-setup.sh to use oneit so ctrl-c works under the emulator. Also
Rob Landley <rob@landley.net>
parents:
369
diff
changeset
|
61 [ -z "$CONSOLE" ] && exec /tools/bin/ash |
37c8a6c9a493
Teach qemu-setup.sh to use oneit so ctrl-c works under the emulator. Also
Rob Landley <rob@landley.net>
parents:
369
diff
changeset
|
62 exec /tools/bin/oneit -c /dev/$CONSOLE /tools/bin/ash |