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
18 # $Id: build.sh,v 1.32 2006/08/16 21:44:48 mlhuang Exp $
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 echo "* myplc: Installing base filesystem"
80 make_chroot root plc_config.xml
83 echo "* myplc: Building database schema"
86 # Install configuration scripts
87 echo "* myplc: Installing configuration scripts"
88 install -D -m 755 plc_config.py root/tmp/plc_config.py
89 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
90 install -D -m 755 plc-config root/usr/bin/plc-config
91 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
92 install -D -m 755 api-config root/usr/bin/api-config
93 install -D -m 755 db-config root/usr/bin/db-config
94 install -D -m 755 dns-config root/usr/bin/dns-config
97 echo "* myplc: Installing initscripts"
98 find plc.d | cpio -p -d -u root/etc/
99 install -D -m 755 guest.init root/etc/init.d/plc
100 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
102 # Install DB schema and API code
103 echo "* myplc: Installing DB schema and API code"
104 mkdir -p root/usr/share
105 rsync -a $srcdir/pl_db $srcdir/plc_api root/usr/share/
107 # Install web scripts
108 echo "* myplc: Installing web scripts"
109 mkdir -p root/usr/bin
111 $srcdir/plc/scripts/gen-sites-xml.py \
112 $srcdir/plc/scripts/gen-slices-xml-05.py \
113 $srcdir/plc/scripts/gen-static-content.py \
117 echo "* myplc: Installing web pages"
118 mkdir -p root/var/www/html
119 # Exclude old cruft, unrelated GENI pages, and official documents
121 --exclude='*2002' --exclude='*2003' \
122 --exclude=geni --exclude=PDN --exclude=Talks \
123 $srcdir/plc_www/ root/var/www/html/
125 # Install configuration file
126 echo "* myplc: Installing configuration file"
127 install -D -m 444 $config data/etc/planetlab/default_config.xml
128 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
130 # handle root's homedir and tweak root prompt
131 echo "* myplc: root's homedir and prompt"
134 cat << EOF > $roothome/.profile
135 export PS1="<plc> \$PS1"
137 chmod 644 $roothome/.profile
139 # Move "data" directories out of the installation
140 echo "* myplc: Moving data directories out of the installation"
145 /var/www/html/alpina-logs
147 /var/www/html/download
148 /var/www/html/generated
149 /var/www/html/install-rpms
153 move_datadirs root data "${datadirs[@]}"
155 # Remove generated bootmanager script
156 rm -f data/var/www/html/boot/bootmanager.sh
158 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
159 # tarball already contains all of the node RPMs pre-installed. Only
160 # updates or optional packages should be placed in this directory.
161 install -D -m 644 ../build/groups/v3_yumgroups.xml \
162 data/var/www/html/install-rpms/planetlab/yumgroups.xml
164 # Make image out of directory
165 echo "* myplc: Building loopback image"
166 make_image root root.img