3 # Build a complete MyPLC development environment. Requires PlanetLab
4 # source code to be exported into directories at the same level as we
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)
15 # Mark Huang <mlhuang@cs.princeton.edu>
16 # Copyright (C) 2006 The Trustees of Princeton University
18 # $Id: build_devel.sh,v 1.6 2007/01/11 21:49:52 mlhuang Exp $
23 # These directories are allowed to grow to unspecified size, so they
24 # are stored as symlinks to the /data partition. mkfedora and yum
25 # expect some of them to be real directories, however.
36 for datadir in "${datadirs[@]}" ; do
37 # If we are being re-run, it may be a symlink
38 if [ -h devel/root/$datadir ] ; then
39 rm -f devel/root/$datadir
40 mkdir -p devel/root/$datadir
44 echo "* myplc-devel: Installing base filesystem"
46 make_chroot devel/root plc_devel_config.xml
48 # Import everything (including ourself) into a private CVS tree
49 echo "* myplc-devel: Building CVS repository"
50 cvsroot=$PWD/devel/data/cvs
54 myplc=$(basename $PWD)
57 if [ ! -d $cvsroot/$dir ] ; then
59 if [ "$dir" = "$myplc" ] ; then
60 # Ignore generated files
61 ignore="-I ! -I devel -I root -I root.img -I data"
65 cvs -d $cvsroot import -m "Initial import" -ko $ignore $dir planetlab $IMPORT_TAG
71 # Install configuration file
72 echo "* myplc-devel: Installing configuration file"
73 install -D -m 444 plc_devel_config.xml devel/data/etc/planetlab/default_config.xml
74 install -D -m 444 plc_config.dtd devel/data/etc/planetlab/plc_config.dtd
76 # Install configuration scripts
77 echo "* myplc-devel: Installing configuration scripts"
78 install -D -m 755 plc_config.py devel/root/tmp/plc_config.py
79 chroot devel/root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
80 install -D -m 755 plc-config devel/root/usr/bin/plc-config
81 install -D -m 755 plc-config-tty devel/root/usr/bin/plc-config-tty
84 echo "* myplc-devel: Installing initscripts"
85 find plc.d/functions | cpio -p -d -u devel/root/etc/
86 install -D -m 755 guest.init devel/root/etc/init.d/plc
87 chroot devel/root sh -c 'chkconfig --add plc; chkconfig plc on'
89 # handle root's homedir and tweak root prompt
90 echo "* myplc-devel: root's homedir and prompt"
91 roothome=devel/data/root
93 cat << EOF > $roothome/.profile
94 export PS1="<plc-devel> \$PS1"
96 chmod 644 $roothome/.profile
98 # Move "data" directories out of the installation
99 echo "* myplc-devel: Moving data directories out of the installation"
100 move_datadirs devel/root devel/data "${datadirs[@]}"
102 # Fix permissions on tmp directories
103 chmod 1777 devel/data/tmp devel/data/usr/tmp devel/data/var/tmp
105 # Make image out of directory
106 echo "* myplc-devel: Building loopback image"
107 make_image devel/root devel/root.img