- MyPLC 0.4 RC2
[myplc.git] / build_devel.sh
1 #!/bin/bash
2 #
3 # Build a complete MyPLC development environment. Requires PlanetLab
4 # source code to be exported into directories at the same level as we
5 # are (i.e., ..).
6 #
7 # devel/root.img (loopback image)
8 # devel/root/ (mount point)
9 # devel/data/ (various data files)
10 # devel/data/cvs/ (local CVS repository)
11 # devel/data/build/ (build area)
12 # devel/data/etc/planetlab/ (configuration)
13 #
14 # Mark Huang <mlhuang@cs.princeton.edu>
15 # Copyright (C) 2006 The Trustees of Princeton University
16 #
17 # $Id: build_devel.sh,v 1.1 2006/07/17 21:31:31 mlhuang Exp $
18 #
19
20 . build.functions
21
22 echo "* myplc-devel: Installing base filesystem"
23 mkdir -p devel/root
24 make_chroot devel/root plc_devel_config.xml
25
26 # Import everything (including ourself) into a private CVS tree
27 echo "* myplc-devel: Building CVS repository"
28 cvsroot=$PWD/devel/data/cvs
29 mkdir -p $cvsroot
30 cvs -d $cvsroot init
31
32 myplc=$(basename $PWD)
33 pushd ..
34 for dir in * ; do
35     if [ ! -d $cvsroot/$dir ] ; then
36         pushd $dir
37         if [ "$dir" = "$myplc" ] ; then
38             # Ignore generated files
39             ignore="-I ! -I devel -I root -I root.img -I data" 
40         else
41             ignore="-I !"
42         fi
43         date=$(date +%Y-%m-%d)
44         cvs -d $cvsroot import -m "Initial import" -ko $ignore $dir planetlab planetlab-$date
45         popd
46     fi
47 done
48 popd
49
50 # Install configuration file
51 echo "* myplc-devel: Installing configuration file"
52 install -D -m 444 plc_devel_config.xml devel/data/etc/planetlab/default_config.xml
53 install -D -m 444 plc_config.dtd devel/data/etc/planetlab/plc_config.dtd
54
55 # Install configuration scripts
56 echo "* myplc-devel: Installing configuration scripts"
57 install -D -m 755 plc_config.py devel/root/tmp/plc_config.py
58 chroot devel/root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
59 install -D -m 755 plc-config devel/root/usr/bin/plc-config
60
61 # Install initscripts
62 echo "* myplc-devel: Installing initscripts"
63 find plc.d/functions | cpio -p -d -u devel/root/etc/
64 install -D -m 755 guest.init devel/root/etc/init.d/plc
65 chroot devel/root sh -c 'chkconfig --add plc; chkconfig plc on'
66
67 # Move "data" directories out of the installation
68 echo "* myplc-devel: Moving data directories out of the installation"
69 move_datadirs devel/root devel/data \
70     /etc/planetlab /build /cvs
71
72 # Make image out of directory
73 echo "* myplc-devel: Building loopback image"
74 make_image devel/root devel/root.img
75
76 exit 0