From: Marc Fiuczynski Date: Thu, 30 Aug 2007 16:39:09 +0000 (+0000) Subject: modified to use common functions from build/build.common X-Git-Url: http://git.onelab.eu/?p=myplc.git;a=commitdiff_plain;h=8405c6fedf8018ff2d2b172fd82dfd1c0033bc53 modified to use common functions from build/build.common --- diff --git a/build.functions b/build.functions index e0c7ff1..81f8889 100644 --- a/build.functions +++ b/build.functions @@ -6,7 +6,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: build.functions,v 1.9 2007/08/28 21:52:14 mef Exp $ +# $Id: build.functions,v 1.10 2007/08/29 03:13:07 mef Exp $ # PATH=/sbin:/bin:/usr/sbin:/usr/bin @@ -24,49 +24,22 @@ fi export PATH -# Release and architecture to install -PLC_DEVEL_FEDORA_RELEASE=$([ -f "/etc/fedora-release" ] && awk ' { if ($2=="Core") print $4; else print $3 } ' /etc/fedora-release || echo 4) -[ $PLC_DEVEL_FEDORA_RELEASE -lt 4 ] && PLC_DEVEL_FEDORA_RELEASE=4 -PLC_DEVEL_FEDORA_ARCH=$(uname -i) -# Fedora Core mirror from which to install filesystems -# xxx don't set URL... mkfedora will pick up the right thing -#PLC_DEVEL_FEDORA_URL=file:///data/fedora -PLC_DEVEL_FEDORA_URL= +. build.common +pl_process_fedora_options $@ +shiftcount=$? +shift $shiftcount + +# XXX Backwards compatibility with old myplc-devel environment # We may be running inside a myplc-devel environment, which can # override these defaults. if [ -f /etc/planetlab/plc_config ] ; then . /etc/planetlab/plc_config + [ ! -z "$PLC_DEVEL_FEDORA_RELEASE" ] && pl_FEDORA_RELEASE=$PLC_DEVEL_FEDORA_RELEASE + [ ! -z "$PLC_DEVEL_FEDORA_ARCH" ] && pl_FEDORA_ARCH=$PLC_DEVEL_FEDORA_ARCH + [ ! -z "$PLC_DEVEL_FEDORA_URL" ] && pl_FEDORA_URL=$PLC_DEVEL_FEDORA_URL fi -usage() -{ - echo "Usage: $0 [OPTION]..." - echo " -l url Fedora mirror location (default: $PLC_DEVEL_FEDORA_URL)" - echo " -r release Fedora release number (default: $PLC_DEVEL_FEDORA_RELEASE)" - echo " -a arch Fedora architecture (default: $PLC_DEVEL_FEDORA_ARCH)" - echo " -h This message" - exit 1 -} - -# Get options -while getopts "l:r:a:h" opt ; do - case $opt in - l) - PLC_DEVEL_FEDORA_URL=$OPTARG - ;; - r) - PLC_DEVEL_FEDORA_RELEASE=$OPTARG - ;; - a) - PLC_DEVEL_FEDORA_ARCH=$OPTARG - ;; - h|*) - usage - ;; - esac -done - # Do not tolerate errors set -e @@ -91,20 +64,7 @@ make_chroot() { packages="$packages -p \"$package\"" done < <(./plc-config --packages $config) - # Install base system - if [ ! -z "$PLC_DEVEL_FEDORA_URL" ] ; then - eval mkfedora -v -l $PLC_DEVEL_FEDORA_URL -r $PLC_DEVEL_FEDORA_RELEASE -a $PLC_DEVEL_FEDORA_ARCH $packages $groups $root - else - eval mkfedora -v -r $PLC_DEVEL_FEDORA_RELEASE -a $PLC_DEVEL_FEDORA_ARCH $packages $groups $root - fi - - # Disable all services in reference image - chroot $root sh -c "/sbin/chkconfig --list | awk '{ print \$1 }' | xargs -i /sbin/chkconfig {} off" - - # FC2 minilogd starts up during shutdown and makes unmounting - # impossible. Just get rid of it. - rm -f $root/sbin/minilogd - ln -nsf /bin/true $root/sbin/minilogd + pl_setup_chroot $root $packages $groups } # Move specified directories out of the chroot and into a "data" @@ -113,41 +73,12 @@ move_datadirs() { root=$1 data=$2 shift 2 - - mkdir -p $root/data - for datadir in "$@" ; do - mkdir -p ${data}$datadir - if [ -d $root/$datadir -a ! -h $root/$datadir ] ; then - (cd $root && find ./$datadir | cpio -p -d -u ../$data/) - fi - rm -rf $root/$datadir - mkdir -p $(dirname $root/$datadir) - ln -nsf /data$datadir $root/$datadir - done + pl_move_dirs $root $data /data "$@" } # Make loopback filesystem from specified location make_image() { root=$1 image=$2 - - # Leave about 100 MB free space and allow for about 20% inode overhead - bytes=$((($(du -sb $root | cut -f1) + 100000000) * 120 / 100)) - bs=4096 - blocks=$(($bytes / $bs)) - dd bs=$bs count=$blocks if=/dev/zero of=$image - mkfs.ext3 -b $bs -j -F $image - - # Temporarily mount it - tmp=$(mktemp -d tmp.XXXXXX) - mount -o loop $image $tmp - trap "umount $tmp; rmdir $tmp" ERR INT - - # Move files to it - (cd $root && tar cpf - .) | (cd $tmp && tar xpf -) - - # Unmount it - umount $tmp - rmdir $tmp - trap - ERR INT + pl_make_image $root $image 100000000 } diff --git a/build.sh b/build.sh index d5d2a57..bbd08c3 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ # Builds MyPLC, either inside the MyPLC development environment in # devel/root (if PLC_DEVEL_BOOTSTRAP is true), or in the current host # environment (may be itself a MyPLC development environment or a -# Fedora Core 4 environment with the appropriate development packages +# Fedora environment with the appropriate development packages # installed). # # root.img (loopback image) @@ -13,9 +13,10 @@ # data/root (root's homedir) # # Mark Huang -# Copyright (C) 2006 The Trustees of Princeton University +# Marc E. Fiuczynski +# Copyright (C) 2006-2007 The Trustees of Princeton University # -# $Id: build.sh,v 1.40 2007/01/30 16:03:20 mlhuang Exp $ +# $Id: build.sh,v 1.41 2007/08/22 02:04:56 faiyaza Exp $ # . build.functions @@ -40,13 +41,8 @@ datadirs=( /var/tmp /var/log ) -for datadir in "${datadirs[@]}" ; do - # If we are being re-run, it may be a symlink - if [ -h root/$datadir ] ; then - rm -f root/$datadir - mkdir -p root/$datadir - fi -done + +pl_fixdirs root "${datadirs[@]}" echo "* myplc: Installing base filesystem" mkdir -p root data @@ -100,10 +96,10 @@ chmod 644 $roothome/.profile # Move "data" directories out of the installation echo "* myplc: Moving data directories out of the installation" -move_datadirs root data "${datadirs[@]}" +pl_move_dirs root data /data "${datadirs[@]}" # Fix permissions on tmp directories -chmod 1777 data/tmp data/usr/tmp data/var/tmp +pl_fixtmp_permissions data # Remove generated bootmanager script rm -f data/var/www/html/boot/bootmanager.sh @@ -111,11 +107,11 @@ rm -f data/var/www/html/boot/bootmanager.sh # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2 # tarball already contains all of the node RPMs pre-installed. Only # updates or optional packages should be placed in this directory. -install -D -m 644 ../build/groups/v4_yumgroups.xml \ +install -D -m 644 $pl_YUMGROUPSXML \ data/var/www/html/install-rpms/planetlab/yumgroups.xml # Make image out of directory echo "* myplc: Building loopback image" -make_image root root.img +pl_make_image root root.img 100000000 exit 0 diff --git a/build_devel.sh b/build_devel.sh index 077dbdb..6c0aefc 100755 --- a/build_devel.sh +++ b/build_devel.sh @@ -13,9 +13,10 @@ # devel/data/root (root's home dir) # # Mark Huang -# Copyright (C) 2006 The Trustees of Princeton University +# Marc E. Fiuczynski +# Copyright (C) 2006-2007 The Trustees of Princeton University # -# $Id: build_devel.sh,v 1.8 2007/01/20 04:02:43 mlhuang Exp $ +# $Id: build_devel.sh,v 1.9 2007/08/13 18:59:04 dhozac Exp $ # . build.functions @@ -31,13 +32,9 @@ datadirs=( /var/tmp /var/log ) -for datadir in "${datadirs[@]}" ; do - # If we are being re-run, it may be a symlink - if [ -h devel/root/$datadir ] ; then - rm -f devel/root/$datadir - mkdir -p devel/root/$datadir - fi -done + +pl_fixdirs devel/root "${datadirs[@]}" + echo "* myplc-devel: Installing base filesystem" mkdir -p devel/root @@ -85,13 +82,13 @@ EOF # Move "data" directories out of the installation echo "* myplc-devel: Moving data directories out of the installation" -move_datadirs devel/root devel/data "${datadirs[@]}" +pl_move_dirs devel/root devel/data /data "${datadirs[@]}" # Fix permissions on tmp directories -chmod 1777 devel/data/tmp devel/data/usr/tmp devel/data/var/tmp +pl_fixtmp_permissions data # Make image out of directory echo "* myplc-devel: Building loopback image" -make_image devel/root devel/root.img +pl_make_mig devel/root devel/root.img 100000000 exit 0