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/data/fedora
38 mount -o bind,ro ${PLC_DEVEL_FEDORA_URL#file://} devel/root/data/fedora
41 # Clean up before exiting if anything goes wrong
42 trap "umount $PWD/devel/root/data/fedora;
43 umount $PWD/devel/root/data;
44 umount $PWD/devel/root/proc" 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 $BUILD_TAG build
55 make TAG=$BUILD_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 plc-config-tty root/usr/bin/plc-config-tty
91 install -D -m 755 api-config root/usr/bin/api-config
92 install -D -m 755 db-config root/usr/bin/db-config
93 install -D -m 755 dns-config root/usr/bin/dns-config
96 echo "* myplc: Installing initscripts"
97 find plc.d | cpio -p -d -u root/etc/
98 install -D -m 755 guest.init root/etc/init.d/plc
99 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
101 # Install DB schema and API code
102 echo "* myplc: Installing DB schema and API code"
103 mkdir -p root/usr/share
104 rsync -a $srcdir/pl_db $srcdir/plc_api root/usr/share/
106 # Install web scripts
107 echo "* myplc: Installing web scripts"
108 mkdir -p root/usr/bin
110 $srcdir/plc/scripts/gen-sites-xml.py \
111 $srcdir/plc/scripts/gen-slices-xml-05.py \
112 $srcdir/plc/scripts/gen-static-content.py \
116 echo "* myplc: Installing web pages"
117 mkdir -p root/var/www/html
118 # Exclude old cruft, unrelated GENI pages, and official documents
120 --exclude='*2002' --exclude='*2003' \
121 --exclude=geni --exclude=PDN --exclude=Talks \
122 $srcdir/plc_www/ root/var/www/html/
124 # Install configuration file
125 echo "* myplc: Installing configuration file"
126 install -D -m 444 $config data/etc/planetlab/default_config.xml
127 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
129 # Move "data" directories out of the installation
133 /var/www/html/alpina-logs
135 /var/www/html/download
136 /var/www/html/generated
137 /var/www/html/install-rpms
141 move_datadirs root data "${datadirs[@]}"
143 # Remove generated bootmanager script
144 rm -f data/var/www/html/boot/bootmanager.sh
146 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
147 # tarball already contains all of the node RPMs pre-installed. Only
148 # updates or optional packages should be placed in this directory.
149 install -D -m 644 ../build/groups/v3_yumgroups.xml \
150 data/var/www/html/install-rpms/planetlab/yumgroups.xml
152 # Make image out of directory
153 echo "* myplc: Building loopback image"
154 make_image root root.img