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 # Marc E. Fiuczynski <mef@cs.princeton.edu>
17 # Copyright (C) 2006-2007 The Trustees of Princeton University
19 # $Id: build_devel.sh,v 1.11 2007/08/31 02:33:04 mef Exp $
24 # These directories are allowed to grow to unspecified size, so they
25 # are stored as symlinks to the /data partition. mkfedora and yum
26 # expect some of them to be real directories, however.
36 pl_fixdirs devel/root "${datadirs[@]}"
39 echo "* myplc-devel: Installing base filesystem"
41 make_chroot devel/root plc_devel_config.xml
43 # Install configuration file
44 echo "* myplc-devel: Installing configuration file"
45 install -D -m 444 plc_devel_config.xml devel/data/etc/planetlab/default_config.xml
46 install -D -m 444 plc_config.dtd devel/data/etc/planetlab/plc_config.dtd
48 # Install configuration scripts
49 echo "* myplc-devel: Installing configuration scripts"
50 install -D -m 755 plc_config.py devel/root/tmp/plc_config.py
51 chroot devel/root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
52 install -D -m 755 plc-config devel/root/usr/bin/plc-config
53 install -D -m 755 plc-config-tty devel/root/usr/bin/plc-config-tty
56 echo "* myplc-devel: Installing initscripts"
57 find plc.d/functions | cpio -p -d -u devel/root/etc/
58 install -D -m 755 guest.init devel/root/etc/init.d/plc
59 chroot devel/root sh -c 'chkconfig --add plc; chkconfig plc on'
61 # Add a build user with the same ID as the current build user, who can
62 # then cross-mount their home directory into the image and build MyPLC
63 # in their home directory.
64 echo "* myplc-devel: Adding build user"
67 if ! grep -q "Automated Build" devel/root/etc/passwd ; then
68 chroot devel/root sh -c "groupadd -o -g $gid build; \
69 useradd -o -c 'Automated Build' -u $uid -g $gid -n -d /data/build -M -s /bin/bash build; \
73 # Copy build scripts to build home directory
74 mkdir -p devel/data/build
75 rsync -a $srcdir/build/ devel/data/build/
77 # Allow build user to build certain RPMs as root
78 cat >devel/root/etc/sudoers <<EOF
80 #build ALL=(root) NOPASSWD: /usr/bin/rpmbuild
81 build ALL=(ALL) NOPASSWD: ALL
84 # Move "data" directories out of the installation
85 echo "* myplc-devel: Moving data directories out of the installation"
86 pl_move_dirs devel/root devel/data /data "${datadirs[@]}"
88 # Fix permissions on tmp directories
89 pl_fixtmp_permissions devel/data
91 # Make image out of directory
92 echo "* myplc-devel: Building loopback image"
93 pl_make_image devel/root devel/root.img 100000000