ea8d2028a04c1ba04c3e78cde1352fb69e04e69d
[bootmanager.git] / support-files / buildnode.sh
1 #!/bin/bash
2 #
3 # Build PlanetLab-Bootstrap.tar.bz2, the reference image for PlanetLab
4 # nodes.
5 #
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2005-2006 The Trustees of Princeton University
8 #
9 # $Id: buildnode.sh,v 1.8 2006/04/11 15:42:04 mlhuang Exp $
10 #
11
12 PATH=/sbin:/bin:/usr/sbin:/usr/bin
13
14 # In both a normal CVS environment and a PlanetLab RPM
15 # build environment, all of our dependencies are checked out into
16 # directories at the same level as us.
17 if [ -d ../../build ] ; then
18     PATH=$PATH:../../build
19     srcdir=../..
20 else
21     echo "Error: Could not find $(cd ../.. && pwd -P)/build/"
22     exit 1
23 fi
24
25 export PATH
26
27 # Release and architecture to install
28 releasever=2
29 basearch=i386
30
31 usage()
32 {
33     echo "Usage: build.sh [OPTION]..."
34     echo "      -r release      Fedora release number (default: $releasever)"
35     echo "      -a arch         Fedora architecture (default: $basearch)"
36     echo "      -h              This message"
37     exit 1
38 }
39
40 # Get options
41 while getopts "r:a:h" opt ; do
42     case $opt in
43         r)
44             releasever=$OPTARG
45             ;;
46         a)
47             basearch=$OPTARG
48             ;;
49         h|*)
50             usage
51             ;;
52     esac
53 done
54
55 # Do not tolerate errors
56 set -e
57
58 VROOT=$PWD/PlanetLab-Bootstrap
59 install -d -m 755 $VROOT
60
61 # Some of the PlanetLab RPMs attempt to (re)start themselves in %post,
62 # unless the installation is running inside the BootCD environment. We
63 # would like to pretend that we are.
64 export PL_BOOTCD=1
65
66 # Install the "PlanetLab" group. This requires that the PlanetLab
67 # build system install the appropriate yumgroups.xml file (currently
68 # build/groups/v3_yumgroups.xml) in $RPM_BUILD_DIR/../RPMS/ and that
69 # mkfedora runs either yum-arch or createrepo on that directory. dev
70 # is specified explicitly because of a stupid bug in its %post script
71 # that causes its installation to fail; see the mkfedora script for a
72 # full explanation. coreutils and python are specified explicitly
73 # because groupinstall does not honor Requires(pre) dependencies
74 # properly, most %pre scripts require coreutils to be installed first,
75 # and some of our %post scripts require python.
76 mkfedora -v -r $releasever -a $basearch -p dev -p coreutils -p python -g PlanetLab $VROOT
77
78 # Disable unnecessary services
79 echo "* Disabling unnecessary services"
80 for service in netfs rawdevices cpuspeed smartd ; do
81     /usr/sbin/chroot $VROOT /sbin/chkconfig $service off
82 done
83
84 # Build tarball
85 echo "* Building bootstrap tarball"
86 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C $VROOT .
87 rm -rf $VROOT
88
89 exit 0