#!/bin/sh # # Copyright (c) 2006,2008 Bryan L Blackburn. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name Bryan L Blackburn, nor the names of any contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' # AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # export PATH=/bin:/usr/bin:/sbin:/usr/sbin # Base filename for the disk image IMGBASENAME="mproot" # subdir start of the chroot CHROOTSUBDIR="mpchroot" # Name of the file containing all of MacPorts MPTARBALL="macports_dist.tar.bz2" # Alternatively, the SVN checkout dir of MacPorts MP_SVN_WORKDIR="mpexport" baseDir=$(dirname $0) dataDir=$(pwd) if [[ $MPAB_DATA ]]; then dataDir=$MPAB_DATA fi chrootPath="${dataDir}/${CHROOTSUBDIR}" if [[ -n ${MPABDEBUG} ]]; then HDIUTILDEBUG="-verbose" else HDIUTILDEBUG="-quiet" fi export HDIUTILDEBUG . ${baseDir}/mpab-functions command="buildports" portlistFile="" if [[ -n $1 ]]; then command=$1 && shift if [[ ${command} != "help" && ${command} != "mount" && ${command} != "umount" && ${command} != "buildmp" && ${command} != "rebuildmp" && ${command} != "buildports" && ${command} != "shell" ]]; then printUsageAndExit fi if [[ ${command} == "buildmp" || ${command} == "rebuildmp" ]]; then installPackage=$1 && shift fi if [[ ${command} == "buildports" && -n $1 ]]; then portlistFile=$1 && shift if [[ ! -e ${portlistFile} ]]; then echo "File '${portlistFile}' not found" && echo printUsageAndExit fi fi if [[ ${command} == "help" || -n $1 ]]; then printUsageAndExit fi fi if [[ ${command} == "umount" ]]; then umountChroot ${chrootPath} exit 0 fi if [[ ${command} == "shell" ]]; then chrootShell exit 0 fi checkDependencies ${dataDir} ${MPTARBALL} ${MP_SVN_WORKDIR} ${installPackage} returnValue=$? if [[ ${returnValue} != 0 ]]; then exit ${returnValue} fi if [[ ${command} == "mount" || ${command} == "buildmp" || ${command} == "rebuildmp" || ${command} == "buildports" ]]; then buildImages ${dataDir} ${chrootPath} ${IMGBASENAME} mountChroot ${dataDir} ${chrootPath} ${IMGBASENAME} if [[ $? == 0 && ( ${command} == "buildmp" || ${command} == "rebuildmp" || ${command} == "buildports" ) ]]; then trap "exitFunction ${dataDir} ${chrootPath}" EXIT exitMessage="Stopping..." if [[ ${command} == "rebuildmp" ]]; then rm -rf ${chrootPath}/opt/mports rm -f ${chrootPath}/opt/local/bin/port fi if [[ -n ${installPackage} ]]; then buildMacPorts ${baseDir} ${dataDir} ${chrootPath} ${installPackage} || ( echo "Failed to build MacPorts from release archive" && exit 1 ) elif [[ -d ${MP_SVN_WORKDIR} ]]; then buildMacPorts ${baseDir} ${dataDir} ${chrootPath} ${MP_SVN_WORKDIR} || ( echo "Failed to build MacPorts from SVN checkout directory (MP_SVN_WORKDIR)" && exit 1 ) else buildMacPorts ${baseDir} ${dataDir} ${chrootPath} ${MPTARBALL} || ( echo "Failed to build MacPorts from ${mpExport}" && exit 1 ) fi exitMessage="" if [[ $? == 0 && ${command} == "buildports" ]]; then if [[ -e ${portlistFile} ]]; then cp -p ${portlistFile} ${chrootPath}/private/var/tmp/portlist fi exitMessage="Stopping..." buildPorts ${baseDir} ${chrootPath} exitMessage="" fi fi fi # Local Variables: # mode: shell-script # indent-tabs-mode: nil # sh-basic-offset: 3 # End: