- fix version number, bump release number, added changelog
[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 # devel/data/root (root's home dir)
14 #
15 # Mark Huang <mlhuang@cs.princeton.edu>
16 # Copyright (C) 2006 The Trustees of Princeton University
17 #
18 # $Id: build_devel.sh,v 1.5 2006/08/18 14:35:52 thierry Exp $
19 #
20
21 . build.functions
22
23 echo "* myplc-devel: Installing base filesystem"
24 mkdir -p devel/root
25 make_chroot devel/root plc_devel_config.xml
26
27 # Import everything (including ourself) into a private CVS tree
28 echo "* myplc-devel: Building CVS repository"
29 cvsroot=$PWD/devel/data/cvs
30 mkdir -p $cvsroot
31 cvs -d $cvsroot init
32
33 myplc=$(basename $PWD)
34 pushd ..
35 for dir in * ; do
36     if [ ! -d $cvsroot/$dir ] ; then
37         pushd $dir
38         if [ "$dir" = "$myplc" ] ; then
39             # Ignore generated files
40             ignore="-I ! -I devel -I root -I root.img -I data" 
41         else
42             ignore="-I !"
43         fi
44         cvs -d $cvsroot import -m "Initial import" -ko $ignore $dir planetlab $IMPORT_TAG
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 install -D -m 755 plc-config-tty devel/root/usr/bin/plc-config-tty
61
62 # Install initscripts
63 echo "* myplc-devel: Installing initscripts"
64 find plc.d/functions | cpio -p -d -u devel/root/etc/
65 install -D -m 755 guest.init devel/root/etc/init.d/plc
66 chroot devel/root sh -c 'chkconfig --add plc; chkconfig plc on'
67
68 # handle root's homedir and tweak root prompt
69 echo "* myplc-devel: root's homedir and prompt"
70 roothome=devel/data/root
71 mkdir -p $roothome
72 cat << EOF > $roothome/.profile
73 export PS1="<plc-devel> \$PS1"
74 EOF
75 chmod 644 $roothome/.profile
76
77 # Move "data" directories out of the installation
78 echo "* myplc-devel: Moving data directories out of the installation"
79 move_datadirs devel/root devel/data \
80     /etc/planetlab /build /cvs /root
81
82 # Make image out of directory
83 echo "* myplc-devel: Building loopback image"
84 make_image devel/root devel/root.img
85
86 exit 0