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)
14 # Mark Huang <mlhuang@cs.princeton.edu>
15 # Copyright (C) 2006 The Trustees of Princeton University
23 # Build myplc inside myplc-devel. Infinite recursion is avoided only
24 # if PLC_DEVEL_BOOTSTRAP is false in the default configuration file.
27 if [ "$PLC_DEVEL_BOOTSTRAP" = "true" ] ; then
28 # So that we don't pollute the actual myplc-devel image, we use
29 # the directory that was used to build the image instead of the
30 # image itself, and mount everything by hand.
31 mount -o bind,rw devel/data devel/root/data
32 mount -t proc none devel/root/proc
34 # If we used a local mirror, bind mount it into the chroot so that
35 # we can use it again.
36 if [ "${PLC_DEVEL_FEDORA_URL:0:7}" = "file://" ] ; then
37 mkdir -p devel/root/usr/share/mirrors/fedora
38 mount -o bind,ro ${PLC_DEVEL_FEDORA_URL#file://} devel/root/usr/share/mirrors/fedora
41 # Clean up before exiting if anything goes wrong
42 trap "umount $PWD/devel/root/data;
43 umount $PWD/devel/root/proc;
44 umount $PWD/devel/root/usr/share/mirrors/fedora" ERR INT
46 # Build myplc inside myplc-devel. Make sure PLC_DEVEL_BOOTSTRAP is
47 # false to avoid infinite recursion.
48 chroot devel/root su - <<EOF
51 plc-config --category=plc_devel --variable=bootstrap --value="false" --save
54 cvs -d /cvs checkout -r $TAG build
55 make TAG=$TAG -C /build myplc
58 # Yoink the image that was just built
59 mv devel/data/build/BUILD/myplc-*/myplc/root{,.img} devel/data/build/BUILD/myplc-*/myplc/data .
62 umount devel/root/data
63 umount devel/root/proc
64 umount devel/root/usr/share/mirrors/fedora || :
65 rm -rf devel/data/build
66 mkdir -p devel/data/build
73 # Build myplc in the host environment. This section is executed if
74 # PLC_DEVEL_BOOTSTRAP is false.
77 echo "* myplc: Installing base filesystem"
79 make_chroot root plc_config.xml
82 echo "* myplc: Building database schema"
85 # Install configuration scripts
86 echo "* myplc: Installing configuration scripts"
87 install -D -m 755 plc_config.py root/tmp/plc_config.py
88 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
89 install -D -m 755 plc-config root/usr/bin/plc-config
90 install -D -m 755 api-config root/usr/bin/api-config
91 install -D -m 755 db-config root/usr/bin/db-config
92 install -D -m 755 dns-config root/usr/bin/dns-config
95 echo "* myplc: Installing initscripts"
96 find plc.d | cpio -p -d -u root/etc/
97 install -D -m 755 guest.init root/etc/init.d/plc
98 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
100 # Install DB schema and API code
101 echo "* myplc: Installing DB schema and API code"
102 mkdir -p root/usr/share
103 rsync -a $srcdir/pl_db $srcdir/plc_api root/usr/share/
105 # Install web scripts
106 echo "* myplc: Installing web scripts"
107 mkdir -p root/usr/bin
109 $srcdir/plc/scripts/gen-sites-xml.py \
110 $srcdir/plc/scripts/gen-slices-xml-05.py \
111 $srcdir/plc/scripts/gen-static-content.py \
115 echo "* myplc: Installing web pages"
116 mkdir -p root/var/www/html
117 # Exclude old cruft, unrelated GENI pages, and official documents
119 --exclude='*2002' --exclude='*2003' \
120 --exclude=geni --exclude=PDN --exclude=Talks \
121 $srcdir/plc_www/ root/var/www/html/
123 # Install configuration file
124 echo "* myplc: Installing configuration file"
125 install -D -m 444 $config data/etc/planetlab/default_config.xml
126 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
128 # Move "data" directories out of the installation
132 /var/www/html/alpina-logs
134 /var/www/html/download
135 /var/www/html/generated
136 /var/www/html/install-rpms
140 move_datadirs root data "${datadirs[@]}"
142 # Remove generated bootmanager script
143 rm -f data/var/www/html/boot/bootmanager.sh
145 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
146 # tarball already contains all of the node RPMs pre-installed. Only
147 # updates or optional packages should be placed in this directory.
148 install -D -m 644 ../build/groups/v3_yumgroups.xml \
149 data/var/www/html/install-rpms/planetlab/yumgroups.xml
151 # Make image out of directory
152 echo "* myplc: Building loopback image"
153 make_image root root.img