-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-
-# In both a normal CVS environment and a PlanetLab RPM
-# build environment, all of our dependencies are checked out into
-# directories at the same level as us.
-if [ -d ../build ] ; then
- PATH=$PATH:../build
- srcdir=..
-else
- echo "Error: Could not find $(cd .. && pwd -P)/build/"
- exit 1
-fi
-
-export PATH
-
-# PLC configuration file
-config=plc_config.xml
-
-# Release and architecture to install
-releasever=4
-basearch=i386
-
-# Initial size of the image
-size=1000000000
-
-usage()
-{
- echo "Usage: build.sh [OPTION]..."
- echo " -c file PLC configuration file (default: $config)"
- echo " -r release Fedora release number (default: $releasever)"
- echo " -a arch Fedora architecture (default: $basearch)"
- echo " -s size Approximate size of the installation (default: $size)"
- echo " -h This message"
- exit 1
-}
-
-# Get options
-while getopts "c:r:a:s:h" opt ; do
- case $opt in
- c)
- config=$OPTARG
- ;;
- r)
- releasever=$OPTARG
- ;;
- a)
- basearch=$OPTARG
- ;;
- s)
- size=$OPTARG
- ;;
- h|*)
- usage
- ;;
- esac
-done
-
-# Do not tolerate errors
-set -e
-
-root=root
-data=data
-
-if [ ! -f $root.img ] ; then
- bs=4096
- count=$(($size / 4096))
- dd bs=$bs count=$count if=/dev/zero of=$root.img
- mkfs.ext3 -j -F $root.img
-fi
-
-mkdir -p $root $data
-mount -o loop $root.img $root
-trap "umount $root" ERR
-
-#
-# Build
-#
-
-# Get package list
-while read package ; do
- packages="$packages -p $package"
-done < <(./plc-config --packages $config)
-
-# Install base system
-mkfedora -v -r $releasever -a $basearch -k $packages $root
-
-# Disable all services in reference image
-chroot $root sh -c "/sbin/chkconfig --list | awk '{ print \$1 }' | xargs -i /sbin/chkconfig {} off"
-
-# FC2 minilogd starts up during shutdown and makes unmounting
-# impossible. Just get rid of it.
-rm -f $root/sbin/minilogd
-ln -nsf /bin/true $root/sbin/minilogd
-
-# Build schema
-make -C $srcdir/pl_db
-
-#
-# Install
-#
-
-# Install configuration scripts
-echo "* Installing configuration scripts"
-install -D -m 755 plc_config.py $root/tmp/plc_config.py
-chroot $root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
-install -D -m 755 plc-config $root/usr/bin/plc-config
-install -D -m 755 api-config $root/usr/bin/api-config
-install -D -m 755 dns-config $root/usr/bin/dns-config
-
-# Install initscripts
-echo "* Installing initscripts"
-find plc.d | cpio -p -d -u $root/etc/
-install -D -m 755 guest.init $root/etc/init.d/plc
-chroot $root sh -c 'chkconfig --add plc; chkconfig plc on'
-
-# Install DB schema and API code
-echo "* Installing DB schema and API code"
-mkdir -p $root/usr/share
-rsync -a $srcdir/pl_db $srcdir/plc_api $root/usr/share/
-
-# Install web scripts
-echo "* Installing web scripts"
-mkdir -p $root/usr/bin
-install -m 755 \
- $srcdir/plc/scripts/gen-sites-xml.py \
- $srcdir/plc/scripts/gen-slices-xml-05.py \
- $srcdir/plc/scripts/gen-static-content.py \
- $root/usr/bin/