mirror of
https://github.com/macports/mpbb.git
synced 2026-03-31 14:38:29 -07:00
git-svn-id: https://svn.macports.org/repository/macports/contrib/mpab@79836 d073be05-634f-4543-b044-5fe20cf6d1d6
169 lines
5.3 KiB
Bash
Executable File
169 lines
5.3 KiB
Bash
Executable File
#!/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
|
|
|
|
if [[ -z "$PREFIX" ]]; then
|
|
PREFIX=/opt/local
|
|
fi
|
|
export PREFIX
|
|
# location to store base and dports sources
|
|
if [[ -z "$SRC_PREFIX" ]]; then
|
|
SRC_PREFIX=/opt/mports
|
|
fi
|
|
export SRC_PREFIX
|
|
|
|
# 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
|
|
|
|
# option parsing
|
|
OSMajor=`uname -r | sed 's/\..*//'`
|
|
# xcodebuild breaks in chroots on 10.6
|
|
if [[ $1 = "-n" || $OSMajor -ge 10 ]]; then
|
|
chrootPath=""
|
|
echo "Warning: not using chroot"
|
|
if [[ $1 = "-n" ]]; then
|
|
shift
|
|
fi
|
|
fi
|
|
|
|
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
|
|
if [[ -n "$chrootPath" ]]; then
|
|
buildImages ${dataDir} ${chrootPath} ${IMGBASENAME}
|
|
mountChroot ${dataDir} ${chrootPath} ${IMGBASENAME}
|
|
fi
|
|
if [[ ( $? == 0 || -n "$chrootPath" ) &&
|
|
( ${command} == "buildmp" || ${command} == "rebuildmp" ||
|
|
${command} == "buildports" ) ]]; then
|
|
trap "exitFunction ${dataDir} ${chrootPath}" EXIT
|
|
exitMessage="Stopping..."
|
|
if [[ ${command} == "rebuildmp" ]]; then
|
|
rm -rf ${chrootPath}${SRC_PREFIX}
|
|
if [[ -n "$chrootPath" ]]; then
|
|
rm -f ${chrootPath}${PREFIX}/bin/port
|
|
fi
|
|
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:
|