3 # Build PlanetLab-Bootstrap.tar.bz2, the reference image for PlanetLab
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Marc E. Fiuczynski <mef@cs.princeton.edu>
8 # Copyright (C) 2005-2007 The Trustees of Princeton University
10 # $Id: buildnode.sh,v 1.12.6.1 2007/08/30 20:09:20 mef Exp $
15 # This will build the Planetlab-Bootstrap.tar.bz2, which comprises
16 # the base root image on the node, then create the ${NAME} bootstrap image
17 # which is made up of just the additional files needed for a ${NAME} nodegroup
21 PATH=/sbin:/bin:/usr/sbin:/usr/bin
23 # In both a normal CVS environment and a PlanetLab RPM
24 # build environment, all of our dependencies are checked out into
25 # directories at the same level as us.
26 if [ -d ../build ] ; then
30 echo "Error: Could not find $(cd ../.. && pwd -P)/build/"
38 pl_process_fedora_options $@
42 # pldistro expected as $1 - defaults to planetlab
44 [ -n "$@" ] && pldistro=$1
46 # Do not tolerate errors
49 # Some of the PlanetLab RPMs attempt to (re)start themselves in %post,
50 # unless the installation is running inside the BootCD environment. We
51 # would like to pretend that we are.
54 echo "+++++++++++++pkgsfile=$pkgsfile (and -k)"
56 # Populate a minimal /dev and then the files for the base PlanetLab-Bootstrap content
58 install -d -m 755 ${vref}
59 pl_root_makedevs $vref
61 pkgsfile=$(pl_locateDistroFile ../build/ ${pldistro} bootstrapfs.pkgs)
62 # -k = exclude kernel* packages
63 pl_root_mkfedora -k -f $pkgsfile ${vref}
65 # for distros that do not define bootstrapfs variants
67 for pkgs in ../build/config.${pldistro}/bootstrapfs-*.pkgs ; do
68 NAME=$(basename $pkgs .pkgs | sed -e s,bootstrapfs-,,)
70 echo "--------START BUILDING PlanetLab-Bootstrap-${NAME}: $(date)"
72 # "Parse" out the packages and groups for yum
73 packages=$(pl_getPackages ${pl_DISTRO_NAME} $pkgs)
74 groups=$(pl_getGroups ${pl_DISTRO_NAME} $pkgs)
75 echo "${NAME} has the following packages : ${packages}"
76 echo "${NAME} has the following groups : ${groups}"
78 vdir=${PWD}/${pldistro}-filesystems/${NAME}
80 install -d -m 755 ${vdir}
82 # Clone the base reference to the bootstrap fs
83 (cd ${vref} && find . | cpio -m -d -u -p ${vdir})
84 rm -f ${vdir}/var/lib/rpm/__db*
86 # Install the system vserver specific packages
87 [ -n "$packages" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y install $packages
88 [ -n "$groups" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y groupinstall $groups
90 if [ -f "${vdir}/proc/cpuinfo" ] ; then
91 echo "WARNING: some RPM appears to have mounted /proc in ${NAME}. Unmounting it!"
95 # Remove unneeded services
96 for service in util-vserver vprocunhide vservers-default; do
97 chroot ${vdir} /sbin/chkconfig $service off
100 # Disable splaying of cron.
101 # At this step, vdir is base, and vref is the set of changes that end up in the nodegroup
102 echo > ${vdir}/etc/sysconfig/crontab
104 # Add site_admin account
105 chroot ${vdir} /usr/sbin/useradd -p "" -u 502 -m site_admin
107 # Create a copy of the ${NAME} bootstrap filesystem w/o the base
108 # bootstrap filesystem and make it smaller. This is a three step
111 # step 1: clean out yum cache to reduce space requirements
112 yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y clean all
114 # step 2: figure out the new/changed files in ${vdir} vs. ${vref} and compute ${vdir}.changes
115 rsync -anv ${vdir}/ ${vref}/ > ${vdir}.changes
116 linecount=$(wc -l ${vdir}.changes | awk ' { print $1 } ')
117 let headcount=$linecount-3
118 let tailcount=$headcount-1
119 # get rid of the last 3 lines of the rsync output
120 head -${headcount} ${vdir}.changes > ${vdir}.changes.1
121 # get rid of the first line of the rsync output
122 tail -${tailcount} ${vdir}.changes.1 > ${vdir}.changes.2
123 # post process rsync output to get rid of symbolic link embellish output
124 awk ' { print $1 } ' ${vdir}.changes.2 > ${vdir}.changes
125 rm -f ${vdir}.changes.*
127 # step 3: create the ${vdir} with just the list given in ${vdir}.changes
128 install -d -m 755 ${vdir}-tmp/
130 (cd ${vdir} && cpio -m -d -u -p ${vdir}-tmp < ${vdir}.changes)
132 rm -f ${vdir}.changes
133 mv ${vdir}-tmp ${vdir}
135 echo "--------STARTING tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)"
136 tar -cpjf ${pldistro}-filesystems/PlanetLab-Bootstrap-${NAME}.tar.bz2 -C ${vdir} .
137 echo "--------FINISHED tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)"
138 echo "--------DONE BUILDING PlanetLab-Bootstrap-${NAME}: $(date)"
141 # Build the base Bootstrap filesystem
142 # clean out yum cache to reduce space requirements
143 yum -c ${vref}/etc/yum.conf --installroot=${vdir} -y clean all
144 echo "--------STARTING tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)"
145 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C ${vref} .
146 echo "--------FINISHED tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)"