3fc005b5bae6dcd4c4f80470dbda78ed46acb374
[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.7 2006/04/05 21:45:34 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 is specified explicitly because
73 # groupinstall does not honor Requires(pre) dependencies properly, and
74 # most %pre scripts require coreutils to be installed first.
75 mkfedora -v -r $releasever -a $basearch -p dev -p coreutils -g PlanetLab $VROOT
76
77 # Disable unnecessary services
78 echo "* Disabling unnecessary services"
79 for service in netfs rawdevices cpuspeed smartd ; do
80     /usr/sbin/chroot $VROOT /sbin/chkconfig $service off
81 done
82
83 # Build tarball
84 echo "* Building bootstrap tarball"
85 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C $VROOT .
86 rm -rf $VROOT
87
88 exit 0