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 $
13 PATH=/sbin:/bin:/usr/sbin:/usr/bin
15 # In both a normal CVS environment and a PlanetLab RPM
16 # build environment, all of our dependencies are checked out into
17 # directories at the same level as us.
18 if [ -d ../build ] ; then
22 echo "Error: Could not find $(cd ../.. && pwd -P)/build/"
30 pl_process_fedora_options $@
34 # pldistro expected as $1 - defaults to planetlab
36 [ -n "$@" ] && pldistro=$1
38 # Do not tolerate errors
41 # Some of the PlanetLab RPMs attempt to (re)start themselves in %post,
42 # unless the installation is running inside the BootCD environment. We
43 # would like to pretend that we are.
46 # "Parse" out the packages and groups into the options passed to mkfedora
47 # -k = exclude kernel* packages
49 lst="${pldistro}-base.lst"
50 popts=$(pl_getPackagesOptions2 ${pl_DISTRO_NAME} $lst)
51 gopts=$(pl_getGroupsOptions2 ${pl_DISTRO_NAME} $lst)
53 options="${popts} ${gopts}"
55 echo "+++++++++++++OPTIONS = ${options}"
57 # Populate a minimal /dev and then the files for the base PlanetLab-Bootstrap content
59 install -d -m 755 ${vref}
60 pl_mkfedora ${vref} ${options}
62 for lst in ${pldistro}-filesystems/*.lst ; do
63 NAME=$(basename $lst .lst)
65 echo "--------START BUILDING PlanetLab-Bootstrap-${NAME}: $(date)"
67 # "Parse" out the packages and groups for yum
68 packages=$(pl_getPackages $lst)
69 groups=$(pl_getGroups $lst)
70 echo "${NAME} has the following packages and groups: ${packages} ${groups}"
72 vdir=${PWD}/${pldistro}-filesystems/${NAME}
74 install -d -m 755 ${vdir}
76 # Clone the base reference to the bootstrap fs
77 (cd ${vref} && find . | cpio -m -d -u -p ${vdir})
78 rm -f ${vdir}/var/lib/rpm/__db*
80 # Install the system vserver specific packages
81 [ -n "$packages" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y install $packages
82 [ -n "$groups" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y groupinstall $groups
84 if [ -f "${vdir}/proc/cpuinfo" ] ; then
85 echo "WARNING: some RPM appears to have mounted /proc in ${NAME}. Unmounting it!"
89 # Create a copy of the ${NAME} bootstrap filesystem w/o the base
90 # bootstrap filesystem and make it smaller. This is a three step
93 # step 1: clean out yum cache to reduce space requirements
94 yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y clean all
96 # step 2: figure out the new/changed files in ${vdir} vs. ${vref} and compute ${vdir}.changes
97 rsync -anv ${vdir}/ ${vref}/ > ${vdir}.changes
98 linecount=$(wc -l ${vdir}.changes | awk ' { print $1 } ')
99 let headcount=$linecount-3
100 let tailcount=$headcount-1
101 # get rid of the last 3 lines of the rsync output
102 head -${headcount} ${vdir}.changes > ${vdir}.changes.1
103 # get rid of the first line of the rsync output
104 tail -${tailcount} ${vdir}.changes.1 > ${vdir}.changes.2
105 # post process rsync output to get rid of symbolic link embellish output
106 awk ' { print $1 } ' ${vdir}.changes.2 > ${vdir}.changes
107 rm -f ${vdir}.changes.*
109 # step 3: create the ${vdir} with just the list given in ${vdir}.changes
110 install -d -m 755 ${vdir}-tmp/
112 (cd ${vdir} && cpio -m -d -u -p ${vdir}-tmp < ${vdir}.changes)
114 rm -f ${vdir}.changes
115 mv ${vdir}-tmp ${vdir}
117 echo "--------STARTING tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)"
118 tar -cpjf ${pldistro}-filesystems/PlanetLab-Bootstrap-${NAME}.tar.bz2 -C ${vdir} .
119 echo "--------FINISHED tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)"
120 echo "--------DONE BUILDING PlanetLab-Bootstrap-${NAME}: $(date)"
123 # Build the base Bootstrap filesystem
124 # clean out yum cache to reduce space requirements
125 yum -c ${vref}/etc/yum.conf --installroot=${vdir} -y clean all
126 echo "--------STARTING tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)"
127 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C ${vref} .
128 echo "--------FINISHED tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)"