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 # Do not tolerate errors
37 # Some of the PlanetLab RPMs attempt to (re)start themselves in %post,
38 # unless the installation is running inside the BootCD environment. We
39 # would like to pretend that we are.
42 # "Parse" out the packages and groups into the options passed to mkfedora
43 # -k = exclude kernel* packages
45 packages=$(pk_getPackages base.lst)
46 groups=$(pk_getGroups base.lst)
47 for package in ${packages} ; do options="$options -p $package"; done
48 for group in ${groups} ; do options="$options -g $group"; done
50 # Populate a minimal /dev and then the files for the base PlanetLab-Bootstrap content
52 install -d -m 755 ${vref}
54 pl_setup_chroot ${vref} -k ${options}
56 for bootstrapfs in bootstrap-filesystems/*.lst ; do
57 NAME=$(basename $bootstrapfs .lst)
59 echo "--------START BUILDING PlanetLab-Bootstrap-${NAME}: $(date)"
61 # "Parse" out the packages and groups for yum
62 packages=$(grep "^package:.*" $bootstrapfs | awk '{print $2}')
63 groups=$(grep "^group:.*" $bootstrapfs | awk '{print $2}')
65 vdir=${PWD}/bootstrap-filesystems/${NAME}
67 install -d -m 755 ${vdir}
69 # Clone the base reference to the bootstrap fs
70 (cd ${vref} && find . | cpio -m -d -u -p ${vdir})
71 rm -f ${vdir}/var/lib/rpm/__db*
73 # Install the system vserver specific packages
74 [ -n "$systempackages" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y install $systempackages
75 [ -n "$systemgroups" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y groupinstall $systemgroups
77 # Create a copy of the system vserver w/o the vserver reference files and make it smaller.
78 # This is a three step process:
80 # step 1: clean out yum cache to reduce space requirements
81 yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y clean all
83 # step 2: figure out the new/changed files in ${vdir} vs. ${vref} and compute ${vdir}.changes
84 rsync -anv ${vdir}/ ${vref}/ > ${vdir}.changes
85 linecount=$(wc -l ${vdir}.changes | awk ' { print $1 } ')
86 let headcount=$linecount-3
87 let tailcount=$headcount-1
88 # get rid of the last 3 lines of the rsync output
89 head -${headcount} ${vdir}.changes > ${vdir}.changes.1
90 # get rid of the first line of the rsync output
91 tail -${tailcount} ${vdir}.changes.1 > ${vdir}.changes.2
92 # post process rsync output to get rid of symbolic link embellish output
93 awk ' { print $1 } ' ${vdir}.changes.2 > ${vdir}.changes
94 rm -f ${vdir}.changes.*
96 # step 3: create the ${vdir} with just the list given in ${vdir}.changes
97 install -d -m 755 ${vdir}-tmp/
99 (cd ${vdir} && cpio -m -d -u -p ${vdir}-tmp < ${vdir}.changes)
101 rm -f ${vdir}.changes
102 mv ${vdir}-tmp ${vdir}
104 echo "--------STARTING tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)"
105 tar -cpjf bootstrap-filesystems/PlanetLab-Bootstrap-${NAME}.tar.bz2 -C ${vdir} .
106 echo "--------FINISHED tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)"
107 echo "--------DONE BUILDING PlanetLab-Bootstrap-${NAME}: $(date)"
110 # Build the base Bootstrap filesystem
111 echo "--------STARTING tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)"
112 # clean out yum cache to reduce space requirements
113 yum -c ${vref}/etc/yum.conf --installroot=${vdir} -y clean all
114 tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C ${vref} .
115 echo "--------FINISHED tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)"