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
88 /var/www/html/generated
89 /var/www/html/install-rpms
96 for datadir in "${datadirs[@]}" ; do
97 # If we are being re-run, it may be a symlink
98 rm -f root/$datadir || :
99 mkdir -p root/$datadir
102 echo "* myplc: Installing base filesystem"
104 make_chroot root plc_config.xml
106 # Install configuration scripts
107 echo "* myplc: Installing configuration scripts"
108 install -D -m 755 plc_config.py root/tmp/plc_config.py
109 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
110 install -D -m 755 plc-config root/usr/bin/plc-config
111 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
112 install -D -m 755 api-config root/usr/bin/api-config
113 install -D -m 755 db-config root/usr/bin/db-config
114 install -D -m 755 dns-config root/usr/bin/dns-config
116 # Install initscripts
117 echo "* myplc: Installing initscripts"
118 find plc.d | cpio -p -d -u root/etc/
119 install -D -m 755 guest.init root/etc/init.d/plc
120 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
122 # Install web scripts
123 echo "* myplc: Installing web scripts"
124 mkdir -p root/usr/bin
126 $srcdir/plc/scripts/gen-sites-xml.py \
127 $srcdir/plc/scripts/gen-slices-xml-05.py \
128 $srcdir/plc/scripts/gen-static-content.py \
132 echo "* myplc: Installing web pages"
133 mkdir -p root/var/www/html
134 # Exclude old cruft, unrelated GENI pages, and official documents
135 rsync -a $srcdir/new_plc_www/ root/var/www/html/
137 # Make the Drupal files upload directory owned by Apache
138 chown apache:apache root/var/www/html/files
140 # Install Drupal rewrite rules
141 install -D -m 644 $srcdir/new_plc_www/drupal.conf root/etc/httpd/conf.d/drupal.conf
143 # Install configuration file
144 echo "* myplc: Installing configuration file"
145 install -D -m 444 $config data/etc/planetlab/default_config.xml
146 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
148 # handle root's homedir and tweak root prompt
149 echo "* myplc: root's homedir and prompt"
152 cat << EOF > $roothome/.profile
153 export PS1="<plc> \$PS1"
155 chmod 644 $roothome/.profile
157 # Move "data" directories out of the installation
158 echo "* myplc: Moving data directories out of the installation"
159 move_datadirs root data "${datadirs[@]}"
161 # Fix permissions on tmp directories
162 chmod 1777 data/tmp data/usr/tmp data/var/tmp
164 # Remove generated bootmanager script
165 rm -f data/var/www/html/boot/bootmanager.sh
167 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
168 # tarball already contains all of the node RPMs pre-installed. Only
169 # updates or optional packages should be placed in this directory.
170 install -D -m 644 ../build/groups/v3_yumgroups.xml \
171 data/var/www/html/install-rpms/planetlab/yumgroups.xml
173 # Make image out of directory
174 echo "* myplc: Building loopback image"
175 make_image root root.img