[38930] contrib
raimue at macports.org
raimue at macports.org
Sat Aug 2 16:59:21 PDT 2008
Revision: 38930
http://trac.macosforge.org/projects/macports/changeset/38930
Author: raimue at macports.org
Date: 2008-08-02 16:59:21 -0700 (Sat, 02 Aug 2008)
Log Message:
-----------
Import MPAB from the wiki
Added Paths:
-----------
contrib/mpab/
contrib/mpab/ReadMe.txt
contrib/mpab/chroot-scripts/
contrib/mpab/chroot-scripts/buildports
contrib/mpab/chroot-scripts/genportlist.tcl
contrib/mpab/chroot-scripts/installmacports
contrib/mpab/mpab
contrib/mpab/mpab-functions
Added: contrib/mpab/ReadMe.txt
===================================================================
--- contrib/mpab/ReadMe.txt (rev 0)
+++ contrib/mpab/ReadMe.txt 2008-08-02 23:59:21 UTC (rev 38930)
@@ -0,0 +1,95 @@
+MacPorts AutoBuild
+Version 0.5, 2008-05-31
+
+Introduction
+------------
+MacPorts AutoBuild (mpab) is a set of scripts which creates a chroot
+environment in which to run MacPorts and build the entire group of ports
+available to it. Once complete (which could take a long time) or stopped,
+the build logs are moved out of the chroot to be available for review.
+
+
+Prerequisites
+-------------
+You need to have 10.5, Xcode 3.0, and Apple's X11 (other versions of Xcode
+and X11 may work, but these are the ones tested so far).
+
+For the MacPorts which will live in the chroot, you'll need (in the same
+directory as the mpab script) a tarball named macports_dist.tar.bz2. To
+create this straight from the MacPorts svn server (assuming current
+working directory is the same as the mpab script):
+
+ svn export http://svn.macports.org/repository/macports/trunk mpexport
+ cd mpexport
+ tar cf - . | bzip2 -c > ../macports_dist.tar.bz2
+ cd ..
+ rm -rf mpexport
+
+This just exports it from svn (since the .svn stuff isn't needed for this)
+then creates the tarball; note everything in the tarball is based on the
+current working directory.
+
+If you already have MacPorts from svn, run this instead of the first command
+above, then do the rest:
+ svn export /path/to/macports/svn/trunk mpexport
+
+
+Installation
+------------
+Once the MPAB tarball is extracted (which you've probably done if you're
+reading this), make sure the above prerequisites are available, then you
+are ready to go
+
+
+Running
+-------
+To just build it all (every port):
+
+ sudo ./mpab
+
+(assuming you are in the directory with the mpab script). This will do
+what needs doing to get a chroot, install MacPorts in said chroot, then
+start building ports.
+
+The first time you run, it will take some time as it is creating a chroot
+environment, which involves copying several gigabytes of files into
+said chroot...be patient.
+
+You can also run 'sudo ./mpab help' to see what commands can be used with
+mpab.
+
+
+Maintenance
+-----------
+mpab creates several disk images:
+
+ mproot.dmg - this is the basic chroot environment with various system
+ programs installed; it is read-only
+ mproot.dmg.shadow - this is where updates to the chroot go, which means
+ to restart with a bare chroot, simply delete it and
+ all traces of MacPorts are gone
+ mproot_distcache.sparseimage - this is a disk image only containing the
+ distfiles MacPorts downloads (which are
+ in /opt/local/var/macports/distfiles)
+
+When the OS version is updated, both mproot.dmg and mproot.dmg.shadow
+should be deleted so they can be rebuilt. Any time you want to clean out
+the MacPorts stuff within the chroot but not rebuild the entire environment,
+you can delete just mproot.dmg.shadow, to start from scratch. Note if you
+want to rebuild MacPorts, mpab has a rebuildmp target to do just that.
+
+
+Todo
+----
+improve the amount of debugging available via MPABDEBUG
+
+add 10.4 support (mostly needs different paths in pathsToCreate and
+pathsToCopy in buildImages())
+
+add a method to allow variants either globally or to an individual port
+
+fix dependency checking to work more like MP; currently if a port fails, all
+those depending on it are skipped, but if it's lib:...:port then it might
+still be buildable (see some things which depend on gnutar, and this will
+allow to skip the XFree86/xorg special-casing)
+
Property changes on: contrib/mpab/ReadMe.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: contrib/mpab/chroot-scripts/buildports
===================================================================
--- contrib/mpab/chroot-scripts/buildports (rev 0)
+++ contrib/mpab/chroot-scripts/buildports 2008-08-02 23:59:21 UTC (rev 38930)
@@ -0,0 +1,140 @@
+#!/bin/sh
+#
+# This is run in the chroot, so don't run yourself...
+#
+# 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.
+#
+
+function uninstallPorts()
+{
+ installedPorts=`/opt/local/bin/port installed | /usr/bin/tail +2 | /usr/bin/awk '{print $1}'`
+ for uninstallPort in $installedPorts; do
+ portOutput=`/opt/local/bin/port -dvf uninstall $uninstallPort 2>&1`
+ if [[ $? != 0 ]]; then
+ echo $portOutput
+ break
+ fi
+ done
+}
+
+
+function cleanBuildStuff()
+{
+ rm -rf /opt/local/var/macports/build/*
+ uninstallPorts
+ if [[ $? != 0 ]]; then
+ echo "Uninstall failed, aborting"
+ exit 1
+ fi
+}
+
+
+cleanBuildStuff
+PORTRESULTSDIR="/var/tmp/portresults"
+rm -rf ${PORTRESULTSDIR}
+/bin/mkdir -p ${PORTRESULTSDIR}/success ${PORTRESULTSDIR}/fail
+
+
+if [[ -f /var/tmp/portlist ]]; then
+ portList=`/bin/cat /var/tmp/portlist`
+ /bin/rm /var/tmp/portlist
+else
+ portList=`/usr/bin/tclsh /var/tmp/genportlist.tcl`
+fi
+
+portCount=`echo ${portList} | /usr/bin/wc -w`
+portCount=$(($portCount)) # Get rid of wc's spacing
+
+tclOS=`echo 'puts [string tolower $tcl_platform(os)]' | tclsh`
+tclArch=`echo 'puts $tcl_platform(machine)' | tclsh`
+if [[ $tclArch == "Power Macintosh" ]]; then
+ tclArch='powerpc'
+elif [[ $tclArch == 'i586' || $tclArch == 'i686' ]]; then
+ tclArch='i386'
+fi
+packageDir="/opt/local/var/macports/packages/${tclOS}/${tclArch}"
+
+currentCount=1
+for portName in ${portList}; do
+ trap "echo \"Canceled, cleaning up...\"; cleanBuildStuff" EXIT
+
+ # special-case XFree86 and xorg since they will "fail" (according to port's
+ # exit status) but since the chroot has Apple's X11, it's okay
+ if [[ ${portName} == "XFree86" || ${portName} == "xorg" ]]; then
+ continue
+ fi
+
+ echo "Building ${portName} (${currentCount} of ${portCount})...\c"
+ # If there's a package, don't build again
+ portVersion=`/opt/local/bin/port info --version ${portName} | awk '{print $2}'`
+ portRevision=`/opt/local/bin/port info --revision ${portName} | awk '{print $2}'`
+ portPackageBaseName="${portName}-${portVersion}_${portRevision}"
+ ls ${packageDir}/${portPackageBaseName}*.${tclArch}.tgz > /dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ echo "package found, not building again"
+ else
+ skipPort=""
+ portDeps=`/opt/local/bin/port deps ${portName} | /usr/bin/tail +2`
+ for oneDep in ${portDeps}; do
+ if [[ -f ${PORTRESULTSDIR}/fail/${oneDep}.log ]]; then
+ skipPort=${oneDep}
+ break
+ fi
+ done
+ if [[ -z $skipPort ]]; then
+ /opt/local/bin/port -dvx install $portName > ${PORTRESULTSDIR}/${portName}.log 2>&1
+ if [[ $? == 0 ]]; then
+ /bin/mv ${PORTRESULTSDIR}/${portName}.log ${PORTRESULTSDIR}/success
+ echo "success"
+ else
+ /bin/mv ${PORTRESULTSDIR}/${portName}.log ${PORTRESULTSDIR}/fail
+ echo "failure"
+ /opt/local/bin/port clean --work $portName
+ # If a port fails in the activation stage, MP has already built
+ # a package, so remove it here
+ rm -f ${packageDir}/${portPackageBaseName}*.${tclArch}.tgz
+ fi
+ uninstallPorts
+ if [[ $? != 0 ]]; then
+ echo "Uninstall failed, aborting"
+ exit 2
+ fi
+ else
+ echo "skipping, ${skipPort} previously failed and is needed"
+ echo "${portName} not built due to failed dependency ${skipPort}" > ${PORTRESULTSDIR}/fail/${portName}.log
+ fi
+ fi
+ currentCount=$((${currentCount}+1))
+done
+
+trap "" EXIT
+
+cleanBuildStuff
+
+exit 0
+
Property changes on: contrib/mpab/chroot-scripts/buildports
___________________________________________________________________
Name: svn:executable
+ *
Added: contrib/mpab/chroot-scripts/genportlist.tcl
===================================================================
--- contrib/mpab/chroot-scripts/genportlist.tcl (rev 0)
+++ contrib/mpab/chroot-scripts/genportlist.tcl 2008-08-02 23:59:21 UTC (rev 38930)
@@ -0,0 +1,97 @@
+#!/usr/bin/env tclsh
+#
+# Generates a list of ports where a port is only listed after all of its
+# dependencies (sans variants) have already been listed
+#
+# 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.
+#
+
+catch {source \
+ [file join "/" Library Tcl macports1.0 macports_fastload.tcl]}
+package require macports
+
+
+proc ui_prefix {priority} {
+ return "OUT: "
+}
+
+
+proc ui_channels {priority} {
+ return {}
+}
+
+
+proc process_port_deps {portname portdeps_in portlist_in} {
+ upvar $portdeps_in portdeps
+ upvar $portlist_in portlist
+ if {[lsearch -exact $portlist $portname] == -1} {
+ if {[info exists portdeps($portname)]} {
+ foreach portdep $portdeps($portname) {
+ if {[lsearch -exact $portlist $portdep] == -1} {
+ process_port_deps $portdep portdeps portlist
+ }
+ }
+ }
+ lappend portlist $portname
+ }
+}
+
+
+if {[catch {mportinit "" "" ""} result]} {
+ puts "$errorInfo"
+ fatal "Failed to initialize ports sytem: $result"
+}
+
+if {[catch {set search_result [mportsearch ^.+$ no]} result]} {
+ puts "$errorInfo"
+ fatal "Failed to find any ports: $result"
+}
+
+array set portdepinfo {}
+foreach {name infoarray} $search_result {
+ array set portinfo $infoarray
+ set depstypes {depends_build depends_lib depends_run}
+ set deplist [list]
+ foreach depstype $depstypes {
+ if {[info exists portinfo($depstype)] && $portinfo($depstype) != ""} {
+ foreach onedep $portinfo($depstype) {
+ lappend deplist [lindex [split [lindex $onedep 0] :] end]
+ }
+ }
+ }
+ set portdepinfo($portinfo(name)) $deplist
+ array unset portinfo
+}
+
+set portlist [list]
+foreach portname [lsort -dictionary [array names portdepinfo]] {
+ process_port_deps $portname portdepinfo portlist
+}
+
+puts [join $portlist "\n"]
+
Property changes on: contrib/mpab/chroot-scripts/genportlist.tcl
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: contrib/mpab/chroot-scripts/installmacports
===================================================================
--- contrib/mpab/chroot-scripts/installmacports (rev 0)
+++ contrib/mpab/chroot-scripts/installmacports 2008-08-02 23:59:21 UTC (rev 38930)
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# 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" > /opt/local/etc/macports/sources.conf
+fi
+
Property changes on: contrib/mpab/chroot-scripts/installmacports
___________________________________________________________________
Name: svn:executable
+ *
Added: contrib/mpab/mpab
===================================================================
--- contrib/mpab/mpab (rev 0)
+++ contrib/mpab/mpab 2008-08-02 23:59:21 UTC (rev 38930)
@@ -0,0 +1,113 @@
+#!/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"
+
+if [[ -n ${MPABDEBUG} ]]; then
+ HDIUTILDEBUG="-verbose"
+else
+ HDIUTILDEBUG="-quiet"
+fi
+export HDIUTILDEBUG
+
+cd `dirname $0`
+baseDir=`pwd -P`
+chrootPath="${baseDir}/${CHROOTSUBDIR}"
+cd - > /dev/null
+
+. ${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" ]]; then
+ printUsageAndExit
+ 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
+
+checkDependencies ${baseDir} ${MPTARBALL}
+returnValue=$?
+if [[ ${returnValue} != 0 ]]; then
+ exit ${returnValue}
+fi
+
+if [[ ${command} == "umount" ]]; then
+ umountChroot ${chrootPath}
+ exit 0
+fi
+
+if [[ ${command} == "mount" || ${command} == "buildmp" ||
+ ${command} == "rebuildmp" || ${command} == "buildports" ]]; then
+ buildImages ${baseDir} ${chrootPath} ${IMGBASENAME}
+ mountChroot ${baseDir} ${chrootPath} ${IMGBASENAME}
+ if [[ $? == 0 &&
+ ( ${command} == "buildmp" || ${command} == "rebuildmp" ||
+ ${command} == "buildports" ) ]]; then
+ trap "exitFunction ${baseDir} ${chrootPath}" EXIT
+ exitMessage="Stopping..."
+ if [[ ${command} == "rebuildmp" ]]; then
+ rm -rf ${chrootPath}/opt/mports
+ rm -f ${chrootPath}/opt/local/bin/port
+ fi
+ buildMacPorts ${baseDir} ${chrootPath} ${MPTARBALL}
+ 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
+
Property changes on: contrib/mpab/mpab
___________________________________________________________________
Name: svn:executable
+ *
Added: contrib/mpab/mpab-functions
===================================================================
--- contrib/mpab/mpab-functions (rev 0)
+++ contrib/mpab/mpab-functions 2008-08-02 23:59:21 UTC (rev 38930)
@@ -0,0 +1,336 @@
+#
+# 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.
+#
+
+#------------------------------------------------------------------------
+# Check necessary bits are available
+# $1 - base directory
+# $2 - MacPorts source tarball
+function checkDependencies()
+{
+ baseDir=$1
+ mpTarball=$2
+
+ if [[ `id -u` != 0 ]]; then
+ echo "This must be run as root, please do so"
+ return 1
+ fi
+ if [[ ! -f ${baseDir}/${mpTarball} ]]; then
+ cat << EOF
+Need to have a MacPorts source tarball as ${baseDir}/${mpTarball}
+See the ReadMe.txt file.
+EOF
+ return 2
+ fi
+}
+
+
+#------------------------------------------------------------------------
+# Print out usage help and exit
+function printUsageAndExit()
+{
+ cat << EOF
+Usage: $0 [help | mount | umount | buildmp | rebuildmp |
+ buildports [portlist_file]]
+ help: this help
+ mount: just mount the chroot images
+ umount: unmount the chroot images
+ buildmp: build/install MacPorts inside the chroot
+ rebuildmp: force a rebuild of MacPorts inside the chroot
+ buildports: build ports; if a portlist file is given, use it, otherwise
+ build all; portlist_file is a simple text file with one port
+ per line; dependencies will be built as needed
+ default is to do everything (except rebuildmp); buildmp and buildports
+ will unmount the chroot when done
+EOF
+ exit 0
+}
+
+
+#------------------------------------------------------------------------
+# Do whatever cleanup is necessary
+# $1 - base directory
+# $2 - chroot path
+function exitFunction()
+{
+ baseDir=$1
+ chrootPath=$2
+
+ if [[ -n $exitMessage ]]; then
+ echo $exitMessage
+ fi
+ if [[ -d ${chrootPath}/var/tmp/portresults/fail ]]; then
+ moveAndReport ${baseDir} ${chrootPath}
+ fi
+ if [[ -d ${chrootPath} ]]; then
+ umountChroot ${chrootPath}
+ fi
+}
+
+
+#------------------------------------------------------------------------
+# Build the base chroot and distfile cache disk images
+# $1 - base directory
+# $2 - chroot path
+# $3 - base name for the disk images
+function buildImages()
+{
+ baseDir=$1
+ chrootPath=$2
+ imgBaseName=$3
+
+ echo "Building MP chroot images, if necessary"
+
+ # Paths to create within the chroot
+ pathsToCreate="private/etc private/var/folders private/var/log private/var/spool private/var/run private/var/tmp private/var/db/dyld private/tmp"
+
+ # Paths to copy to the chroot
+ pathsToCopy="private/etc/bashrc private/etc/group private/etc/hosts private/etc/pam.d private/etc/passwd private/etc/profile private/etc/shells private/var/root bin sbin etc tmp var usr/bin usr/include usr/lib usr/libexec usr/sbin usr/share usr/X11 usr/X11R6 Developer/Headers Developer/Library Developer/Makefiles Developer/Private Developer/SDKs Developer/Tools Developer/usr System/Library/CoreServices System/Library/Filesystems System/Library/Frameworks System/Library/Java System/Library/Perl System/Library/PrivateFrameworks System/Library/Tcl"
+
+ # Size of the disk images (hdiutil nomenclature)
+ imageSize="32g"
+
+ # Filesystem of the disk images (hdiutil nomenclature)
+ imageFileSystem="HFS+J"
+
+ mkdir -p ${chrootPath}
+
+ if [[ ! -f ${baseDir}/${imgBaseName}.dmg ]]; then
+ hdiutil create -size ${imageSize} -fs ${imageFileSystem} -volname MPRoot -imagekey sparse-band-size=16384 ${baseDir}/${imgBaseName}.sparseimage ${HDIUTILDEBUG}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "hdiutil create (MPRoot) failed"
+ return ${returnValue}
+ fi
+
+ hdiutil attach ${baseDir}/${imgBaseName}.sparseimage -mountpoint ${chrootPath} -owners on -nobrowse -noautofsck ${HDIUTILDEBUG}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "Failed to attach"
+ return ${returnValue}
+ fi
+ mkdir ${chrootPath}/dev
+ mount_devfs devfs ${chrootPath}/dev
+ mount_fdesc -o union fdesc ${chrootPath}/dev
+
+ if [[ ! -d ${chrootPath}/usr ]]; then
+ cd /
+ for createpath in ${pathsToCreate}; do
+ mkdir -p ${chrootPath}/${createpath}
+ done
+
+ for copypath in ${pathsToCopy}; do
+ pax -r -w -pe $copypath ${chrootPath}
+ done
+ cd - > /dev/null
+ fi
+
+ umount -f ${chrootPath}/dev
+ umount -f ${chrootPath}/dev
+ hdiutil detach ${chrootPath} ${HDIUTILDEBUG}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "hdiutil detach failed"
+ return ${returnValue}
+ fi
+ hdiutil convert ${baseDir}/${imgBaseName}.sparseimage -format UDRO -o ${baseDir}/${imgBaseName}.dmg ${HDIUTILDEBUG}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "hdiutil convert failed"
+ return ${returnValue}
+ fi
+ rm ${baseDir}/${imgBaseName}.sparseimage
+ fi
+
+ if [[ ! -f ${baseDir}/${imgBaseName}_distcache.sparseimage ]]; then
+ hdiutil create -size ${imageSize} -fs ${imageFileSystem} -volname MPCache -imagekey sparse-band-size=16384 ${baseDir}/${imgBaseName}_distcache.sparseimage ${HDIUTILDEBUG}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "hdiutil create (MPCache) failed"
+ return ${returnValue}
+ fi
+ fi
+
+ return 0
+}
+
+
+#------------------------------------------------------------------------
+# Build MacPorts in the chroot
+# $1 - base directory
+# $2 - chroot path
+# $3 - MacPorts source tarball
+function buildMacPorts()
+{
+ baseDir=$1
+ chrootPath=$2
+ mpTarball=$3
+
+ echo "Building/installing MP in chroot, if necessary"
+
+ if [[ ! -d ${chrootPath}/opt/mports ]]; then
+ if [[ ! -f ${baseDir}/${mpTarball} ]]; then
+ echo "No ${mpTarball} found"
+ return 1
+ fi
+ mkdir -p ${chrootPath}/opt/mports
+ cd ${chrootPath}/opt/mports
+ bunzip2 -c ${baseDir}/${mpTarball} | tar xf -
+ cd - > /dev/null
+ fi
+
+ if [[ ! -f ${chrootPath}/opt/local/bin/port ]]; then
+ cp -p ${baseDir}/chroot-scripts/installmacports ${chrootPath}/var/tmp/
+ # 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/installmacports
+ rm ${chrootPath}/var/tmp/installmacports
+ sed 's/portarchivemode.*no/portarchivemode yes/' ${chrootPath}/opt/local/etc/macports/macports.conf > ${chrootPath}/opt/local/etc/macports/macports.conf.new
+ mv ${chrootPath}/opt/local/etc/macports/macports.conf.new ${chrootPath}/opt/local/etc/macports/macports.conf
+ fi
+
+ return 0
+}
+
+
+#------------------------------------------------------------------------
+# Build MP ports, either those listed in a file given or by generating
+# a list of all ports and using that
+# $1 - base directory
+# $2 - chroot path
+function buildPorts()
+{
+ baseDir=$1
+ chrootPath=$2
+
+ echo "Building ports"
+
+ cp -p ${baseDir}/chroot-scripts/buildports ${chrootPath}/var/tmp/
+ cp -p ${baseDir}/chroot-scripts/genportlist.tcl ${chrootPath}/var/tmp/
+
+ # 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/buildports
+
+ return 0
+}
+
+
+#------------------------------------------------------------------------
+# Move logs and report results
+# $1 - base directory
+# $2 - chroot path
+function moveAndReport()
+{
+ baseDir=$1
+ chrootPath=$2
+
+ now=`date '+%Y%m%d-%H%M%S'`
+ mkdir ${baseDir}/logs-${now}
+ mv ${chrootPath}/var/tmp/portresults/fail ${baseDir}/logs-${now}
+ mv ${chrootPath}/var/tmp/portresults/success ${baseDir}/logs-${now}
+ failcount=`ls -1 ${baseDir}/logs-${now}/fail | wc -l`
+ successcount=`ls -1 ${baseDir}/logs-${now}/success | wc -l`
+ echo "Ports built successfully: $successcount"
+ echo "Ports failed: $failcount"
+ echo "All logs are located in ${baseDir}/logs-${now}"
+
+ return 0
+}
+
+
+#------------------------------------------------------------------------
+# Mount the full chroot stuff
+# $1 - base directory
+# $2 - chroot path
+# $3 - base name for the disk images
+function mountChroot()
+{
+ baseDir=$1
+ chrootPath=$2
+ imgBaseName=$3
+
+ echo "Mounting chroot images"
+
+ mkdir -p ${chrootPath}
+
+ if [[ ! -d ${chrootPath}/usr ]]; then
+ if [[ ! -f ${baseDir}/${imgBaseName}.dmg ]]; then
+ echo "MPRoot image ${baseDir}/${imgBaseName}.dmg not found"
+ return 1
+ fi
+ hdiutil attach ${baseDir}/${imgBaseName}.dmg -mountpoint ${chrootPath} -shadow -noverify -owners on -nobrowse -noautofsck ${HDIUTILDEBUG}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "Failed to attach root image"
+ return ${returnValue}
+ fi
+ 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}
+ returnValue=$?
+ if [[ ${returnValue} != 0 ]]; then
+ echo "Failed to attach distfiles image"
+ return ${returnValue}
+ fi
+ fi
+
+ return 0
+}
+
+
+#------------------------------------------------------------------------
+# Unmount everything for the MP chroot
+# $1 - chroot path
+function umountChroot()
+{
+ chrootPath=$1
+
+ if [[ -d ${chrootPath}/dev ]]; then
+ # First for the fdesc
+ umount -f ${chrootPath}/dev
+ # And again for the devfs
+ umount -f ${chrootPath}/dev
+ fi
+ if [[ -d ${chrootPath}/opt/local/var/macports/distfiles ]]; then
+ # Now the cache image for the dist files
+ hdiutil detach ${chrootPath}/opt/local/var/macports/distfiles ${HDIUTILDEBUG}
+ fi
+ if [[ -d ${chrootPath} ]]; then
+ # Finally, the main image itself
+ hdiutil detach ${chrootPath} ${HDIUTILDEBUG}
+ rmdir ${chrootPath}
+ fi
+
+ return 0
+}
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080802/60be44fd/attachment-0001.html
More information about the macports-changes
mailing list