propset - enables svn keywords
[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$
19 #
20
21 echo "$0" not supported anymore
22 echo "need to figure a way to handle space in group names in .lst files"
23 exit 1
24
25 . build.functions
26
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.
30 datadirs=(
31 /etc/planetlab
32 /root
33 /tmp
34 /usr/tmp
35 /var/tmp
36 /var/log
37 )
38
39 pl_fixdirs devel/root "${datadirs[@]}"
40
41
42 echo "* myplc-devel: Installing base filesystem"
43 mkdir -p devel/root
44 # xxx need be pldistro & fcdistro dependant
45 make_chroot_from_lst devel/root planetlab-devel.lst
46
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
51
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
58
59 # Install initscripts
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'
64
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"
69 uid=${SUDO_UID:-2000}
70 gid=${SUDO_GID:-2000}
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
75 exit 0
76 EOF
77 fi
78
79 # Copy build scripts to build home directory
80 mkdir -p devel/data/build
81 rsync -a $srcdir/build/ devel/data/build/
82
83 # Allow build user to build certain RPMs as root
84 cat >devel/root/etc/sudoers <<EOF
85 root    ALL=(ALL) ALL
86 #build  ALL=(root) NOPASSWD: /usr/bin/rpmbuild
87 build   ALL=(ALL)       NOPASSWD: ALL
88 EOF
89
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[@]}"
93
94 # Fix permissions on tmp directories
95 pl_fixtmp_permissions devel/data
96
97 # Make image out of directory
98 echo "* myplc-devel: Building loopback image"
99 pl_make_image devel/root devel/root.img 100000000
100
101 exit 0