From c5588c0570a80bcc238e6a98f765a4e32c363a36 Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Tue, 6 Nov 2007 20:49:33 +0000 Subject: [PATCH] Support to build bootstrap filesystems (i.e. PlanetLab-Bootstrap*.tar.bz2) --- base.lst | 3 + bootstrap-filesystems/production.lst | 13 +++ bootstrapfs.spec | 71 +++++++++++++++++ build.sh | 115 +++++++++++++++++++++++++++ 4 files changed, 202 insertions(+) create mode 100644 base.lst create mode 100644 bootstrap-filesystems/production.lst create mode 100644 bootstrapfs.spec create mode 100755 build.sh diff --git a/base.lst b/base.lst new file mode 100644 index 0000000..7c9d9d0 --- /dev/null +++ b/base.lst @@ -0,0 +1,3 @@ +package: filesystem +package: udev +package: coreutils diff --git a/bootstrap-filesystems/production.lst b/bootstrap-filesystems/production.lst new file mode 100644 index 0000000..114d87b --- /dev/null +++ b/bootstrap-filesystems/production.lst @@ -0,0 +1,13 @@ +# Install the "PlanetLab" group. This requires that the PlanetLab +# build system install the appropriate yumgroups.xml file (currently +# build/groups/v4_yumgroups.xml) in $RPM_BUILD_DIR/../RPMS/ and that +# mkfedora runs either yum-arch or createrepo on that directory. dev +# is specified explicitly because of a stupid bug in its %post script +# that causes its installation to fail; see the mkfedora script for a +# full explanation. coreutils and python are specified explicitly +# because groupinstall does not honor Requires(pre) dependencies +# properly, most %pre scripts require coreutils to be installed first, +# and some of our %post scripts require python. + +package: python +group: PlanetLab \ No newline at end of file diff --git a/bootstrapfs.spec b/bootstrapfs.spec new file mode 100644 index 0000000..abd37f4 --- /dev/null +++ b/bootstrapfs.spec @@ -0,0 +1,71 @@ +%define name bootstrapfs +%define version 0.1 +%define release 0%{?pldistro:.%{pldistro}}%{?date:.%{date}} + +Vendor: PlanetLab +Packager: PlanetLab Central +Distribution: PlanetLab 4.2 +URL: http://svn.planet-lab.org/svn/BootStrapFS/ + +Summary: The PlanetLab Bootstrap Filesystems +Name: %{name} +Version: %{version} +Release: %{release} +License: BSD +Group: System Environment/Base +Source0: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root + +Requires: tar, gnupg, sharutils, bzip2 + +AutoReqProv: no +%define debug_package %{nil} + +%description + +The PlanetLab Bootstrap Filesystem(s) are downloaded by the +BootManager to instantiate a node with a new filesystem. + +%prep +%setup -q + +%build +./build.sh + +%install +rm -rf $RPM_BUILD_ROOT + +install -D -m 644 PlanetLab-Bootstrap.tar.bz2 \ + $RPM_BUILD_ROOT/var/www/html/boot/PlanetLab-Bootstrap.tar.bz2 + +for bootstrapfs in $(ls bootstrap-filesystems/*.lst) ; do + NAME=$(basename $bootstrapfs .lst) + install -D -m 644 bootstrap-filesystems/PlanetLab-Bootstrap-${NAME}.tar.bz2 \ + $RPM_BUILD_ROOT/var/www/html/boot/PlanetLab-Bootstrap-${NAME}.tar.bz2 +done + +%clean +rm -rf $RPM_BUILD_ROOT + +# If run under sudo +if [ -n "$SUDO_USER" ] ; then + # Allow user to delete the build directory + chown -h -R $SUDO_USER . + # Some temporary cdroot files like /var/empty/sshd and + # /usr/bin/sudo get created with non-readable permissions. + find . -not -perm +0600 -exec chmod u+rw {} \; + # Allow user to delete the built RPM(s) + chown -h -R $SUDO_USER %{_rpmdir}/%{_arch} +fi + +%post + + +%files +%defattr(-,root,root,-) +%{_datadir}/%{name} +/var/www/html/boot/PlanetLab-Bootstrap*.tar.bz2 + +%changelog +* Fri Sep 2 2005 Mark Huang - +- Initial build. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..8165fa5 --- /dev/null +++ b/build.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# +# Build PlanetLab-Bootstrap.tar.bz2, the reference image for PlanetLab +# nodes. +# +# Mark Huang +# Marc E. Fiuczynski +# Copyright (C) 2005-2007 The Trustees of Princeton University +# +# $Id: buildnode.sh,v 1.12.6.1 2007/08/30 20:09:20 mef Exp $ +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# In both a normal CVS environment and a PlanetLab RPM +# build environment, all of our dependencies are checked out into +# directories at the same level as us. +if [ -d ../build ] ; then + PATH=$PATH:../build + srcdir=../ +else + echo "Error: Could not find $(cd ../.. && pwd -P)/build/" + exit 1 +fi + +export PATH + +. build.common + +pl_process_fedora_options $@ +shiftcount=$? +shift $shiftcount + +# Do not tolerate errors +set -e + +# Some of the PlanetLab RPMs attempt to (re)start themselves in %post, +# unless the installation is running inside the BootCD environment. We +# would like to pretend that we are. +export PL_BOOTCD=1 + +# "Parse" out the packages and groups into the options passed to mkfedora +# -k = exclude kernel* packages +options="-k" +packages=$(grep "^package:.*" base.lst | awk '{print $2}') +groups=$(grep "^group:.*" base.lst | awk '{print $2}') +for package in ${packages} ; do options="$options -p $package"; done +for group in ${groups} ; do options="$options -g $group"; done + +# Populate a minimal /dev and then the files for the base PlanetLab-Bootstrap content +vref=${PWD}/base +install -d -m 755 ${vref} +pl_makedevs ${vref} +pl_setup_chroot ${vref} -k ${options} + +# Build the base Bootstrap filesystem +echo "--------STARTING tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)" +tar -cpjf PlanetLab-Bootstrap.tar.bz2 -C ${vref} . +echo "--------FINISHED tar'ing PlanetLab-Bootstrap.tar.bz2: $(date)" + +for bootstrapfs in bootstrap-filesystems/*.lst ; do + NAME=$(basename $bootstrapfs .lst) + + echo "--------START BUILDING PlanetLab-Bootstrap-${NAME}: $(date)" + + # "Parse" out the packages and groups for yum + packages=$(grep "^package:.*" $bootstrapfs | awk '{print $2}') + groups=$(grep "^group:.*" $bootstrapfs | awk '{print $2}') + + vdir=${PWD}/bootstrap-filesystems/${NAME} + rm -rf ${vdir}/* + install -d -m 755 ${vdir} + + # Clone the base reference to the bootstrap fs + (cd ${vref} && find . | cpio -m -d -u -p ${vdir}) + rm -f ${vdir}/var/lib/rpm/__db* + + # Install the system vserver specific packages + [ -n "$systempackages" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y install $systempackages + [ -n "$systemgroups" ] && yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y groupinstall $systemgroups + + # Create a copy of the system vserver w/o the vserver reference files and make it smaller. + # This is a three step process: + + # step 1: clean out yum cache to reduce space requirements + yum -c ${vdir}/etc/yum.conf --installroot=${vdir} -y clean all + + # step 2: figure out the new/changed files in ${vdir} vs. ${vref} and compute ${vdir}.changes + rsync -anv ${vdir}/ ${vref}/ > ${vdir}.changes + linecount=$(wc -l ${vdir}.changes | awk ' { print $1 } ') + let headcount=$linecount-3 + let tailcount=$headcount-1 + # get rid of the last 3 lines of the rsync output + head -${headcount} ${vdir}.changes > ${vdir}.changes.1 + # get rid of the first line of the rsync output + tail -${tailcount} ${vdir}.changes.1 > ${vdir}.changes.2 + # post process rsync output to get rid of symbolic link embellish output + awk ' { print $1 } ' ${vdir}.changes.2 > ${vdir}.changes + rm -f ${vdir}.changes.* + + # step 3: create the ${vdir} with just the list given in ${vdir}.changes + install -d -m 755 ${vdir}-tmp/ + rm -rf ${vdir}-tmp/* + (cd ${vdir} && cpio -m -d -u -p ${vdir}-tmp < ${vdir}.changes) + rm -rf ${vdir} + rm -f ${vdir}.changes + mv ${vdir}-tmp ${vdir} + + echo "--------STARTING tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)" + tar -cpjf bootstrap-filesystems/PlanetLab-Bootstrap-${NAME}.tar.bz2 -C ${vdir} . + echo "--------FINISHED tar'ing PlanetLab-Bootstrap-${NAME}.tar.bz2: $(date)" + echo "--------DONE BUILDING PlanetLab-Bootstrap-${NAME}: $(date)" +done + +exit 0 -- 2.43.0