- use mkfedora
[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.5 2006/03/21 14:57:29 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.
70 mkfedora -v -r $releasever -a $basearch -g PlanetLab $VROOT
71
72 # Disable unnecessary services
73 echo "* Disabling unnecessary services"
74 for service in netfs rawdevices cpuspeed smartd ; do
75     /usr/sbin/chroot $VROOT /sbin/chkconfig $service off
76 done
77
78 # Build tarball
79 echo "* Building bootstrap tarball"
80 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C $VROOT .
81 rm -rf $VROOT
82
83 exit 0