3 # Build PlanetLab-Bootstrap.tar.bz2, the reference image for PlanetLab
4 # nodes. Requires the web and boot servers to be up, which complicates
5 # bootstrap. Alternatively, we could require the build server to host
6 # a local yum repository. Already, it is required to run the same
7 # major version of yum as the nodes.
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Copyright (C) 2005 The Trustees of Princeton University
12 # $Id: buildnode.sh,v 1.2 2005/09/03 21:42:07 mlhuang Exp $
15 # Get the production /etc/yum.conf file. XXX When MAs begin deploying
16 # their own boot servers and/or code, this will have to change.
17 curl --silent http://boot.planet-lab.org/$(curl --silent --insecure --form node_id=1 --form file=/etc/yum.conf https://boot.planet-lab.org/db/plnodeconf/getsinglefile.php) > yum.conf
19 # Solve the bootstrap problem by including any just built packages in
20 # the yum configuration. This cooperates with the PlanetLab build
22 if [ -n "$RPM_BUILD_DIR" ] ; then
23 # Remove any [PlanetLab*] sections
24 sed -i -f - yum.conf <<EOF
25 # Match lines between [PlanetLab*] and the next [*
26 /\[PlanetLab.*\]/I,/^\[/{
36 # And replace them with a section for the RPMS that were just built
39 name=Bootstrap RPMS -- $(dirname $RPM_BUILD_DIR)/RPMS/
40 baseurl=file://$(dirname $RPM_BUILD_DIR)/RPMS/
45 VROOT=$PWD/PlanetLab-Bootstrap
46 install -d -m 755 $VROOT
52 mknod -m 666 $VROOT/dev/null c 1 3
53 mknod -m 666 $VROOT/dev/zero c 1 5
54 mknod -m 666 $VROOT/dev/full c 1 7
55 mknod -m 644 $VROOT/dev/random c 1 8
56 mknod -m 644 $VROOT/dev/urandom c 1 9
57 mknod -m 666 $VROOT/dev/tty c 5 0
58 mknod -m 666 $VROOT/dev/ptmx c 5 2
59 # For bash command substitution
60 ln -nsf ../proc/self/fd /dev/fd
61 # For df and linuxconf
65 # Initialize /dev in reference image
68 # Mount /dev/pts in reference image
69 mkdir -p $VROOT/dev/pts
70 mount -t devpts none $VROOT/dev/pts
72 # Mount /proc in reference image
74 mount -t proc none $VROOT/proc
76 # Clean up before exiting if anything goes wrong
77 trap "umount $VROOT/proc ; umount $VROOT/dev/pts ; exit 255" ERR
79 # Create a dummy /etc/fstab in reference image
81 cat > $VROOT/etc/fstab <<EOF
82 # This fake fstab exists only to please df and linuxconf.
83 /dev/hdv1 / ext2 defaults 1 1
85 cp $VROOT/etc/fstab $VROOT/etc/mtab
87 # Prevent all locales from being installed in reference image
88 mkdir -p $VROOT/etc/rpm
89 cat > $VROOT/etc/rpm/macros <<EOF
90 %_install_langs en_US:en
92 %__file_context_path /dev/null
95 # Trick rpm and yum, who read the real root /etc/rpm/macros file
96 # rather than the one installed in the reference image, despite what
97 # you might expect the --root and --installroot options to mean. Both
98 # programs always read $HOME/.rpmmacros.
100 ln -sf $VROOT/etc/rpm/macros $PWD/.rpmmacros
102 # Initialize RPM database in reference image
103 mkdir -p $VROOT/var/lib/rpm
104 rpm --root $VROOT --initdb
106 # glibc must be specified explicitly for the correct arch to be chosen.
107 yum -c yum.conf --installroot=$VROOT -y install glibc yum
109 # yum will annoyingly use the /etc/yum.conf file in the --installroot
110 # even if overridden with -c
111 rm -f $VROOT/etc/yum.conf
113 # Some of the PlanetLab RPMs may attempt to call /sbin/runlevel to
114 # determine if the installation is running inside the BootCD
115 # environment. We would like to pretend that we are, so make sure
116 # /sbin/runlevel returns 'unknown'.
117 rm -f $VROOT/var/run/utmp
121 yum -c yum.conf --installroot=$VROOT -y groupinstall PlanetLab
123 # Remove stale RPM locks
124 rm -f $VROOT/var/lib/rpm/__db*
126 # Clean up /dev in reference image
127 umount $VROOT/dev/pts
129 # Disable unnecessary services
130 for service in netfs rawdevices cpuspeed smartd ; do
131 /usr/sbin/chroot $VROOT /sbin/chkconfig $service off
138 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C $VROOT .