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 1078 2007-11-15 13:38:27Z thierry $
21 echo "$0" not supported anymore
22 echo "need to figure a way to handle space in group names in .lst files"
27 # These directories are allowed to grow to unspecified size, so they
28 # are stored as symlinks to the /data partition. mkfedora and yum
29 # expect some of them to be real directories, however.
39 pl_fixdirs devel/root "${datadirs[@]}"
42 echo "* myplc-devel: Installing base filesystem"
44 # xxx need be pldistro & fcdistro dependant
45 make_chroot_from_lst devel/root planetlab-devel.lst
47 # Install configuration file
48 echo "* myplc-devel: Installing configuration file"
49 install -D -m 444 plc_devel_config.xml devel/data/etc/planetlab/default_config.xml
50 install -D -m 444 plc_config.dtd devel/data/etc/planetlab/plc_config.dtd
52 # Install configuration scripts
53 echo "* myplc-devel: Installing configuration scripts"
54 install -D -m 755 plc_config.py devel/root/tmp/plc_config.py
55 chroot devel/root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
56 install -D -m 755 plc-config devel/root/usr/bin/plc-config
57 install -D -m 755 plc-config-tty devel/root/usr/bin/plc-config-tty
60 echo "* myplc-devel: Installing initscripts"
61 find plc.d/functions | cpio -p -d -u devel/root/etc/
62 install -D -m 755 guest.init devel/root/etc/init.d/plc
63 chroot devel/root sh -c 'chkconfig --add plc; chkconfig plc on'
65 # Add a build user with the same ID as the current build user, who can
66 # then cross-mount their home directory into the image and build MyPLC
67 # in their home directory.
68 echo "* myplc-devel: Adding build user"
71 if ! grep -q "Automated Build" devel/root/etc/passwd ; then
72 chroot devel/root <<EOF
73 groupadd -o -g $gid build
74 useradd -o -c 'Automated Build' -u $uid -g $gid -n -d /data/build -M -s /bin/bash build
79 # Copy build scripts to build home directory
80 mkdir -p devel/data/build
81 rsync -a $srcdir/build/ devel/data/build/
83 # Allow build user to build certain RPMs as root
84 cat >devel/root/etc/sudoers <<EOF
86 #build ALL=(root) NOPASSWD: /usr/bin/rpmbuild
87 build ALL=(ALL) NOPASSWD: ALL
90 # Move "data" directories out of the installation
91 echo "* myplc-devel: Moving data directories out of the installation"
92 pl_move_dirs devel/root devel/data /data "${datadirs[@]}"
94 # Fix permissions on tmp directories
95 pl_fixtmp_permissions devel/data
97 # Make image out of directory
98 echo "* myplc-devel: Building loopback image"
99 pl_make_image devel/root devel/root.img 100000000