mpab: make macports prefix and location to keep sources configurable

git-svn-id: https://svn.macports.org/repository/macports/contrib/mpab@79836 d073be05-634f-4543-b044-5fe20cf6d1d6
This commit is contained in:
Joshua Root
2011-06-27 22:22:56 +00:00
parent 4ef18cdc7c
commit a2d8aa2103
7 changed files with 60 additions and 29 deletions
+3 -1
View File
@@ -30,7 +30,9 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
PREFIX="/opt/local"
if [[ -z "$PREFIX" ]]; then
PREFIX=/opt/local
fi
ARCHIVE_TYPE=".tbz2"
function uninstallPorts()
+6 -3
View File
@@ -31,10 +31,13 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
set prefix /opt/local
if {[info exists env(PREFIX)]} {
set prefix $env(PREFIX)
} else {
set prefix /opt/local
}
catch {source \
[file join ${prefix} share macports Tcl macports1.0 macports_fastload.tcl]}
source ${prefix}/share/macports/Tcl/macports1.0/macports_fastload.tcl
package require macports
+10 -4
View File
@@ -3,9 +3,15 @@
# configure/build/install MacPorts in the chroot
#
cd /opt/mports/base
./configure && make all && make install && make distclean
if [[ $? == 0 ]]; then
echo "file:///opt/mports/dports [default]" > /opt/local/etc/macports/sources.conf
if [[ -z "$PREFIX" ]]; then
PREFIX=/opt/local
fi
if [[ -z "$SRC_PREFIX" ]]; then
SRC_PREFIX=/opt/mports
fi
cd ${SRC_PREFIX}/base
./configure --prefix=${PREFIX} && make -j2 all && make install && make distclean
if [[ $? == 0 ]]; then
echo "file://${SRC_PREFIX}/dports [default]" > ${PREFIX}/etc/macports/sources.conf
fi
+9 -2
View File
@@ -3,5 +3,12 @@
# re-create the portindex
#
cd /opt/mports/dports
/opt/local/bin/portindex > /dev/null
if [[ -z "$PREFIX" ]]; then
PREFIX=/opt/local
fi
if [[ -z "$SRC_PREFIX" ]]; then
SRC_PREFIX=/opt/mports
fi
cd ${SRC_PREFIX}/dports
${PREFIX}/bin/portindex > /dev/null
+12 -2
View File
@@ -30,6 +30,16 @@
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"
@@ -122,9 +132,9 @@ if [[ ${command} == "mount" || ${command} == "buildmp" ||
trap "exitFunction ${dataDir} ${chrootPath}" EXIT
exitMessage="Stopping..."
if [[ ${command} == "rebuildmp" ]]; then
rm -rf ${chrootPath}/opt/mports
rm -rf ${chrootPath}${SRC_PREFIX}
if [[ -n "$chrootPath" ]]; then
rm -f ${chrootPath}/opt/local/bin/port
rm -f ${chrootPath}${PREFIX}/bin/port
fi
fi
+14 -14
View File
@@ -215,25 +215,25 @@ function buildMacPorts()
local chrootPath=$3
local mpExport=$4
if [[ ! -d ${chrootPath}/opt/mports ]]; then
if [[ ! -d ${chrootPath}${SRC_PREFIX} ]]; then
if [[ -f ${dataDir}/${mpExport} ]]; then
mkdir -p ${chrootPath}/opt/mports
mkdir -p ${chrootPath}${SRC_PREFIX}
echo ${mpExport} | grep -q "MacPorts-......tar.gz"
if [[ $? == 0 ]]; then
cp ${mpExport} ${chrootPath}/opt/mports
cd ${chrootPath}/opt/mports
cp ${mpExport} ${chrootPath}${SRC_PREFIX}
cd ${chrootPath}${SRC_PREFIX}
tar xzf ${mpExport} || return 1
rm -rf base 2>/dev/null
mv $(ls -d MacPorts-?.?.?) base || return 1
else
cd ${chrootPath}/opt/mports
cd ${chrootPath}${SRC_PREFIX}
bunzip2 -c ${dataDir}/${mpExport} | tar xf -
fi
cd - > /dev/null
elif [[ -d ${dataDir}/${mpExport} ]]; then
mkdir -p ${chrootPath}/opt/mports
mkdir -p ${chrootPath}${SRC_PREFIX}
cd ${dataDir}/${mpExport} && \
rsync -r --del --exclude '*~' --exclude '.svn' . ${chrootPath}/opt/mports
rsync -r --del --exclude '*~' --exclude '.svn' . ${chrootPath}${SRC_PREFIX}
cd - > /dev/null
else
echo "No ${mpExport} found"
@@ -241,7 +241,7 @@ function buildMacPorts()
fi
fi
if [[ ! -f ${chrootPath}/opt/local/bin/port ]]; then
if [[ ! -f ${chrootPath}${PREFIX}/bin/port ]]; then
chrootExec installmacports
fi
@@ -344,8 +344,8 @@ function mountChroot()
mount_devfs devfs ${chrootPath}/dev
mount_fdesc -o union fdesc ${chrootPath}/dev
mkdir -p ${chrootPath}/opt/local/var/macports/distfiles
hdiutil attach ${baseDir}/${imgBaseName}_distcache.sparseimage -mountpoint ${chrootPath}/opt/local/var/macports/distfiles -noverify -owners on -nobrowse -noautofsck ${HDIUTILDEBUG}
mkdir -p ${chrootPath}${PREFIX}/var/macports/distfiles
hdiutil attach ${baseDir}/${imgBaseName}_distcache.sparseimage -mountpoint ${chrootPath}${PREFIX}/var/macports/distfiles -noverify -owners on -nobrowse -noautofsck ${HDIUTILDEBUG}
returnValue=$?
if [[ ${returnValue} != 0 ]]; then
echo "Failed to attach distfiles image"
@@ -374,9 +374,9 @@ function umountChroot()
# And again for the devfs
umount -f ${chrootPath}/dev
fi
if [[ -d ${chrootPath}/opt/local/var/macports/distfiles ]]; then
if [[ -d ${chrootPath}${PREFIX}/var/macports/distfiles ]]; then
# Now the cache image for the dist files
hdiutil detach ${chrootPath}/opt/local/var/macports/distfiles ${HDIUTILDEBUG}
hdiutil detach ${chrootPath}${PREFIX}/var/macports/distfiles ${HDIUTILDEBUG}
fi
if [[ -d ${chrootPath} ]]; then
# Finally, the main image itself
@@ -398,9 +398,9 @@ function chrootExec () {
# Set DYLD_NO_FIX_PREBINDING as otherwise, on 10.5, dyld will spew
# errors to syslog/console log like:
# com.apple.launchd[1] (com.apple.dyld): Throttling respawn: Will start in 10 seconds
env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/var/root DYLD_NO_FIX_PREBINDING=1 /usr/sbin/chroot ${chrootPath} /bin/sh /var/tmp/$1
env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/var/root DYLD_NO_FIX_PREBINDING=1 PREFIX=${PREFIX} SRC_PREFIX=${SRC_PREFIX} /usr/sbin/chroot ${chrootPath} /bin/sh /var/tmp/$1
else
env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/var/root /bin/sh /var/tmp/$1
env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/var/root PREFIX=${PREFIX} SRC_PREFIX=${SRC_PREFIX} /bin/sh /var/tmp/$1
fi
rm ${chrootPath}/var/tmp/$1
}
+6 -3
View File
@@ -7,9 +7,12 @@ CHROOTSUBDIR=mpchroot
baseDir=$(dirname $0)
dataDir=$(pwd)
if [[ $MPAB_DATA ]]; then
if [[ -n "$MPAB_DATA" ]]; then
dataDir=$MPAB_DATA
fi
if [[ -z "$SRC_PREFIX" ]]; then
SRC_PREFIX=/opt/mports
fi
chrootPath="${dataDir}/${CHROOTSUBDIR}"
@@ -34,14 +37,14 @@ else
${dataDir}/${exportDir} > /dev/null || exit 1
fi
if [[ ! -d ${dataDir}/mpchroot ]] ; then
if [[ ! -d ${chrootPath} ]] ; then
sudo ${baseDir}/mpab mount || exit 1
umount=yes
fi
rsync -r --del --exclude '*~' --exclude '.svn' \
${dataDir}/${exportDir}/dports \
${dataDir}/mpchroot/opt/mports || exit 1
${chrootPath}${SRC_PREFIX} || exit 1
echo "Re-creating portindex in chroot"
chroot_exec recreateportindex