annotate sources/native/bin/qemu-setup.sh @ 425:6a8f6cecce7c

Cleanup after chroot-setup.sh, and set nameserver.
author Rob Landley <rob@landley.net>
date Wed, 29 Oct 2008 17:28:36 -0500
parents acb61c298000
children f4d6502501d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
425
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
56 else
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
57 echo "nameserver 4.2.2.1" > /etc/resolv.conf
302
eb2aa88277e2 If a second block device exists, mount it on /home.
Rob Landley <rob@landley.net>
parents: 286
diff changeset
58 fi
eb2aa88277e2 If a second block device exists, mount it on /home.
Rob Landley <rob@landley.net>
parents: 286
diff changeset
59
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
60 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
61
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
62 # Switch to a shell with command history.
425
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
63 if [ -z "$CONSOLE" ]
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
64 then
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
65 /tools/bin/ash
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
66 cd /
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
67 umount ./dev
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
68 umount ./home
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
69 umount ./sys
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
70 umount ./proc
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
71 sync
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
72 else
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
73 exec /tools/bin/oneit -c /dev/$CONSOLE /tools/bin/ash
6a8f6cecce7c Cleanup after chroot-setup.sh, and set nameserver.
Rob Landley <rob@landley.net>
parents: 415
diff changeset
74 fi