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 sh -s <<EOF
51 plc-config --category=plc_devel --variable=bootstrap --value="false" --save
54 cvs -d /cvs checkout build
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 || :
66 # Could leave it around, but it does consume a lot of disk space
67 # rm -rf devel/data/build
68 # mkdir -p devel/data/build
75 # Build myplc in the host environment. This section is executed if
76 # PLC_DEVEL_BOOTSTRAP is false.
79 echo "* myplc: Installing base filesystem"
81 make_chroot root plc_config.xml
84 echo "* myplc: Building database schema"
87 # Install configuration scripts
88 echo "* myplc: Installing configuration scripts"
89 install -D -m 755 plc_config.py root/tmp/plc_config.py
90 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
91 install -D -m 755 plc-config root/usr/bin/plc-config
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 # Move "data" directories out of the installation
134 /var/www/html/alpina-logs
136 /var/www/html/download
137 /var/www/html/generated
138 /var/www/html/install-rpms
142 move_datadirs root data "${datadirs[@]}"
144 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
145 # tarball already contains all of the node RPMs pre-installed. Only
146 # updates or optional packages should be placed in this directory.
147 if [ -n "$RPM_BUILD_DIR" ] ; then
148 echo "* myplc: Initializing node RPMs directory"
149 RPM_RPMS_DIR=$(cd $(dirname $RPM_BUILD_DIR)/RPMS && pwd -P)
150 mkdir -p data/var/www/html/install-rpms/planetlab
151 if [ -f $RPM_RPMS_DIR/yumgroups.xml ] ; then
152 install -D -m 644 $RPM_RPMS_DIR/yumgroups.xml \
153 data/var/www/html/install-rpms/planetlab/yumgroups.xml
156 if [ -x /usr/bin/yum-arch ] ; then
157 yum-arch data/var/www/html/install-rpms/planetlab
160 if [ -x /usr/bin/createrepo ] ; then
161 if [ -f data/var/www/html/install-rpms/planetlab/yumgroups.xml ] ; then
162 groupfile="-g yumgroups.xml"
164 createrepo $groupfile data/var/www/html/install-rpms/planetlab
168 # Make image out of directory
169 echo "* myplc: Building loopback image"
170 make_image root root.img