3 # Builds MyPLC, either inside the MyPLC development environment in
4 # devel/root (if PLC_DEVEL_BOOTSTRAP is true), or in the current host
5 # environment (may be itself a MyPLC development environment or a
6 # Fedora Core 4 environment with the appropriate development packages
9 # root.img (loopback image)
11 # data/ (various data files)
12 # data/etc/planetlab/ (configuration files)
13 # data/root (root's homedir)
15 # Mark Huang <mlhuang@cs.princeton.edu>
16 # Copyright (C) 2006 The Trustees of Princeton University
24 # Build myplc inside myplc-devel. Infinite recursion is avoided only
25 # if PLC_DEVEL_BOOTSTRAP is false in the default configuration file.
28 if [ "$PLC_DEVEL_BOOTSTRAP" = "true" ] ; then
29 # So that we don't pollute the actual myplc-devel image, we use
30 # the directory that was used to build the image instead of the
31 # image itself, and mount everything by hand.
32 mount -o bind,rw devel/data devel/root/data
33 mount -t proc none devel/root/proc
35 # If we used a local mirror, bind mount it into the chroot so that
36 # we can use it again.
37 if [ "${PLC_DEVEL_FEDORA_URL:0:7}" = "file://" ] ; then
38 mkdir -p devel/root/data/fedora
39 mount -o bind,ro ${PLC_DEVEL_FEDORA_URL#file://} devel/root/data/fedora
42 # Clean up before exiting if anything goes wrong
43 trap "umount $PWD/devel/root/data/fedora;
44 umount $PWD/devel/root/data;
45 umount $PWD/devel/root/proc" ERR INT
47 # Build myplc inside myplc-devel. Make sure PLC_DEVEL_BOOTSTRAP is
48 # false to avoid infinite recursion.
49 chroot devel/root su - <<EOF
52 plc-config --category=plc_devel --variable=bootstrap --value="false" --save
55 cvs -d /cvs checkout -r $BUILD_TAG build
56 make TAG=$BUILD_TAG -C /build myplc
59 # Yoink the image that was just built
60 mv devel/data/build/BUILD/myplc-*/myplc/root{,.img} devel/data/build/BUILD/myplc-*/myplc/data .
63 umount devel/root/data/fedora || :
64 umount devel/root/data
65 umount devel/root/proc
66 rm -rf devel/data/build
67 mkdir -p devel/data/build
74 # Build myplc in the host environment. This section is executed if
75 # PLC_DEVEL_BOOTSTRAP is false.
78 # These directories are allowed to grow to unspecified size, so they
79 # are stored as symlinks to the /data partition. mkfedora and yum
80 # expect some of them to be real directories, however.
85 /var/www/html/alpina-logs
87 /var/www/html/download
89 /var/www/html/generated
90 /var/www/html/install-rpms
97 for datadir in "${datadirs[@]}" ; do
98 # If we are being re-run, it may be a symlink
99 if [ -h root/$datadir ] ; then
101 mkdir -p root/$datadir
105 echo "* myplc: Installing base filesystem"
107 make_chroot root plc_config.xml
109 # Install configuration scripts
110 echo "* myplc: Installing configuration scripts"
111 install -D -m 755 plc_config.py root/tmp/plc_config.py
112 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
113 install -D -m 755 plc-config root/usr/bin/plc-config
114 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
115 install -D -m 755 api-config root/usr/bin/api-config
116 install -D -m 755 db-config root/usr/bin/db-config
117 install -D -m 755 dns-config root/usr/bin/dns-config
119 # Install initscripts
120 echo "* myplc: Installing initscripts"
121 find plc.d | cpio -p -d -u root/etc/
122 install -D -m 755 guest.init root/etc/init.d/plc
123 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
125 # Install web scripts
126 echo "* myplc: Installing web scripts"
127 mkdir -p root/usr/bin
129 $srcdir/plc/scripts/gen-sites-xml.py \
130 $srcdir/plc/scripts/gen-slices-xml-05.py \
131 $srcdir/plc/scripts/gen-static-content.py \
135 echo "* myplc: Installing web pages"
136 mkdir -p root/var/www/html
137 rsync -a $srcdir/new_plc_www/ root/var/www/html/
139 # Install Drupal rewrite rules
140 install -D -m 644 $srcdir/new_plc_www/drupal.conf root/etc/httpd/conf.d/drupal.conf
142 # Install configuration file
143 echo "* myplc: Installing configuration file"
144 install -D -m 444 $config data/etc/planetlab/default_config.xml
145 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
147 # handle root's homedir and tweak root prompt
148 echo "* myplc: root's homedir and prompt"
151 cat << EOF > $roothome/.profile
152 export PS1="<plc> \$PS1"
154 chmod 644 $roothome/.profile
156 # Move "data" directories out of the installation
157 echo "* myplc: Moving data directories out of the installation"
158 move_datadirs root data "${datadirs[@]}"
160 # Fix permissions on tmp directories
161 chmod 1777 data/tmp data/usr/tmp data/var/tmp
163 # Remove generated bootmanager script
164 rm -f data/var/www/html/boot/bootmanager.sh
166 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
167 # tarball already contains all of the node RPMs pre-installed. Only
168 # updates or optional packages should be placed in this directory.
169 install -D -m 644 ../build/groups/v3_yumgroups.xml \
170 data/var/www/html/install-rpms/planetlab/yumgroups.xml
172 # Make image out of directory
173 echo "* myplc: Building loopback image"
174 make_image root root.img