[darwinbuild-changes] [447] trunk
source_changes at macosforge.org
source_changes at macosforge.org
Sun Dec 21 00:19:07 PST 2008
Revision: 447
http://trac.macosforge.org/projects/darwinbuild/changeset/447
Author: wsiegrist at apple.com
Date: 2008-12-21 00:19:03 -0800 (Sun, 21 Dec 2008)
Log Message:
-----------
Make shell scripts honor PREFIX during compile phase.
Modified Paths:
--------------
trunk/common.mk
trunk/darwinbuild/Makefile
Added Paths:
-----------
trunk/darwinbuild/darwinbuild.in
trunk/darwinbuild/darwinmaster.sh.in
trunk/darwinbuild/packageRoots.sh.in
trunk/darwinbuild/thinPackages.sh.in
Removed Paths:
-------------
trunk/darwinbuild/darwinbuild
trunk/darwinbuild/darwinmaster.sh
trunk/darwinbuild/packageRoots.sh
trunk/darwinbuild/thinPackages.sh
Modified: trunk/common.mk
===================================================================
--- trunk/common.mk 2008-12-21 00:09:50 UTC (rev 446)
+++ trunk/common.mk 2008-12-21 08:19:03 UTC (rev 447)
@@ -17,3 +17,5 @@
INSTALL_EXE_FLAGS=-m 0755 -o root -g wheel
INSTALL_DIR_FLAGS=$(INSTALL_EXE_FLAGS)
INSTALL_DOC_FLAGS=-m 0644 -o root -g wheel
+
+SED=/usr/bin/sed
\ No newline at end of file
Modified: trunk/darwinbuild/Makefile
===================================================================
--- trunk/darwinbuild/Makefile 2008-12-21 00:09:50 UTC (rev 446)
+++ trunk/darwinbuild/Makefile 2008-12-21 08:19:03 UTC (rev 447)
@@ -5,11 +5,20 @@
###
DATDIR:=$(DATDIR)/darwinbuild
-all: manifest
+PrefixReplacements = darwinbuild \
+ darwinmaster.sh \
+ packageRoots.sh \
+ thinPackages.sh
+all: manifest prefixes
+
manifest: manifest.c
cc -Wall -Werror -o $(OBJROOT)/$@ -lcrypto $^
+prefixes:
+ @$(foreach SCRIPT,$(PrefixReplacements), \
+ $(SED) -e 's,%%PREFIX%%,$(PREFIX),' $(SCRIPT).in > $(SCRIPT) ;)
+
install: all
[ -d $(BINDIR) ] || $(INSTALL) -d $(INSTALL_DIR_FLAGS) $(BINDIR)
$(INSTALL) $(INSTALL_EXE_FLAGS) darwinbuild $(BINDIR)
@@ -53,3 +62,5 @@
clean:
rm -f manifest
+ @$(foreach SCRIPT,$(PrefixReplacements), \
+ rm -f $(SCRIPT) ; )
Deleted: trunk/darwinbuild/darwinbuild
===================================================================
--- trunk/darwinbuild/darwinbuild 2008-12-21 00:09:50 UTC (rev 446)
+++ trunk/darwinbuild/darwinbuild 2008-12-21 08:19:03 UTC (rev 447)
@@ -1,895 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2004-2005, Apple Computer, Inc. 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 of Apple Computer, Inc. ("Apple") nor the names of
-# its contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
-# ANY EXPRESS 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 APPLE OR ITS 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.
-#
-
-###
-### README
-###
-### This script sets up the proper environment to build Darwin projects
-###
-### Building takes place in the BuildRoot, this should be an HFSX (or UFS)
-### volume (Disk images work well). The BuildRoot location can by specified by
-### the DARWIN_BUILDROOT environment variable. If not set, it will default
-### to the current working directory. However, if the current working directory
-### does not contain a Sources, Roots, Logs, and other necessary directories
-### the script will exit with an error.
-###
-### This script has the ability to build in a changed root. This allows
-### slightly projects to be built for targets that differ from the host
-### system, and also helps prevent against pollution of the host system
-### with intermediate build tools and headers. Unfortunately there are
-### limitations on just how much the changed root can vary from the host
-### system. For example, items in the changed root still need to be
-### compatible with the system daemons that are running (i.e. lookupd)
-### and if devfs or volfs is mounted in the changed root, it will resemble
-### the host system, and not the target system.
-###
-### If the project's version is omitted then the darwinxref tool is consulted.
-### This tool should live in the same directory as this script. darwinxref
-### allows cross-referencing of project versions and system build numbers.
-### If no build number is specified, the host system's build number is used,
-### otherwise the version of the project for the specified build will be built.
-###
-### The script checks its source cache (BuildRoot/Sources) for a .tar.gz archive
-### of the given project-version. If one exists, it is used. If it does not
-### exist, then this script will attempt to use curl(1) to fetch the sources
-### from the darwinsource.opendarwin.org and www.opensource.apple.com sites.
-###
-### If the -chroot option is specified, the script will use the darwinxref tool
-### to populate the build root with the "Roots" necessary to build the project
-### (Roots are pre-compiled projects ready for installation). This script
-### will look for an existing root in the root cache (BuildRoot/Roots). If a
-### root is missing, then this script will attempt to use curl(1) to fetch the
-### roots from the darwinsource.opendarwin.org and www.opensource.apple.com sites.
-###
-### If the specified project requires Xcode to build (i.e. it does not use
-### a makefile, but instead has a .pbproj or .xcode project file), then it
-### must be built on a Mac OS X system, and cannot be built on a Darwin system.
-### Furthermore, because Xcode and many of the frameworks it uses are not open
-### source, it is not distributed on the www.opensource.apple.com or
-### darwinsource.opendarwin.org sites. This script will look for a special
-### Xcode root in the local root cache, and if it doesn't exist, it will attempt
-### to create the root using the Xcode installation on the host system.
-###
-###
-
-PREFIX=/usr/local
-XREFDB=.build/xref.db
-DARWINXREF=$PREFIX/bin/darwinxref
-DATADIR=$PREFIX/share/darwinbuild
-COMMONFILE=$DATADIR/darwinbuild.common
-DARWINTRACE=$DATADIR/darwintrace.dylib
-DITTO=$DATADIR/ditto
-DEFAULTPLISTSITE=http://svn.macosforge.org/repository/darwinbuild/trunk/plists/
-
-# PREFIX=/Volumes/HD/ltmp/build/darwinbuild
-# DARWINXREF=$PREFIX/darwinxref/darwinxref
-# DATADIR=$PREFIX/darwinbuild
-# COMMONFILE=$DATADIR/darwinbuild.common
-# DARWINTRACE=$PREFIX/darwintrace/darwintrace.dylib
-# DITTO=$DATADIR/ditto.sh
-# DEFAULTPLISTSITE=file:///Volumes/HD/ltmp/build/darwinbuild/plists/
-
-build=""
-depsbuild=""
-CHROOTED="YES"
-logdeps=""
-nopatch=""
-noload=""
-loadonly=""
-projnam=""
-action="install"
-target=""
-version=""
-
-###
-### Include some common subroutines
-###
-
-. "$COMMONFILE"
-
-shopt -s nullglob
-
-###
-### DarwinBuild must be run as root. Enforce this.
-###
-if [ "$EUID" != "0" ]; then
- echo "Error: DarwinBuild must be run as root." 1>&2
- exit 1
-fi
-
-###
-### The "-init" command sets up the build environment
-### in the current working directory.
-### EXITs
-###
-if [ "$1" == "-init" ]; then
- if [ "$2" == "" ]; then
- echo "usage: $(basename $0) -init <build>" 1>&2
- exit 1
- fi
- build="$2"
- sites=""
- [ -d Roots ] || mkdir Roots
- [ -d Sources ] || mkdir Sources
- [ -d Symbols ] || mkdir Symbols
- [ -d Headers ] || mkdir Headers
- [ -d Logs ] || mkdir Logs
- [ -d .build ] || mkdir .build
-
- # check if there's a plist locally by this name
- if [ -f "$build" ]; then
- filepath="$build"
- filename=$(basename "$filepath")
- build=$(echo "$filename" | sed 's/.plist$//')
- # since we don't want to download this, copy it
- cp "$filepath" ".build/$build.plist"
- fi
-
- echo "$build" > .build/build
-
- while [ "$build" != "" ]; do
- Download .build "$build".plist "$sites ${DEFAULTPLISTSITE}"
- $DARWINXREF "-f$XREFDB" "-b$build" loadIndex .build/"$build".plist
- sites=$($DARWINXREF "-f$XREFDB" "-b$build" plist_sites | xargs echo)
- build=$($DARWINXREF "-f$XREFDB" "-b$build" inherits)
- done
- echo "Initialization Complete"
- exit 0
-fi
-
-
-function PrintUsage() {
- cat <<-EOF 1>&2
- usage: $(basename $0) [flags] <project> [<version>]
- usage: flags: [-headers] [-build=X] [-target=X]
- [-logdeps] [-nochroot] [-nopatch] [-noload | -loadonly]
- [-depsbuild=X [-depsbuild=Y]]
- [-fetch] [-source] [-load]
-EOF
- exit 1
-}
-
-###
-### Check that we're property situated in an initialized directory
-###
-CheckDarwinBuildRoot
-
-BuildRoot="$DARWIN_BUILDROOT/BuildRoot"
-mkdir -p "$BuildRoot"
-export DARWINXREF_DB_FILE="$DARWIN_BUILDROOT/$XREFDB"
-
-###
-### Check and see wether there is a sources directory set in the
-### environment ($DARWIN_SOURCES). If not we assign it the sources pass
-### in the $DARWIN_BUILDROOT
-###
-
-if [ "$DARWIN_SOURCES" != "" ]; then
- if [ "${DARWIN_SOURCES:0:1}" != "/" ]; then
- echo "The DARWIN_SOURCES environment variable must contain" 1>&2
- echo "an absolute path." 1>&2
- echo "" 1>&2
- exit 1
- else
- SourceCache="$DARWIN_SOURCES"
- fi
-else
- SourceCache="$DARWIN_BUILDROOT/Sources"
-fi
-
-if [ ! -e $SourceCache ]; then
- mkdir -p "$SourceCache"
-fi
-
-###
-### Interpret our arguments:
-### -headers Do the installhdrs phase, instead of install
-### -fetch Download necessary source and patch files
-### -source Extract, patch, and stage source
-### -nochroot Do not chroot into the BuildRoot when building
-### -load Populate the BuildRoot with one project
-### -nopatch Don't patch sources before building.
-### -noload Don't load dependencies into the chroot.
-### Has no effect if -nochroot is specified.
-### -loadonly Only load dependencies into the chroot, but
-### don't build.
-### -logdeps Do magic to log the build-time dependencies
-### -target=X The makefile or xcode target to build
-### -build=X X is the darwin build number to buld, e.g. 8B15
-### -depsbuild=X X is the darwin build number to populate the BuildRoot
-### <project> The name of the project to build
-### <version> If specified, the version of the project to build
-### this will default to the version associated with the
-### currently running build.
-
-if [ "$DARWINBUILD_BUILD" != "" ]; then
- build="$DARWINBUILD_BUILD"
-fi
-
-for ARG in "$@"; do
- if [ "$projnam" == "" ]; then
- if [ "$ARG" == "-headers" ]; then
- if [ "$action" == "load" ]; then
- action="loadhdrs"
- else
- action="installhdrs"
- fi
- elif [ "$ARG" == "-fetch" ]; then
- action="fetch"
- elif [ "$ARG" == "-source" ]; then
- action="source"
- elif [ "${ARG/=*/}" == "-target" ]; then
- target="${ARG/*=/}"
- elif [ "${ARG/=*/}" == "-build" ]; then
- build="${ARG/*=/}"
- elif [ "${ARG/=*/}" == "-depsbuild" ]; then
- depsbuild="${depsbuild} ${ARG/*=/}"
- elif [ "$ARG" == "-nochroot" ]; then
- export CHROOTED="NO"
- elif [ "$ARG" == "-nopatch" ]; then
- nopatch="YES"
- elif [ "$ARG" == "-load" ]; then
- if [ "$action" == "installhdrs" ]; then
- action="loadhdrs"
- else
- action="load"
- fi
- elif [ "$ARG" == "-noload" ]; then
- noload="YES"
- elif [ "$ARG" == "-loadonly" ]; then
- loadonly="YES"
- elif [ "$ARG" == "-logdeps" ]; then
- logdeps="YES"
- elif [ "${ARG:0:1}" != "-" ]; then
- projnam="$ARG"
- else
- PrintUsage "$0"
- fi
- elif [ "$version" == "" ]; then
- version="$ARG"
- else
- PrintUsage "$0"
- fi
-done
-
-if [ "$projnam" == "" -o "${projnam:0:1}" == "-" ]; then
- PrintUsage "$0"
-fi
-
-###
-### No build number specified. Look in the DARWIN_BUILDROOT for
-### a cached value.
-###
-if [ "$build" == "" -a -f "$DARWIN_BUILDROOT/.build/build" ]; then
- build="$(cat $DARWIN_BUILDROOT/.build/build)"
-fi
-
-###
-### Still no build number specified. Error.
-###
-if [ "$build" == "" ]; then
- echo "Error: no build number specified." 2>&1
- exit 1
-fi
-export DARWINBUILD_BUILD="$build"
-
-###
-### By default, dependencies are taken from the same build,
-### but that can be overridden above.
-###
-if [ "$depsbuild" == "" ]; then
- depsbuild="$build"
-fi
-
-
-###
-### If we are doing a -load, install the root and exit.
-###
-if [ "$action" == "load" ]; then
- InstallRoot "$BuildRoot" "$projnam" "$depsbuild"
- exit 0
-elif [ "$action" == "loadhdrs" ]; then
- InstallHeader "$BuildRoot" "$projnam" "$depsbuild"
- exit 0
-fi
-
-#
-# Get the version of the project for this build.
-#
-if [ "$version" == "" ]; then
- project=$($DARWINXREF version "$projnam")
- version=${project/$projnam-/}
-else
- project="$projnam-$version"
-fi
-
-#
-# Check if the project is a build alias.
-#
-alias=$($DARWINXREF original "$projnam")
-
-#
-# Look for an alternate target in the database
-#
-if [ "$target" == "" -a "$action" == "install" ]; then
- target=$($DARWINXREF target "$projnam")
-fi
-
-#
-# Sanity check to make sure we actually have a project to build.
-#
-if [ "$project" == "" ]; then
- echo "ERROR: project not found: $projnam" 1>&2
- exit 1
-fi
-
-
-
-
-
-###
-### Download the sources,
-### and any applicable patches.
-###
-echo "*** Fetching Sources ..."
-# project might be a build alias
-if [ "$alias" != "" ]; then
- filename="$alias-$version.tar.gz"
-else
- filename="$project.tar.gz"
-fi
-patchfilenames=$($DARWINXREF patchfiles $projnam)
-#echo "patchfiles are $patchfilenames"
-Download "$SourceCache" "$filename" "$($DARWINXREF source_sites $projnam)"
-for p in $patchfilenames; do
- Download "$SourceCache" "$p" "$($DARWINXREF source_sites $projnam)"
-done
-
-### If we are doing a -fetch, stop here.
-if [ "$action" == "fetch" ]; then
- exit
-fi
-
-###
-### We do our building in private/var/tmp since it's
-### likely to be out of the way of our dependencies
-### and is supposed to be writable by everyone.
-###
-
-vartmp="private/var/tmp"
-mkdir -p "$BuildRoot/$vartmp"
-chmod 1777 "$BuildRoot/$vartmp"
-
-###
-### Define the SRCROOT, OBJROOT, SYMROOT, and DSTROOT.
-### This script refers to the absolute paths of the build
-### directory, and should use REAL_SRCROOT, etc.
-### If CHROOTED, then the environment variables will have
-### the BuildRoot prefix omitted because the chroot
-### will make all paths relative to that point.
-###
-REAL_SRCROOT="$BuildRoot/SourceCache/$projnam/$project"
-REAL_OBJROOT="$BuildRoot/$vartmp/$projnam/$project.obj"
-REAL_SYMROOT="$BuildRoot/$vartmp/$projnam/$project.sym"
-REAL_DSTROOT="$BuildRoot/$vartmp/$projnam/$project.root"
-if [ "$CHROOTED" == "YES" ]; then
- prefix="$BuildRoot"
-else
- prefix=""
-fi
-export SRCROOT="${REAL_SRCROOT/$prefix/}"
-export OBJROOT="${REAL_OBJROOT/$prefix/}"
-export SYMROOT="${REAL_SYMROOT/$prefix/}"
-export DSTROOT="${REAL_DSTROOT/$prefix/}"
-
-###
-### Remove any pre-existing directories that might be in the way
-### and create new directories in their place. Make sure the
-### directories have root:wheel ownership, otherwise things may
-### not build correctly.
-###
-rm -Rf "$REAL_SRCROOT" "$REAL_OBJROOT" "$REAL_SYMROOT" "$REAL_DSTROOT"
-mkdir -p "$REAL_SRCROOT" "$REAL_OBJROOT" "$REAL_SYMROOT" "$REAL_DSTROOT"
-chown root:wheel "$REAL_SRCROOT" "$REAL_OBJROOT" "$REAL_SYMROOT" "$REAL_DSTROOT"
-
-###
-### Install the sources and patches into the BuildRoot
-###
-cd "$REAL_SRCROOT/.."
-echo "*** Copying Sources ..."
-if [ -d "$SourceCache/$project" ]; then
- tar c -C "$SourceCache" "$project" | tar xf -
-elif [ "$alias" != "" -a -d "$SourceCache/$alias-$version" ]; then
- tar c -C "$SourceCache" "$alias-$version" | tar xf -
- rmdir "$REAL_SRCROOT"
- ln -fhs "$alias-$version" "$project"
-elif [ "$alias" != "" ]; then
- tar xzf "$SourceCache/$alias-$version.tar.gz"
- rmdir "$REAL_SRCROOT"
- ln -fhs "$alias-$version" "$project"
-else
- tar xzf "$SourceCache/$filename"
-fi
-
-# you can avoid registering patches in the DB by using "xnu-792--patches.tar.gz"
-if [ -r "$SourceCache/$project-patches.tar.gz" ]; then
- tar xzf "$SourceCache/$project-patches.tar.gz"
-fi
-
-###
-### Apply the patches
-### Current working directory should be the SRCROOT
-###
-cd "$REAL_SRCROOT"
-if [ "$nopatch" != "YES" ]; then
-if [ -d "$REAL_SRCROOT/../$project-patches" ]; then
- echo "*** Applying Patches ..."
- cat $REAL_SRCROOT/../$project-patches/* | patch -p0
-fi
-for patchfile in $patchfilenames; do
- echo "*** Applying Patch $patchfile ..."
- if [ -r "$SourceCache/$patchfile" ]; then
- catprog=""
- case $patchfile in
- *.gz)
- catprog="gzip -d -c"
- ;;
- *.bz2)
- catprog="bzip2 -d -c"
- ;;
- *)
- catprog="cat"
- ;;
- esac
- case $patchfile in
- *.p1.patch*)
- $catprog "$SourceCache/$patchfile" | patch -l -f -p1
- ;;
- *.patch*)
- $catprog "$SourceCache/$patchfile" | patch -l -f -p0
- ;;
- *.add*)
- newfile=`echo $patchfile | sed -e 's/^.*-\([^-]*\)\.add.*/\1/' -e 's,_,/,g'`
- $catprog "$SourceCache/$patchfile" > "./$newfile"
- ;;
- *)
- echo "Don't know how to apply $patchfile"
- ;;
- esac
- fi
-done
-fi
-
-### If we are doing a -source, stop here.
-if [ "$action" == "source" ]; then
- exit
-fi
-
-###
-### Look for the build tool: make, xcodebuild
-###
-
-numfiles=$(echo *.pbxproj *.pbproj *.xcode *.xcodeproj 2> /dev/null )
-if [ -n "$numfiles" ]; then
- buildtool="xcodebuild"
-else
- buildtool="make"
-fi
-
-###
-### If we are CHROOTED, then
-### Install the roots into the BuildRoot
-### Make sure we have at least a minimally functioning root
-### by installing bash and its dependencies.
-###
-### Also install CoreOSMakefiles and Perl for make based projects
-###
-if [ "$CHROOTED" == "YES" -a "$noload" != "YES" ]; then
- echo "*** Installing Roots ..."
- receipts="$BuildRoot/usr/local/darwinbuild/receipts"
- mkdir -p "$receipts"
- bash_deps=$($DARWINXREF dependencies -run "bash")
- deps=$($DARWINXREF dependencies -build "$projnam")
-
- for X in files bash $bash_deps $deps ; do
- InstallRoot "$BuildRoot" "$X" "$depsbuild"
- done
-
- ### so many things require ditto, we have hacked around it
- if [ ! -x "$BuildRoot/usr/bin/ditto" ]; then
- cp "$DITTO" "$BuildRoot/usr/bin/ditto"
- fi
-
- ### need dsymutil but it depends on libauto so disable for now
- if [ ! -x "$BuildRoot/usr/bin/dsymutil" ]; then
- cp "/usr/bin/dsymutil" "$BuildRoot/usr/bin/dsymutil"
- fi
-
- ### CoreOSMakefiles
- if [ ! -d "$BuildRoot/Developer/Makefiles/CoreOS" ]; then
- InstallRoot "$BuildRoot" "CoreOSMakefiles" "$depsbuild"
- fi
-
- ### Perl
- if [ ! -x "$BuildRoot/usr/bin/perl" ]; then
- InstallRoot "$BuildRoot" "perl" "$depsbuild"
- fi
-
- echo "*** Installing Headers ..."
- deps=$($DARWINXREF dependencies -header "$projnam")
- for X in $deps ; do
- InstallHeader "$BuildRoot" "$X" "$depsbuild"
-# InstallRoot "$BuildRoot" "$X" "$depsbuild"
- done
-
- ### xcodebuild is a special case because it is not open source
- ### we try to install it from the host Mac OS X system if it is required
- if [ "$buildtool" == "xcodebuild" -a ! -f "$receipts/xcodebuild" ]; then
- echo "*** Installing Xcode Tools ..."
- "$DATADIR/installXcode" "$BuildRoot"
- touch "$receipts/xcodebuild"
- fi
-
- if [ "$loadonly" = "YES" ]; then
- exit
- fi
-
-fi
-
-###
-### Read in the environment
-###
-
-version="${project/$projnam-/}"
-build_version=$(($(GetBuildVersion $DARWIN_BUILDROOT/{Logs,Symbols,Headers,Roots}/$projnam/$project.*) + 1))
-
-LOG="$DARWIN_BUILDROOT/Logs/$projnam/$project.log~$build_version"
-TRACELOG="$BuildRoot/private/var/tmp/$projnam/$project.trace~$build_version"
-mkdir -p "$DARWIN_BUILDROOT/Logs/$projnam"
-
-# Hide this variable from the unset
-export -n SRCROOT OBJROOT SYMROOT DSTROOT
-export -n DARWIN_BUILDROOT DARWINBUILD_BUILD DARWINXREF_DB_FILE
-export -n CHROOTED
-
-# Screen sets this to a multi-line value which causes trouble
-unset TERMCAP
-OLDIFS="$IFS"
-IFS=$'\n'
-for X in $(printenv) ; do
- X=${X/=*/}
- eval "unset $X"
-done
-IFS="$OLDIFS"
-
-export SRCROOT OBJROOT SYMROOT DSTROOT
-export DARWIN_BUILDROOT DARWINBUILD_BUILD DARWINXREF_DB_FILE
-export CHROOTED
-
-export PATH=/bin:/sbin:/usr/bin:/usr/sbin/:/usr/local/bin:/usr/local/sbin
-
-# sets the install path to xcode tools if we're chrooted
-if [ "$CHROOTED" == "YES" ]; then
- export DEVELOPER_DIR="/XCD/loper"
-fi
-
-export SHELL="/bin/sh"
-export HOME="/var/root"
-export LOGNAME="root"
-export USER="root"
-export GROUP="wheel"
-
-build_string=""
-if [ "$buildtool" == "xcodebuild" -a "$target" != "" ]; then
- build_string="-target $target"
-elif [ "$target" != "" ]; then
- action="$target"
-fi
-
-###
-### Write out the build script that will be used.
-### This may or may not be executed in a chroot.
-### We want things like the gcc version to be picked
-### up from the chroot.
-###
-
-SCRIPT="$BuildRoot/$vartmp/$projnam/build-$project~$build_version.sh"
-
-cat <<-EOF > $SCRIPT
- #!/bin/sh
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo "BUILDING $project~$build_version on \$(date 2>/dev/null)"
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo 'Build configuration:'
- echo " Build host: \$(hostname 2>/dev/null)"
- echo ' Build tool: $buildtool'
- echo ' Build action: $action'
- echo " Build number: $build"
- echo " Host kernel version: \$(uname -v 2>/dev/null)"
- echo " cc version: \$(gcc -v 2>&1 | tail -n 1 2>/dev/null)"
- # Panther cctools unlinks -o target, so don't use /dev/null
- echo " cctools version: \$(as -v -o /.devnull < /dev/null 2>&1 | cut -c 22- 2>/dev/null)"
-EOF
-if [ "$logdeps" == "YES" ]; then
- if [ "$CHROOTED" == "YES" ]; then
- if [ "$DARWINTRACE" -nt "$BuildRoot/usr/lib/darwintrace.dylib" ]; then
- mkdir -p "$BuildRoot/usr/lib"
- cp "$DARWINTRACE" \
- "$BuildRoot/usr/lib/darwintrace.dylib"
- fi
- echo "export DARWINTRACE_LOG=\"${TRACELOG/$BuildRoot/}\"" >> $SCRIPT
- echo "export DYLD_INSERT_LIBRARIES=/usr/lib/darwintrace.dylib" >> $SCRIPT
- else
- echo "export DARWINTRACE_LOG=\"${TRACELOG}\"" >> $SCRIPT
- echo "export DYLD_INSERT_LIBRARIES=$DARWINTRACE" >> $SCRIPT
- fi
- echo "export DYLD_FORCE_FLAT_NAMESPACE=1" >> $SCRIPT
-fi
-if [ "$buildtool" == "xcodebuild" ]; then
-cat <<-EOF >> $SCRIPT
- echo " xcode version: \$(sh -c \\\"$buildtool -version\\\")"
-EOF
-else
-cat <<-EOF >> $SCRIPT
- echo " make version: \$(sh -c \\\"$buildtool -version\\\" | head -1 2>/dev/null)"
-EOF
-fi
-
-cat <<-EOF >> $SCRIPT
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo 'Build parameters:'
- echo SRCROOT: '$SRCROOT'
- echo OBJROOT: '$OBJROOT'
- echo SYMROOT: '$SYMROOT'
- echo DSTROOT: '$DSTROOT'
-EOF
-###
-### Add in the build environment variables from darwinxref
-###
-build_string="$build_string \"SRCROOT=$SRCROOT\" \"OBJROOT=$OBJROOT\" \"SYMROOT=$SYMROOT\" \"DSTROOT=$DSTROOT\""
-
-XREF_ENV=$($DARWINXREF environment $projnam)
-OLDIFS="$IFS"
-IFS=$'\n'
-for X in \
- "RC_ProjectName=$projnam" \
- "RC_ProjectSourceVersion=$version" \
- "RC_ProjectNameAndSourceVersion=$project" \
- "RC_ProjectBuildVersion=$build_version" \
- $XREF_ENV ; do
- echo "echo '${X/=*/}: ${X/*=/}'" >> $SCRIPT
- eval "export -- \"$X\""
- build_string="$build_string \"$X\""
-done
-IFS="$OLDIFS"
-
-cat <<-EOF >> $SCRIPT
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo 'Environment variables:'
-EOF
-
-OLDIFS="$IFS"
-IFS=$'\n'
-for X in $(printenv | sort) ; do
- echo "echo '$X'" >> $SCRIPT
-done
-IFS="$OLDIFS"
-
-cat <<-EOF >> $SCRIPT
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo 'Installed Roots:'
-EOF
-# I didn't really want to use perl(1) here, but ls(1) doesn't support this.
-# For now, execute this outside the chroot so we don't require perl to be
-# installed in there. This should probably be re-written as a C tool
-# that can be installed into the chroot.
-# Uses tail +3 to avoid getting . and ..
-RECEIPTS=$DARWIN_BUILDROOT/BuildRoot/usr/local/darwinbuild/receipts
-perl -e "opendir(DIR,\"$RECEIPTS\");
- @files = sort(readdir(DIR));
- my %seen;
- foreach my \$x (@files) {
- if ( -l \"$RECEIPTS/\$x\" ) {
- \$seen{readlink(\"$RECEIPTS/\$x\")} = 1;
- }
- }
- foreach my \$x (@files) {
- my \$str = undef;
- if ( -l \"$RECEIPTS/\$x\" ) {
- \$str = sprintf \"%-20s -> %s\", \"\$x\", readlink(\"$RECEIPTS/\$x\");
- } elsif (!exists(\$seen{\$x})) {
- \$str = sprintf \"%-24s%s\", \"\", \"\$x\";
- }
- print \"echo \\\"\$str\\\"\n\" if \$str;
- } closedir(DIR);" | tail +3 >> $SCRIPT
-cat <<-EOF >> $SCRIPT
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo $buildtool $action '$build_string' \< /dev/null
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- echo ''
- echo 'Build log begins here:'
- echo ''
- cd '$SRCROOT'
-EOF
-cat <<-EOF >> $SCRIPT
- if [ -x /bin/date ]; then
- START_DATE=\$(date "+%s")
- fi
- $buildtool $action $build_string < /dev/null
- EXIT_STATUS="\$?"
- if [ -x /bin/date ]; then
- END_DATE=\$(date "+%s")
- ELAPSED_TIME=\$((\$END_DATE - \$START_DATE))
- fi
- echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
- if [ -x /bin/date ]; then
- echo " BUILD TIME: \$((\$ELAPSED_TIME / 3600))h \$((\$ELAPSED_TIME / 60))m \$((\$ELAPSED_TIME % 60))s"
- fi
- echo "EXIT STATUS: \$EXIT_STATUS"
- exit \$EXIT_STATUS
-EOF
-
-chmod ugo+x $SCRIPT
-
-
-ExitHandler() {
- ### Once for fdsec
- [ -z "$(echo $BuildRoot/dev/*)" ] || umount "$BuildRoot/dev"
- ### Twice for devfs
- [ -z "$(echo $BuildRoot/dev/*)" ] || umount "$BuildRoot/dev"
- ### Thrice for volfs
- [ -z "$(echo $BuildRoot/.vol/*)" ] || chroot "$BuildRoot" umount /.vol
-}
-
-
-if [ "$CHROOTED" == "YES" ] ; then
- ###
- ### Mount devfs in the chroot
- ### We'll make /dev/null our de-facto test for the existence of devfs
- ###
- ### Warning:
- ### This must be done *BEFORE* the call to chroot, otherwise there is
- ### no way to unmount the filesystem except rebooting.
- ###
- echo "*** Mounting special filesystems ..."
- trap ExitHandler EXIT
-
- if [ ! -c "$BuildRoot/dev/null" ]; then
- echo "Mounting devfs ..."
- mkdir -p "$BuildRoot/dev"
- mount -t devfs stdin "$BuildRoot/dev"
- mount -t fdesc -o union stdin "$BuildRoot/dev"
- else
- echo "devfs appears to exist ..."
- fi
-
- if [ -x /sbin/mount_volfs ]; then
- # volfs is no longer present (nor needed) on Leopard.
- if [ -z "$(echo $BuildRoot/.vol/*)" ]; then
- echo "Mounting volfs ..."
- [ -d "$BuildRoot/sbin" ] || mkdir -p "$BuildRoot/sbin"
- [ -x "$BuildRoot/sbin/mount_volfs" ] || \
- cp /sbin/mount_volfs "$BuildRoot/sbin/"
- [ -x "$BuildRoot/sbin/umount" ] || \
- cp /sbin/umount "$BuildRoot/sbin/"
- [ -d "$BuildRoot/.vol" ] || mkdir -p "$BuildRoot/.vol"
- ## If the directory is empty, assume volfs not mounted
- chroot "$BuildRoot" /sbin/mount_volfs "/.vol"
- else
- echo "volfs appears to be mounted ..."
- fi
- fi
-
- ###
- ### Actually invoke the build tool here
- ###
- chroot -u root -g wheel $BuildRoot $vartmp/$projnam/build-$project~$build_version.sh 2>&1 | tee -a "$LOG"
- EXIT_STATUS="${PIPESTATUS[0]}"
-
-else
- ###
- ### Actually invoke the build tool here
- ###
- $BuildRoot/$vartmp/$projnam/build-$project~$build_version.sh 2>&1 | tee -a "$LOG"
- EXIT_STATUS="${PIPESTATUS[0]}"
-
- ###
- ### Clean up the logging
- ###
- if [ "$logdeps" == "YES" ]; then
- export -n DYLD_INSERT_LIBRARIES DYLD_FORCE_FLAT_NAMESPACE DARWINTRACE_LOG
- fi
-fi
-
-if [ $EXIT_STATUS -eq 0 ]; then
- IsDirectoryEmpty "$REAL_DSTROOT"
- if [ $? -eq 0 ]; then
- echo "$REAL_DSTROOT is empty. Build verification failed." 1>&2
- EXIT_STATUS=3
- fi
-fi
-
-
-if [ "$EXIT_STATUS" == "0" ]; then
- ###
- ### Building was successful, copy the results out of the
- ### build root and into the Root cache
- ###
-
- if [ "$action" == "installhdrs" ]; then
- ### Output the manifest
- MANIFEST="/tmp/$projnam.$$"
- "$DARWINXREF" register "$projnam" "$REAL_DSTROOT" | tee "$MANIFEST"
- SHA1=$(cat "$MANIFEST" | openssl dgst -sha1)
- mkdir -p "$REAL_DSTROOT/usr/local/darwinbuild/receipts"
- cp "$MANIFEST" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$SHA1"
- ln -s "$SHA1" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$projnam.hdrs"
- rm -f "$MANIFEST"
-
- mkdir -p "$DARWIN_BUILDROOT/Headers/$projnam/$project.hdrs~$build_version"
- ditto "$REAL_DSTROOT" "$DARWIN_BUILDROOT/Headers/$projnam/$project.hdrs~$build_version"
- else
- ### Register the root with the darwinxref database. This will output a manifest
- ### which can be used to uniquely identify the root. Store the unique identifier
- ### in the receipts directory after registration.
- MANIFEST="/tmp/$projnam.$$"
- "$DARWINXREF" register "$projnam" "$REAL_DSTROOT" | tee "$MANIFEST"
- SHA1=$(cat "$MANIFEST" | openssl dgst -sha1)
- mkdir -p "$REAL_DSTROOT/usr/local/darwinbuild/receipts"
- cp "$MANIFEST" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$SHA1"
- ln -s "$SHA1" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$projnam"
- rm -f "$MANIFEST"
-
- mkdir -p "$DARWIN_BUILDROOT/Symbols/$projnam/$project.sym~$build_version"
- mkdir -p "$DARWIN_BUILDROOT/Roots/$projnam/$project.root~$build_version"
- ditto "$REAL_SYMROOT" "$DARWIN_BUILDROOT/Symbols/$projnam/$project.sym~$build_version"
- ditto "$REAL_DSTROOT" "$DARWIN_BUILDROOT/Roots/$projnam/$project.root~$build_version"
-
- if [ "$logdeps" = "YES" ]; then
- ### Log dependencies, but filter out duplicates, relative paths, and temporary files
- TRACE_TYPES='\(execve\|open\|readlink\)[[:space:]]\+'
- cat "$TRACELOG" | sort -u | \
- sed "s|$DARWIN_BUILDROOT/BuildRoot||" | \
- grep -i "^$TRACE_TYPES/" | \
- grep -v "^$TRACE_TYPES/SourceCache/" | \
- grep -vi "^$TRACE_TYPES\(/private\)\?\(/var\)\?/tmp/" | \
- grep -vi "^$TRACE_TYPES/XCD/" | \
- grep -vi "^$TRACE_TYPES/dev/" | \
- sort -u | \
- "$DARWINXREF" loadDeps "$projnam" "$DARWIN_BUILDROOT/BuildRoot"
- "$DARWINXREF" resolveDeps -commit "$projnam"
- cp "$TRACELOG" $DARWIN_BUILDROOT/Logs/$projnam/$project.trace~$build_version
- fi
- fi
-fi
-
-#ExitHandler
-#rm -Rf "${BuildRoot}"/*
-
-exit $EXIT_STATUS
Copied: trunk/darwinbuild/darwinbuild.in (from rev 445, trunk/darwinbuild/darwinbuild)
===================================================================
--- trunk/darwinbuild/darwinbuild.in (rev 0)
+++ trunk/darwinbuild/darwinbuild.in 2008-12-21 08:19:03 UTC (rev 447)
@@ -0,0 +1,895 @@
+#!/bin/sh
+#
+# Copyright (c) 2004-2005, Apple Computer, Inc. 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 of Apple Computer, Inc. ("Apple") nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS 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 APPLE OR ITS 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.
+#
+
+###
+### README
+###
+### This script sets up the proper environment to build Darwin projects
+###
+### Building takes place in the BuildRoot, this should be an HFSX (or UFS)
+### volume (Disk images work well). The BuildRoot location can by specified by
+### the DARWIN_BUILDROOT environment variable. If not set, it will default
+### to the current working directory. However, if the current working directory
+### does not contain a Sources, Roots, Logs, and other necessary directories
+### the script will exit with an error.
+###
+### This script has the ability to build in a changed root. This allows
+### slightly projects to be built for targets that differ from the host
+### system, and also helps prevent against pollution of the host system
+### with intermediate build tools and headers. Unfortunately there are
+### limitations on just how much the changed root can vary from the host
+### system. For example, items in the changed root still need to be
+### compatible with the system daemons that are running (i.e. lookupd)
+### and if devfs or volfs is mounted in the changed root, it will resemble
+### the host system, and not the target system.
+###
+### If the project's version is omitted then the darwinxref tool is consulted.
+### This tool should live in the same directory as this script. darwinxref
+### allows cross-referencing of project versions and system build numbers.
+### If no build number is specified, the host system's build number is used,
+### otherwise the version of the project for the specified build will be built.
+###
+### The script checks its source cache (BuildRoot/Sources) for a .tar.gz archive
+### of the given project-version. If one exists, it is used. If it does not
+### exist, then this script will attempt to use curl(1) to fetch the sources
+### from the darwinsource.opendarwin.org and www.opensource.apple.com sites.
+###
+### If the -chroot option is specified, the script will use the darwinxref tool
+### to populate the build root with the "Roots" necessary to build the project
+### (Roots are pre-compiled projects ready for installation). This script
+### will look for an existing root in the root cache (BuildRoot/Roots). If a
+### root is missing, then this script will attempt to use curl(1) to fetch the
+### roots from the darwinsource.opendarwin.org and www.opensource.apple.com sites.
+###
+### If the specified project requires Xcode to build (i.e. it does not use
+### a makefile, but instead has a .pbproj or .xcode project file), then it
+### must be built on a Mac OS X system, and cannot be built on a Darwin system.
+### Furthermore, because Xcode and many of the frameworks it uses are not open
+### source, it is not distributed on the www.opensource.apple.com or
+### darwinsource.opendarwin.org sites. This script will look for a special
+### Xcode root in the local root cache, and if it doesn't exist, it will attempt
+### to create the root using the Xcode installation on the host system.
+###
+###
+
+PREFIX=%%PREFIX%%
+XREFDB=.build/xref.db
+DARWINXREF=$PREFIX/bin/darwinxref
+DATADIR=$PREFIX/share/darwinbuild
+COMMONFILE=$DATADIR/darwinbuild.common
+DARWINTRACE=$DATADIR/darwintrace.dylib
+DITTO=$DATADIR/ditto
+DEFAULTPLISTSITE=http://svn.macosforge.org/repository/darwinbuild/trunk/plists/
+
+# PREFIX=/Volumes/HD/ltmp/build/darwinbuild
+# DARWINXREF=$PREFIX/darwinxref/darwinxref
+# DATADIR=$PREFIX/darwinbuild
+# COMMONFILE=$DATADIR/darwinbuild.common
+# DARWINTRACE=$PREFIX/darwintrace/darwintrace.dylib
+# DITTO=$DATADIR/ditto.sh
+# DEFAULTPLISTSITE=file:///Volumes/HD/ltmp/build/darwinbuild/plists/
+
+build=""
+depsbuild=""
+CHROOTED="YES"
+logdeps=""
+nopatch=""
+noload=""
+loadonly=""
+projnam=""
+action="install"
+target=""
+version=""
+
+###
+### Include some common subroutines
+###
+
+. "$COMMONFILE"
+
+shopt -s nullglob
+
+###
+### DarwinBuild must be run as root. Enforce this.
+###
+if [ "$EUID" != "0" ]; then
+ echo "Error: DarwinBuild must be run as root." 1>&2
+ exit 1
+fi
+
+###
+### The "-init" command sets up the build environment
+### in the current working directory.
+### EXITs
+###
+if [ "$1" == "-init" ]; then
+ if [ "$2" == "" ]; then
+ echo "usage: $(basename $0) -init <build>" 1>&2
+ exit 1
+ fi
+ build="$2"
+ sites=""
+ [ -d Roots ] || mkdir Roots
+ [ -d Sources ] || mkdir Sources
+ [ -d Symbols ] || mkdir Symbols
+ [ -d Headers ] || mkdir Headers
+ [ -d Logs ] || mkdir Logs
+ [ -d .build ] || mkdir .build
+
+ # check if there's a plist locally by this name
+ if [ -f "$build" ]; then
+ filepath="$build"
+ filename=$(basename "$filepath")
+ build=$(echo "$filename" | sed 's/.plist$//')
+ # since we don't want to download this, copy it
+ cp "$filepath" ".build/$build.plist"
+ fi
+
+ echo "$build" > .build/build
+
+ while [ "$build" != "" ]; do
+ Download .build "$build".plist "$sites ${DEFAULTPLISTSITE}"
+ $DARWINXREF "-f$XREFDB" "-b$build" loadIndex .build/"$build".plist
+ sites=$($DARWINXREF "-f$XREFDB" "-b$build" plist_sites | xargs echo)
+ build=$($DARWINXREF "-f$XREFDB" "-b$build" inherits)
+ done
+ echo "Initialization Complete"
+ exit 0
+fi
+
+
+function PrintUsage() {
+ cat <<-EOF 1>&2
+ usage: $(basename $0) [flags] <project> [<version>]
+ usage: flags: [-headers] [-build=X] [-target=X]
+ [-logdeps] [-nochroot] [-nopatch] [-noload | -loadonly]
+ [-depsbuild=X [-depsbuild=Y]]
+ [-fetch] [-source] [-load]
+EOF
+ exit 1
+}
+
+###
+### Check that we're property situated in an initialized directory
+###
+CheckDarwinBuildRoot
+
+BuildRoot="$DARWIN_BUILDROOT/BuildRoot"
+mkdir -p "$BuildRoot"
+export DARWINXREF_DB_FILE="$DARWIN_BUILDROOT/$XREFDB"
+
+###
+### Check and see wether there is a sources directory set in the
+### environment ($DARWIN_SOURCES). If not we assign it the sources pass
+### in the $DARWIN_BUILDROOT
+###
+
+if [ "$DARWIN_SOURCES" != "" ]; then
+ if [ "${DARWIN_SOURCES:0:1}" != "/" ]; then
+ echo "The DARWIN_SOURCES environment variable must contain" 1>&2
+ echo "an absolute path." 1>&2
+ echo "" 1>&2
+ exit 1
+ else
+ SourceCache="$DARWIN_SOURCES"
+ fi
+else
+ SourceCache="$DARWIN_BUILDROOT/Sources"
+fi
+
+if [ ! -e $SourceCache ]; then
+ mkdir -p "$SourceCache"
+fi
+
+###
+### Interpret our arguments:
+### -headers Do the installhdrs phase, instead of install
+### -fetch Download necessary source and patch files
+### -source Extract, patch, and stage source
+### -nochroot Do not chroot into the BuildRoot when building
+### -load Populate the BuildRoot with one project
+### -nopatch Don't patch sources before building.
+### -noload Don't load dependencies into the chroot.
+### Has no effect if -nochroot is specified.
+### -loadonly Only load dependencies into the chroot, but
+### don't build.
+### -logdeps Do magic to log the build-time dependencies
+### -target=X The makefile or xcode target to build
+### -build=X X is the darwin build number to buld, e.g. 8B15
+### -depsbuild=X X is the darwin build number to populate the BuildRoot
+### <project> The name of the project to build
+### <version> If specified, the version of the project to build
+### this will default to the version associated with the
+### currently running build.
+
+if [ "$DARWINBUILD_BUILD" != "" ]; then
+ build="$DARWINBUILD_BUILD"
+fi
+
+for ARG in "$@"; do
+ if [ "$projnam" == "" ]; then
+ if [ "$ARG" == "-headers" ]; then
+ if [ "$action" == "load" ]; then
+ action="loadhdrs"
+ else
+ action="installhdrs"
+ fi
+ elif [ "$ARG" == "-fetch" ]; then
+ action="fetch"
+ elif [ "$ARG" == "-source" ]; then
+ action="source"
+ elif [ "${ARG/=*/}" == "-target" ]; then
+ target="${ARG/*=/}"
+ elif [ "${ARG/=*/}" == "-build" ]; then
+ build="${ARG/*=/}"
+ elif [ "${ARG/=*/}" == "-depsbuild" ]; then
+ depsbuild="${depsbuild} ${ARG/*=/}"
+ elif [ "$ARG" == "-nochroot" ]; then
+ export CHROOTED="NO"
+ elif [ "$ARG" == "-nopatch" ]; then
+ nopatch="YES"
+ elif [ "$ARG" == "-load" ]; then
+ if [ "$action" == "installhdrs" ]; then
+ action="loadhdrs"
+ else
+ action="load"
+ fi
+ elif [ "$ARG" == "-noload" ]; then
+ noload="YES"
+ elif [ "$ARG" == "-loadonly" ]; then
+ loadonly="YES"
+ elif [ "$ARG" == "-logdeps" ]; then
+ logdeps="YES"
+ elif [ "${ARG:0:1}" != "-" ]; then
+ projnam="$ARG"
+ else
+ PrintUsage "$0"
+ fi
+ elif [ "$version" == "" ]; then
+ version="$ARG"
+ else
+ PrintUsage "$0"
+ fi
+done
+
+if [ "$projnam" == "" -o "${projnam:0:1}" == "-" ]; then
+ PrintUsage "$0"
+fi
+
+###
+### No build number specified. Look in the DARWIN_BUILDROOT for
+### a cached value.
+###
+if [ "$build" == "" -a -f "$DARWIN_BUILDROOT/.build/build" ]; then
+ build="$(cat $DARWIN_BUILDROOT/.build/build)"
+fi
+
+###
+### Still no build number specified. Error.
+###
+if [ "$build" == "" ]; then
+ echo "Error: no build number specified." 2>&1
+ exit 1
+fi
+export DARWINBUILD_BUILD="$build"
+
+###
+### By default, dependencies are taken from the same build,
+### but that can be overridden above.
+###
+if [ "$depsbuild" == "" ]; then
+ depsbuild="$build"
+fi
+
+
+###
+### If we are doing a -load, install the root and exit.
+###
+if [ "$action" == "load" ]; then
+ InstallRoot "$BuildRoot" "$projnam" "$depsbuild"
+ exit 0
+elif [ "$action" == "loadhdrs" ]; then
+ InstallHeader "$BuildRoot" "$projnam" "$depsbuild"
+ exit 0
+fi
+
+#
+# Get the version of the project for this build.
+#
+if [ "$version" == "" ]; then
+ project=$($DARWINXREF version "$projnam")
+ version=${project/$projnam-/}
+else
+ project="$projnam-$version"
+fi
+
+#
+# Check if the project is a build alias.
+#
+alias=$($DARWINXREF original "$projnam")
+
+#
+# Look for an alternate target in the database
+#
+if [ "$target" == "" -a "$action" == "install" ]; then
+ target=$($DARWINXREF target "$projnam")
+fi
+
+#
+# Sanity check to make sure we actually have a project to build.
+#
+if [ "$project" == "" ]; then
+ echo "ERROR: project not found: $projnam" 1>&2
+ exit 1
+fi
+
+
+
+
+
+###
+### Download the sources,
+### and any applicable patches.
+###
+echo "*** Fetching Sources ..."
+# project might be a build alias
+if [ "$alias" != "" ]; then
+ filename="$alias-$version.tar.gz"
+else
+ filename="$project.tar.gz"
+fi
+patchfilenames=$($DARWINXREF patchfiles $projnam)
+#echo "patchfiles are $patchfilenames"
+Download "$SourceCache" "$filename" "$($DARWINXREF source_sites $projnam)"
+for p in $patchfilenames; do
+ Download "$SourceCache" "$p" "$($DARWINXREF source_sites $projnam)"
+done
+
+### If we are doing a -fetch, stop here.
+if [ "$action" == "fetch" ]; then
+ exit
+fi
+
+###
+### We do our building in private/var/tmp since it's
+### likely to be out of the way of our dependencies
+### and is supposed to be writable by everyone.
+###
+
+vartmp="private/var/tmp"
+mkdir -p "$BuildRoot/$vartmp"
+chmod 1777 "$BuildRoot/$vartmp"
+
+###
+### Define the SRCROOT, OBJROOT, SYMROOT, and DSTROOT.
+### This script refers to the absolute paths of the build
+### directory, and should use REAL_SRCROOT, etc.
+### If CHROOTED, then the environment variables will have
+### the BuildRoot prefix omitted because the chroot
+### will make all paths relative to that point.
+###
+REAL_SRCROOT="$BuildRoot/SourceCache/$projnam/$project"
+REAL_OBJROOT="$BuildRoot/$vartmp/$projnam/$project.obj"
+REAL_SYMROOT="$BuildRoot/$vartmp/$projnam/$project.sym"
+REAL_DSTROOT="$BuildRoot/$vartmp/$projnam/$project.root"
+if [ "$CHROOTED" == "YES" ]; then
+ prefix="$BuildRoot"
+else
+ prefix=""
+fi
+export SRCROOT="${REAL_SRCROOT/$prefix/}"
+export OBJROOT="${REAL_OBJROOT/$prefix/}"
+export SYMROOT="${REAL_SYMROOT/$prefix/}"
+export DSTROOT="${REAL_DSTROOT/$prefix/}"
+
+###
+### Remove any pre-existing directories that might be in the way
+### and create new directories in their place. Make sure the
+### directories have root:wheel ownership, otherwise things may
+### not build correctly.
+###
+rm -Rf "$REAL_SRCROOT" "$REAL_OBJROOT" "$REAL_SYMROOT" "$REAL_DSTROOT"
+mkdir -p "$REAL_SRCROOT" "$REAL_OBJROOT" "$REAL_SYMROOT" "$REAL_DSTROOT"
+chown root:wheel "$REAL_SRCROOT" "$REAL_OBJROOT" "$REAL_SYMROOT" "$REAL_DSTROOT"
+
+###
+### Install the sources and patches into the BuildRoot
+###
+cd "$REAL_SRCROOT/.."
+echo "*** Copying Sources ..."
+if [ -d "$SourceCache/$project" ]; then
+ tar c -C "$SourceCache" "$project" | tar xf -
+elif [ "$alias" != "" -a -d "$SourceCache/$alias-$version" ]; then
+ tar c -C "$SourceCache" "$alias-$version" | tar xf -
+ rmdir "$REAL_SRCROOT"
+ ln -fhs "$alias-$version" "$project"
+elif [ "$alias" != "" ]; then
+ tar xzf "$SourceCache/$alias-$version.tar.gz"
+ rmdir "$REAL_SRCROOT"
+ ln -fhs "$alias-$version" "$project"
+else
+ tar xzf "$SourceCache/$filename"
+fi
+
+# you can avoid registering patches in the DB by using "xnu-792--patches.tar.gz"
+if [ -r "$SourceCache/$project-patches.tar.gz" ]; then
+ tar xzf "$SourceCache/$project-patches.tar.gz"
+fi
+
+###
+### Apply the patches
+### Current working directory should be the SRCROOT
+###
+cd "$REAL_SRCROOT"
+if [ "$nopatch" != "YES" ]; then
+if [ -d "$REAL_SRCROOT/../$project-patches" ]; then
+ echo "*** Applying Patches ..."
+ cat $REAL_SRCROOT/../$project-patches/* | patch -p0
+fi
+for patchfile in $patchfilenames; do
+ echo "*** Applying Patch $patchfile ..."
+ if [ -r "$SourceCache/$patchfile" ]; then
+ catprog=""
+ case $patchfile in
+ *.gz)
+ catprog="gzip -d -c"
+ ;;
+ *.bz2)
+ catprog="bzip2 -d -c"
+ ;;
+ *)
+ catprog="cat"
+ ;;
+ esac
+ case $patchfile in
+ *.p1.patch*)
+ $catprog "$SourceCache/$patchfile" | patch -l -f -p1
+ ;;
+ *.patch*)
+ $catprog "$SourceCache/$patchfile" | patch -l -f -p0
+ ;;
+ *.add*)
+ newfile=`echo $patchfile | sed -e 's/^.*-\([^-]*\)\.add.*/\1/' -e 's,_,/,g'`
+ $catprog "$SourceCache/$patchfile" > "./$newfile"
+ ;;
+ *)
+ echo "Don't know how to apply $patchfile"
+ ;;
+ esac
+ fi
+done
+fi
+
+### If we are doing a -source, stop here.
+if [ "$action" == "source" ]; then
+ exit
+fi
+
+###
+### Look for the build tool: make, xcodebuild
+###
+
+numfiles=$(echo *.pbxproj *.pbproj *.xcode *.xcodeproj 2> /dev/null )
+if [ -n "$numfiles" ]; then
+ buildtool="xcodebuild"
+else
+ buildtool="make"
+fi
+
+###
+### If we are CHROOTED, then
+### Install the roots into the BuildRoot
+### Make sure we have at least a minimally functioning root
+### by installing bash and its dependencies.
+###
+### Also install CoreOSMakefiles and Perl for make based projects
+###
+if [ "$CHROOTED" == "YES" -a "$noload" != "YES" ]; then
+ echo "*** Installing Roots ..."
+ receipts="$BuildRoot/usr/local/darwinbuild/receipts"
+ mkdir -p "$receipts"
+ bash_deps=$($DARWINXREF dependencies -run "bash")
+ deps=$($DARWINXREF dependencies -build "$projnam")
+
+ for X in files bash $bash_deps $deps ; do
+ InstallRoot "$BuildRoot" "$X" "$depsbuild"
+ done
+
+ ### so many things require ditto, we have hacked around it
+ if [ ! -x "$BuildRoot/usr/bin/ditto" ]; then
+ cp "$DITTO" "$BuildRoot/usr/bin/ditto"
+ fi
+
+ ### need dsymutil but it depends on libauto so disable for now
+ if [ ! -x "$BuildRoot/usr/bin/dsymutil" ]; then
+ cp "/usr/bin/dsymutil" "$BuildRoot/usr/bin/dsymutil"
+ fi
+
+ ### CoreOSMakefiles
+ if [ ! -d "$BuildRoot/Developer/Makefiles/CoreOS" ]; then
+ InstallRoot "$BuildRoot" "CoreOSMakefiles" "$depsbuild"
+ fi
+
+ ### Perl
+ if [ ! -x "$BuildRoot/usr/bin/perl" ]; then
+ InstallRoot "$BuildRoot" "perl" "$depsbuild"
+ fi
+
+ echo "*** Installing Headers ..."
+ deps=$($DARWINXREF dependencies -header "$projnam")
+ for X in $deps ; do
+ InstallHeader "$BuildRoot" "$X" "$depsbuild"
+# InstallRoot "$BuildRoot" "$X" "$depsbuild"
+ done
+
+ ### xcodebuild is a special case because it is not open source
+ ### we try to install it from the host Mac OS X system if it is required
+ if [ "$buildtool" == "xcodebuild" -a ! -f "$receipts/xcodebuild" ]; then
+ echo "*** Installing Xcode Tools ..."
+ "$DATADIR/installXcode" "$BuildRoot"
+ touch "$receipts/xcodebuild"
+ fi
+
+ if [ "$loadonly" = "YES" ]; then
+ exit
+ fi
+
+fi
+
+###
+### Read in the environment
+###
+
+version="${project/$projnam-/}"
+build_version=$(($(GetBuildVersion $DARWIN_BUILDROOT/{Logs,Symbols,Headers,Roots}/$projnam/$project.*) + 1))
+
+LOG="$DARWIN_BUILDROOT/Logs/$projnam/$project.log~$build_version"
+TRACELOG="$BuildRoot/private/var/tmp/$projnam/$project.trace~$build_version"
+mkdir -p "$DARWIN_BUILDROOT/Logs/$projnam"
+
+# Hide this variable from the unset
+export -n SRCROOT OBJROOT SYMROOT DSTROOT
+export -n DARWIN_BUILDROOT DARWINBUILD_BUILD DARWINXREF_DB_FILE
+export -n CHROOTED
+
+# Screen sets this to a multi-line value which causes trouble
+unset TERMCAP
+OLDIFS="$IFS"
+IFS=$'\n'
+for X in $(printenv) ; do
+ X=${X/=*/}
+ eval "unset $X"
+done
+IFS="$OLDIFS"
+
+export SRCROOT OBJROOT SYMROOT DSTROOT
+export DARWIN_BUILDROOT DARWINBUILD_BUILD DARWINXREF_DB_FILE
+export CHROOTED
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin/:/usr/local/bin:/usr/local/sbin
+
+# sets the install path to xcode tools if we're chrooted
+if [ "$CHROOTED" == "YES" ]; then
+ export DEVELOPER_DIR="/XCD/loper"
+fi
+
+export SHELL="/bin/sh"
+export HOME="/var/root"
+export LOGNAME="root"
+export USER="root"
+export GROUP="wheel"
+
+build_string=""
+if [ "$buildtool" == "xcodebuild" -a "$target" != "" ]; then
+ build_string="-target $target"
+elif [ "$target" != "" ]; then
+ action="$target"
+fi
+
+###
+### Write out the build script that will be used.
+### This may or may not be executed in a chroot.
+### We want things like the gcc version to be picked
+### up from the chroot.
+###
+
+SCRIPT="$BuildRoot/$vartmp/$projnam/build-$project~$build_version.sh"
+
+cat <<-EOF > $SCRIPT
+ #!/bin/sh
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo "BUILDING $project~$build_version on \$(date 2>/dev/null)"
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo 'Build configuration:'
+ echo " Build host: \$(hostname 2>/dev/null)"
+ echo ' Build tool: $buildtool'
+ echo ' Build action: $action'
+ echo " Build number: $build"
+ echo " Host kernel version: \$(uname -v 2>/dev/null)"
+ echo " cc version: \$(gcc -v 2>&1 | tail -n 1 2>/dev/null)"
+ # Panther cctools unlinks -o target, so don't use /dev/null
+ echo " cctools version: \$(as -v -o /.devnull < /dev/null 2>&1 | cut -c 22- 2>/dev/null)"
+EOF
+if [ "$logdeps" == "YES" ]; then
+ if [ "$CHROOTED" == "YES" ]; then
+ if [ "$DARWINTRACE" -nt "$BuildRoot/usr/lib/darwintrace.dylib" ]; then
+ mkdir -p "$BuildRoot/usr/lib"
+ cp "$DARWINTRACE" \
+ "$BuildRoot/usr/lib/darwintrace.dylib"
+ fi
+ echo "export DARWINTRACE_LOG=\"${TRACELOG/$BuildRoot/}\"" >> $SCRIPT
+ echo "export DYLD_INSERT_LIBRARIES=/usr/lib/darwintrace.dylib" >> $SCRIPT
+ else
+ echo "export DARWINTRACE_LOG=\"${TRACELOG}\"" >> $SCRIPT
+ echo "export DYLD_INSERT_LIBRARIES=$DARWINTRACE" >> $SCRIPT
+ fi
+ echo "export DYLD_FORCE_FLAT_NAMESPACE=1" >> $SCRIPT
+fi
+if [ "$buildtool" == "xcodebuild" ]; then
+cat <<-EOF >> $SCRIPT
+ echo " xcode version: \$(sh -c \\\"$buildtool -version\\\")"
+EOF
+else
+cat <<-EOF >> $SCRIPT
+ echo " make version: \$(sh -c \\\"$buildtool -version\\\" | head -1 2>/dev/null)"
+EOF
+fi
+
+cat <<-EOF >> $SCRIPT
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo 'Build parameters:'
+ echo SRCROOT: '$SRCROOT'
+ echo OBJROOT: '$OBJROOT'
+ echo SYMROOT: '$SYMROOT'
+ echo DSTROOT: '$DSTROOT'
+EOF
+###
+### Add in the build environment variables from darwinxref
+###
+build_string="$build_string \"SRCROOT=$SRCROOT\" \"OBJROOT=$OBJROOT\" \"SYMROOT=$SYMROOT\" \"DSTROOT=$DSTROOT\""
+
+XREF_ENV=$($DARWINXREF environment $projnam)
+OLDIFS="$IFS"
+IFS=$'\n'
+for X in \
+ "RC_ProjectName=$projnam" \
+ "RC_ProjectSourceVersion=$version" \
+ "RC_ProjectNameAndSourceVersion=$project" \
+ "RC_ProjectBuildVersion=$build_version" \
+ $XREF_ENV ; do
+ echo "echo '${X/=*/}: ${X/*=/}'" >> $SCRIPT
+ eval "export -- \"$X\""
+ build_string="$build_string \"$X\""
+done
+IFS="$OLDIFS"
+
+cat <<-EOF >> $SCRIPT
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo 'Environment variables:'
+EOF
+
+OLDIFS="$IFS"
+IFS=$'\n'
+for X in $(printenv | sort) ; do
+ echo "echo '$X'" >> $SCRIPT
+done
+IFS="$OLDIFS"
+
+cat <<-EOF >> $SCRIPT
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo 'Installed Roots:'
+EOF
+# I didn't really want to use perl(1) here, but ls(1) doesn't support this.
+# For now, execute this outside the chroot so we don't require perl to be
+# installed in there. This should probably be re-written as a C tool
+# that can be installed into the chroot.
+# Uses tail +3 to avoid getting . and ..
+RECEIPTS=$DARWIN_BUILDROOT/BuildRoot/usr/local/darwinbuild/receipts
+perl -e "opendir(DIR,\"$RECEIPTS\");
+ @files = sort(readdir(DIR));
+ my %seen;
+ foreach my \$x (@files) {
+ if ( -l \"$RECEIPTS/\$x\" ) {
+ \$seen{readlink(\"$RECEIPTS/\$x\")} = 1;
+ }
+ }
+ foreach my \$x (@files) {
+ my \$str = undef;
+ if ( -l \"$RECEIPTS/\$x\" ) {
+ \$str = sprintf \"%-20s -> %s\", \"\$x\", readlink(\"$RECEIPTS/\$x\");
+ } elsif (!exists(\$seen{\$x})) {
+ \$str = sprintf \"%-24s%s\", \"\", \"\$x\";
+ }
+ print \"echo \\\"\$str\\\"\n\" if \$str;
+ } closedir(DIR);" | tail +3 >> $SCRIPT
+cat <<-EOF >> $SCRIPT
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo $buildtool $action '$build_string' \< /dev/null
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ echo ''
+ echo 'Build log begins here:'
+ echo ''
+ cd '$SRCROOT'
+EOF
+cat <<-EOF >> $SCRIPT
+ if [ -x /bin/date ]; then
+ START_DATE=\$(date "+%s")
+ fi
+ $buildtool $action $build_string < /dev/null
+ EXIT_STATUS="\$?"
+ if [ -x /bin/date ]; then
+ END_DATE=\$(date "+%s")
+ ELAPSED_TIME=\$((\$END_DATE - \$START_DATE))
+ fi
+ echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
+ if [ -x /bin/date ]; then
+ echo " BUILD TIME: \$((\$ELAPSED_TIME / 3600))h \$((\$ELAPSED_TIME / 60))m \$((\$ELAPSED_TIME % 60))s"
+ fi
+ echo "EXIT STATUS: \$EXIT_STATUS"
+ exit \$EXIT_STATUS
+EOF
+
+chmod ugo+x $SCRIPT
+
+
+ExitHandler() {
+ ### Once for fdsec
+ [ -z "$(echo $BuildRoot/dev/*)" ] || umount "$BuildRoot/dev"
+ ### Twice for devfs
+ [ -z "$(echo $BuildRoot/dev/*)" ] || umount "$BuildRoot/dev"
+ ### Thrice for volfs
+ [ -z "$(echo $BuildRoot/.vol/*)" ] || chroot "$BuildRoot" umount /.vol
+}
+
+
+if [ "$CHROOTED" == "YES" ] ; then
+ ###
+ ### Mount devfs in the chroot
+ ### We'll make /dev/null our de-facto test for the existence of devfs
+ ###
+ ### Warning:
+ ### This must be done *BEFORE* the call to chroot, otherwise there is
+ ### no way to unmount the filesystem except rebooting.
+ ###
+ echo "*** Mounting special filesystems ..."
+ trap ExitHandler EXIT
+
+ if [ ! -c "$BuildRoot/dev/null" ]; then
+ echo "Mounting devfs ..."
+ mkdir -p "$BuildRoot/dev"
+ mount -t devfs stdin "$BuildRoot/dev"
+ mount -t fdesc -o union stdin "$BuildRoot/dev"
+ else
+ echo "devfs appears to exist ..."
+ fi
+
+ if [ -x /sbin/mount_volfs ]; then
+ # volfs is no longer present (nor needed) on Leopard.
+ if [ -z "$(echo $BuildRoot/.vol/*)" ]; then
+ echo "Mounting volfs ..."
+ [ -d "$BuildRoot/sbin" ] || mkdir -p "$BuildRoot/sbin"
+ [ -x "$BuildRoot/sbin/mount_volfs" ] || \
+ cp /sbin/mount_volfs "$BuildRoot/sbin/"
+ [ -x "$BuildRoot/sbin/umount" ] || \
+ cp /sbin/umount "$BuildRoot/sbin/"
+ [ -d "$BuildRoot/.vol" ] || mkdir -p "$BuildRoot/.vol"
+ ## If the directory is empty, assume volfs not mounted
+ chroot "$BuildRoot" /sbin/mount_volfs "/.vol"
+ else
+ echo "volfs appears to be mounted ..."
+ fi
+ fi
+
+ ###
+ ### Actually invoke the build tool here
+ ###
+ chroot -u root -g wheel $BuildRoot $vartmp/$projnam/build-$project~$build_version.sh 2>&1 | tee -a "$LOG"
+ EXIT_STATUS="${PIPESTATUS[0]}"
+
+else
+ ###
+ ### Actually invoke the build tool here
+ ###
+ $BuildRoot/$vartmp/$projnam/build-$project~$build_version.sh 2>&1 | tee -a "$LOG"
+ EXIT_STATUS="${PIPESTATUS[0]}"
+
+ ###
+ ### Clean up the logging
+ ###
+ if [ "$logdeps" == "YES" ]; then
+ export -n DYLD_INSERT_LIBRARIES DYLD_FORCE_FLAT_NAMESPACE DARWINTRACE_LOG
+ fi
+fi
+
+if [ $EXIT_STATUS -eq 0 ]; then
+ IsDirectoryEmpty "$REAL_DSTROOT"
+ if [ $? -eq 0 ]; then
+ echo "$REAL_DSTROOT is empty. Build verification failed." 1>&2
+ EXIT_STATUS=3
+ fi
+fi
+
+
+if [ "$EXIT_STATUS" == "0" ]; then
+ ###
+ ### Building was successful, copy the results out of the
+ ### build root and into the Root cache
+ ###
+
+ if [ "$action" == "installhdrs" ]; then
+ ### Output the manifest
+ MANIFEST="/tmp/$projnam.$$"
+ "$DARWINXREF" register "$projnam" "$REAL_DSTROOT" | tee "$MANIFEST"
+ SHA1=$(cat "$MANIFEST" | openssl dgst -sha1)
+ mkdir -p "$REAL_DSTROOT/usr/local/darwinbuild/receipts"
+ cp "$MANIFEST" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$SHA1"
+ ln -s "$SHA1" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$projnam.hdrs"
+ rm -f "$MANIFEST"
+
+ mkdir -p "$DARWIN_BUILDROOT/Headers/$projnam/$project.hdrs~$build_version"
+ ditto "$REAL_DSTROOT" "$DARWIN_BUILDROOT/Headers/$projnam/$project.hdrs~$build_version"
+ else
+ ### Register the root with the darwinxref database. This will output a manifest
+ ### which can be used to uniquely identify the root. Store the unique identifier
+ ### in the receipts directory after registration.
+ MANIFEST="/tmp/$projnam.$$"
+ "$DARWINXREF" register "$projnam" "$REAL_DSTROOT" | tee "$MANIFEST"
+ SHA1=$(cat "$MANIFEST" | openssl dgst -sha1)
+ mkdir -p "$REAL_DSTROOT/usr/local/darwinbuild/receipts"
+ cp "$MANIFEST" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$SHA1"
+ ln -s "$SHA1" "$REAL_DSTROOT/usr/local/darwinbuild/receipts/$projnam"
+ rm -f "$MANIFEST"
+
+ mkdir -p "$DARWIN_BUILDROOT/Symbols/$projnam/$project.sym~$build_version"
+ mkdir -p "$DARWIN_BUILDROOT/Roots/$projnam/$project.root~$build_version"
+ ditto "$REAL_SYMROOT" "$DARWIN_BUILDROOT/Symbols/$projnam/$project.sym~$build_version"
+ ditto "$REAL_DSTROOT" "$DARWIN_BUILDROOT/Roots/$projnam/$project.root~$build_version"
+
+ if [ "$logdeps" = "YES" ]; then
+ ### Log dependencies, but filter out duplicates, relative paths, and temporary files
+ TRACE_TYPES='\(execve\|open\|readlink\)[[:space:]]\+'
+ cat "$TRACELOG" | sort -u | \
+ sed "s|$DARWIN_BUILDROOT/BuildRoot||" | \
+ grep -i "^$TRACE_TYPES/" | \
+ grep -v "^$TRACE_TYPES/SourceCache/" | \
+ grep -vi "^$TRACE_TYPES\(/private\)\?\(/var\)\?/tmp/" | \
+ grep -vi "^$TRACE_TYPES/XCD/" | \
+ grep -vi "^$TRACE_TYPES/dev/" | \
+ sort -u | \
+ "$DARWINXREF" loadDeps "$projnam" "$DARWIN_BUILDROOT/BuildRoot"
+ "$DARWINXREF" resolveDeps -commit "$projnam"
+ cp "$TRACELOG" $DARWIN_BUILDROOT/Logs/$projnam/$project.trace~$build_version
+ fi
+ fi
+fi
+
+#ExitHandler
+#rm -Rf "${BuildRoot}"/*
+
+exit $EXIT_STATUS
Property changes on: trunk/darwinbuild/darwinbuild.in
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+ /branches/PR-4841388/darwinbuild/darwinbuild:399-419
/branches/PR-6358021/darwinbuild/darwinbuild:442-443
/branches/PR-6392966/darwinbuild/darwinbuild:423-427
/branches/PR-6398060/darwinbuild/darwinbuild:433-434
/trunk/darwinbuild/darwinbuild:432-434
Added: svn:eol-style
+ native
Deleted: trunk/darwinbuild/darwinmaster.sh
===================================================================
--- trunk/darwinbuild/darwinmaster.sh 2008-12-21 00:09:50 UTC (rev 446)
+++ trunk/darwinbuild/darwinmaster.sh 2008-12-21 08:19:03 UTC (rev 447)
@@ -1,296 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005, Apple Computer, Inc. All rights reserved.
-#
-# @APPLE_BSD_LICENSE_HEADER_START@
-#
-# 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 of Apple Computer, Inc. ("Apple") nor the names of
-# its contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
-# ANY EXPRESS 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 APPLE OR ITS 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.
-#
-# @APPLE_BSD_LICENSE_HEADER_END@
-#
-# Kevin Van Vechten <kvv at apple.com>
-#
-# ISO generation adapted from buildcd.sh by:
-#
-# Shantonu Sen <ssen at opendarwin.org>
-# Felix Kronlage <fkr at opendarwin.org>
-# Chuck Remes <cremes at opendarwin.org>
-
-function PrintUsage() {
- cat 1>&2 <<- EOB
-usage: $(basename "$0") [-arch=arch] <volname>
- arch = {ppc, i386}
-EOB
- exit 1
-}
-
-for ARG in "$@"; do
- if [ "$VOLNAME" == "" ]; then
- if [ "${ARG/=*/}" == "-arch" ]; then
- ARCH="${ARCH/*=/}"
- elif [ "${ARG:0:1}" != "-" ]; then
- VOLNAME="$ARG"
- else
- PrintUsage "$0"
- fi
- else
- PrintUsage "$0"
- fi
-done
-
-if [ "$ARCH" != "" -a "$ARCH" != "ppc" -a "$ARCH" != "i386" \
- -o "$VOLNAME" == "" ]; then
- PrintUsage "$0"
-fi
-
-PREFIX=/usr/local
-XREFDB=.build/xref.db
-DARWINXREF=$PREFIX/bin/darwinxref
-DATADIR=$PREFIX/share/darwinbuild
-COMMONFILE=$DATADIR/darwinbuild.common
-
-###
-### Include some common subroutines
-###
-. "$COMMONFILE"
-
-shopt -s nullglob
-
-###
-### Check that we're property situated in an initialized directory
-###
-CheckDarwinBuildRoot
-
-DMG="/tmp/$VOLNAME.dmg"
-CDR="/tmp/$VOLNAME.cdr"
-ISO="/tmp/$VOLNAME.iso"
-PKGDIR="$DARWIN_BUILDROOT/Packages"
-MKISOFS="/opt/local/bin/mkisofs"
-SIZE="650m"
-if [ ! -z "$ARCH" ]; then
- ARCHSFX="_$ARCH"
-else
- ARCHSFX=""
-fi
-
-export DARWINXREF_DB_FILE="$DARWIN_BUILDROOT/$XREFDB"
-
-###
-### Must be run as root. Enforce this.
-###
-if [ "$EUID" != "0" ]; then
- echo "Error: $(basename $0) must be run as root." 1>&2
- exit 1
-fi
-
-###
-### Look for a build number
-###
-if [ "$DARWINBUILD_BUILD" != "" ]; then
- build="$DARWINBUILD_BUILD"
-fi
-
-###
-### No build number specified. Look in the DARWIN_BUILDROOT for
-### a cached value.
-###
-if [ "$build" == "" -a -f "$DARWIN_BUILDROOT/.build/build" ]; then
- build="$(cat $DARWIN_BUILDROOT/.build/build)"
-fi
-
-###
-### Still no build number specified. Error.
-###
-if [ "$build" == "" ]; then
- echo "Error: no build number specified." 2>&1
- exit 1
-fi
-export DARWINBUILD_BUILD="$build"
-
-
-
-###
-### Update binary packages
-###
-"$DATADIR/packageRoots"
-
-###
-### Update thin packages
-###
-if [ ! -z "$ARCH" ]; then
- "$DATADIR/thinPackages" "$ARCH"
-fi
-
-
-###
-### Mount a disk image, create if necessary
-###
-if [ ! -f "$DMG" ]; then
- hdiutil create "$DMG" \
- -size "$SIZE" \
- -layout SPUD \
- -fs HFS+ \
- -volname "$VOLNAME"
-fi
-DESTDIR=$(hdiutil attach "$DMG" \
- -readwrite \
- -owners on | tail -1 | awk '{print $3}')
-
-###
-### Copy roots necessary for booting / installation onto disk image
-###
-cd "$DESTDIR" || exit
-chown root:admin "$DESTDIR"
-chmod 1775 "$DESTDIR"
-
-echo "Installing Roots ..."
-for Project in $("$DARWINXREF" group boot) ; do
- InstallRoot "$DESTDIR" "$Project" "$build"
-done
-
-###
-### Generate the mkext cache
-###
-echo "Generating MKext ..."
-
-export TMPDIR="$DESTDIR/private/tmp"
-if [ -z "$ARCH" ]; then
- KEXTARCH="-a ppc -a i386"
-else
- KEXTARCH="-a $ARCH"
-fi
-kextcache $KEXTARCH -k -K "$DESTDIR/mach_kernel" -m "$DESTDIR/System/Library/Extensions.mkext" "$DESTDIR/System/Library/Extensions"
-export -n TMPDIR
-
-###
-### Remove extraneous files
-###
-echo "Pruning ..."
-find "$DESTDIR" -type f \( -name '*.[ch]' -or -name '*.cp' -or -name '*.cpp' \) -print -exec rm -f {} ';'
-rm -Rf "$DESTDIR/AppleInternal"
-rm -Rf "$DESTDIR/Developer"
-rm -Rf "$DESTDIR/usr/local"
-rm -Rf "$DESTDIR/usr/share/doc"
-rm -Rf "$DESTDIR"/usr/share/man/man3/*
-
-###
-### Modify the root password to blank
-###
-echo "Modifying Root Password ..."
-nicl -raw "$DESTDIR/var/db/netinfo/local.nidb" -create /users/root passwd ''
-
-###
-### Copy installation packages
-###
-mkdir -p "$DESTDIR/System/Installation/BinaryDrivers${ARCHSFX}"
-echo "Copying binary drivers ..."
-for X in $DARWIN_BUILDROOT/BinaryDrivers${ARCHSFX}/*-*.tar.bz2 ; do
- Y="$DESTDIR"/System/Installation/BinaryDrivers${ARCHSFX}/$(basename $X)
- if [ $X -nt $Y ]; then
- cp $X $Y
- fi
-done
-
-echo "Copying packages ..."
-mkdir -p "$DESTDIR"/System/Installation/Packages${ARCHSFX}
-for X in $DARWIN_BUILDROOT/Packages${ARCHSFX}/*-*.tar.bz2 ; do
- f=$(basename $X)
- if [ "${f/-*/}" != "DarwinInstaller" ]; then
- Y="$DESTDIR"/System/Installation/Packages${ARCHSFX}/$(basename $X)
- if [ $X -nt $Y ]; then
- echo $f
- cp $X $Y
- fi
- fi
-done
-
-###
-### Architecture-specific boot setup
-###
-if [ "$ARCH" == "ppc" ]; then
- ###
- ### Bless the volume for powerpc booting
- ###
- echo "Blessing Volume ..."
- bless --verbose \
- --label "$VOLNAME" \
- --folder "$DESTDIR/System/Library/CoreServices" \
- --bootinfo "$DESTDIR/usr/standalone/ppc/bootx.bootinfo"
-
- ### Generate CDR image
- rm -f "$CDR"
- hdiutil convert \
- "$DMG" \
- -format UDTO \
- -o "$CDR"
-
-
-elif [ "$ARCH" == "i386" -o -z "$ARCH" ]; then
- ###
- ### Create a bootable ISO filesystem
- ###
- ditto "$DESTDIR/usr/standalone/i386" /tmp/i386
- rm -f "$ISO.boot"
- $MKISOFS -R \
- -V "$VOLNAME" \
- -no-emul-boot \
- -T \
- -J \
- -c boot.cat \
- -b cdboot \
- -hide-joliet-trans-tbl \
- -quiet \
- -o "$ISO.boot" \
- /tmp/i386
- SECTORS=$(du "$ISO.boot" | tail -1 | awk '{print $1}')
-
- ###
- ### Create a hybrid image
- ###
- rm -f "$ISO.dmg"
- hdiutil create "$ISO.dmg" -size "$SIZE" -layout NONE
- DEV=$(hdid -nomount "$ISO.dmg" | tail -1 | awk '{print $1}')
- RDEV=$(echo $DEV | sed s/disk/rdisk/)
-
- pdisk "$RDEV" -initialize
- BLOCKS=$(pdisk "$RDEV" -dump | grep 2: | awk -F" " '{print $4}')
-
- pdisk "$RDEV" -createPartition "$VOLNAME" Apple_HFS $SECTORS $(($BLOCKS - $SECTORS))
- SLICE=$(pdisk "$RDEV" -dump | grep "$VOLNAME" | awk -F: '{print $1}' | awk -F" " '{print $1}')
-
- ### Copy ISO boot data onto the disk image
- dd if="$ISO.boot" of="$RDEV" skip=64 seek=64 bs=512
-
- newfs_hfs -v "$VOLNAME" "${RDEV}s${SLICE}"
- mkdir -p /mnt
- mount -t hfs -o perm "${DEV}s${SLICE}" /mnt
- ditto -rsrc "$DESTDIR" /mnt
- bless -folder /mnt/System/Library/CoreServices \
- -bootinfo /mnt/usr/standalone/ppc/bootx.bootinfo \
- -label "$VOLNAME"
- umount /mnt
- hdiutil eject "$DEV"
- mv "$ISO.dmg" "$ISO"
-fi
Copied: trunk/darwinbuild/darwinmaster.sh.in (from rev 445, trunk/darwinbuild/darwinmaster.sh)
===================================================================
--- trunk/darwinbuild/darwinmaster.sh.in (rev 0)
+++ trunk/darwinbuild/darwinmaster.sh.in 2008-12-21 08:19:03 UTC (rev 447)
@@ -0,0 +1,296 @@
+#!/bin/sh
+#
+# Copyright (c) 2005, Apple Computer, Inc. All rights reserved.
+#
+# @APPLE_BSD_LICENSE_HEADER_START@
+#
+# 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 of Apple Computer, Inc. ("Apple") nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS 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 APPLE OR ITS 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.
+#
+# @APPLE_BSD_LICENSE_HEADER_END@
+#
+# Kevin Van Vechten <kvv at apple.com>
+#
+# ISO generation adapted from buildcd.sh by:
+#
+# Shantonu Sen <ssen at opendarwin.org>
+# Felix Kronlage <fkr at opendarwin.org>
+# Chuck Remes <cremes at opendarwin.org>
+
+function PrintUsage() {
+ cat 1>&2 <<- EOB
+usage: $(basename "$0") [-arch=arch] <volname>
+ arch = {ppc, i386}
+EOB
+ exit 1
+}
+
+for ARG in "$@"; do
+ if [ "$VOLNAME" == "" ]; then
+ if [ "${ARG/=*/}" == "-arch" ]; then
+ ARCH="${ARCH/*=/}"
+ elif [ "${ARG:0:1}" != "-" ]; then
+ VOLNAME="$ARG"
+ else
+ PrintUsage "$0"
+ fi
+ else
+ PrintUsage "$0"
+ fi
+done
+
+if [ "$ARCH" != "" -a "$ARCH" != "ppc" -a "$ARCH" != "i386" \
+ -o "$VOLNAME" == "" ]; then
+ PrintUsage "$0"
+fi
+
+PREFIX=%%PREFIX%%
+XREFDB=.build/xref.db
+DARWINXREF=$PREFIX/bin/darwinxref
+DATADIR=$PREFIX/share/darwinbuild
+COMMONFILE=$DATADIR/darwinbuild.common
+
+###
+### Include some common subroutines
+###
+. "$COMMONFILE"
+
+shopt -s nullglob
+
+###
+### Check that we're property situated in an initialized directory
+###
+CheckDarwinBuildRoot
+
+DMG="/tmp/$VOLNAME.dmg"
+CDR="/tmp/$VOLNAME.cdr"
+ISO="/tmp/$VOLNAME.iso"
+PKGDIR="$DARWIN_BUILDROOT/Packages"
+MKISOFS="/opt/local/bin/mkisofs"
+SIZE="650m"
+if [ ! -z "$ARCH" ]; then
+ ARCHSFX="_$ARCH"
+else
+ ARCHSFX=""
+fi
+
+export DARWINXREF_DB_FILE="$DARWIN_BUILDROOT/$XREFDB"
+
+###
+### Must be run as root. Enforce this.
+###
+if [ "$EUID" != "0" ]; then
+ echo "Error: $(basename $0) must be run as root." 1>&2
+ exit 1
+fi
+
+###
+### Look for a build number
+###
+if [ "$DARWINBUILD_BUILD" != "" ]; then
+ build="$DARWINBUILD_BUILD"
+fi
+
+###
+### No build number specified. Look in the DARWIN_BUILDROOT for
+### a cached value.
+###
+if [ "$build" == "" -a -f "$DARWIN_BUILDROOT/.build/build" ]; then
+ build="$(cat $DARWIN_BUILDROOT/.build/build)"
+fi
+
+###
+### Still no build number specified. Error.
+###
+if [ "$build" == "" ]; then
+ echo "Error: no build number specified." 2>&1
+ exit 1
+fi
+export DARWINBUILD_BUILD="$build"
+
+
+
+###
+### Update binary packages
+###
+"$DATADIR/packageRoots"
+
+###
+### Update thin packages
+###
+if [ ! -z "$ARCH" ]; then
+ "$DATADIR/thinPackages" "$ARCH"
+fi
+
+
+###
+### Mount a disk image, create if necessary
+###
+if [ ! -f "$DMG" ]; then
+ hdiutil create "$DMG" \
+ -size "$SIZE" \
+ -layout SPUD \
+ -fs HFS+ \
+ -volname "$VOLNAME"
+fi
+DESTDIR=$(hdiutil attach "$DMG" \
+ -readwrite \
+ -owners on | tail -1 | awk '{print $3}')
+
+###
+### Copy roots necessary for booting / installation onto disk image
+###
+cd "$DESTDIR" || exit
+chown root:admin "$DESTDIR"
+chmod 1775 "$DESTDIR"
+
+echo "Installing Roots ..."
+for Project in $("$DARWINXREF" group boot) ; do
+ InstallRoot "$DESTDIR" "$Project" "$build"
+done
+
+###
+### Generate the mkext cache
+###
+echo "Generating MKext ..."
+
+export TMPDIR="$DESTDIR/private/tmp"
+if [ -z "$ARCH" ]; then
+ KEXTARCH="-a ppc -a i386"
+else
+ KEXTARCH="-a $ARCH"
+fi
+kextcache $KEXTARCH -k -K "$DESTDIR/mach_kernel" -m "$DESTDIR/System/Library/Extensions.mkext" "$DESTDIR/System/Library/Extensions"
+export -n TMPDIR
+
+###
+### Remove extraneous files
+###
+echo "Pruning ..."
+find "$DESTDIR" -type f \( -name '*.[ch]' -or -name '*.cp' -or -name '*.cpp' \) -print -exec rm -f {} ';'
+rm -Rf "$DESTDIR/AppleInternal"
+rm -Rf "$DESTDIR/Developer"
+rm -Rf "$DESTDIR/usr/local"
+rm -Rf "$DESTDIR/usr/share/doc"
+rm -Rf "$DESTDIR"/usr/share/man/man3/*
+
+###
+### Modify the root password to blank
+###
+echo "Modifying Root Password ..."
+nicl -raw "$DESTDIR/var/db/netinfo/local.nidb" -create /users/root passwd ''
+
+###
+### Copy installation packages
+###
+mkdir -p "$DESTDIR/System/Installation/BinaryDrivers${ARCHSFX}"
+echo "Copying binary drivers ..."
+for X in $DARWIN_BUILDROOT/BinaryDrivers${ARCHSFX}/*-*.tar.bz2 ; do
+ Y="$DESTDIR"/System/Installation/BinaryDrivers${ARCHSFX}/$(basename $X)
+ if [ $X -nt $Y ]; then
+ cp $X $Y
+ fi
+done
+
+echo "Copying packages ..."
+mkdir -p "$DESTDIR"/System/Installation/Packages${ARCHSFX}
+for X in $DARWIN_BUILDROOT/Packages${ARCHSFX}/*-*.tar.bz2 ; do
+ f=$(basename $X)
+ if [ "${f/-*/}" != "DarwinInstaller" ]; then
+ Y="$DESTDIR"/System/Installation/Packages${ARCHSFX}/$(basename $X)
+ if [ $X -nt $Y ]; then
+ echo $f
+ cp $X $Y
+ fi
+ fi
+done
+
+###
+### Architecture-specific boot setup
+###
+if [ "$ARCH" == "ppc" ]; then
+ ###
+ ### Bless the volume for powerpc booting
+ ###
+ echo "Blessing Volume ..."
+ bless --verbose \
+ --label "$VOLNAME" \
+ --folder "$DESTDIR/System/Library/CoreServices" \
+ --bootinfo "$DESTDIR/usr/standalone/ppc/bootx.bootinfo"
+
+ ### Generate CDR image
+ rm -f "$CDR"
+ hdiutil convert \
+ "$DMG" \
+ -format UDTO \
+ -o "$CDR"
+
+
+elif [ "$ARCH" == "i386" -o -z "$ARCH" ]; then
+ ###
+ ### Create a bootable ISO filesystem
+ ###
+ ditto "$DESTDIR/usr/standalone/i386" /tmp/i386
+ rm -f "$ISO.boot"
+ $MKISOFS -R \
+ -V "$VOLNAME" \
+ -no-emul-boot \
+ -T \
+ -J \
+ -c boot.cat \
+ -b cdboot \
+ -hide-joliet-trans-tbl \
+ -quiet \
+ -o "$ISO.boot" \
+ /tmp/i386
+ SECTORS=$(du "$ISO.boot" | tail -1 | awk '{print $1}')
+
+ ###
+ ### Create a hybrid image
+ ###
+ rm -f "$ISO.dmg"
+ hdiutil create "$ISO.dmg" -size "$SIZE" -layout NONE
+ DEV=$(hdid -nomount "$ISO.dmg" | tail -1 | awk '{print $1}')
+ RDEV=$(echo $DEV | sed s/disk/rdisk/)
+
+ pdisk "$RDEV" -initialize
+ BLOCKS=$(pdisk "$RDEV" -dump | grep 2: | awk -F" " '{print $4}')
+
+ pdisk "$RDEV" -createPartition "$VOLNAME" Apple_HFS $SECTORS $(($BLOCKS - $SECTORS))
+ SLICE=$(pdisk "$RDEV" -dump | grep "$VOLNAME" | awk -F: '{print $1}' | awk -F" " '{print $1}')
+
+ ### Copy ISO boot data onto the disk image
+ dd if="$ISO.boot" of="$RDEV" skip=64 seek=64 bs=512
+
+ newfs_hfs -v "$VOLNAME" "${RDEV}s${SLICE}"
+ mkdir -p /mnt
+ mount -t hfs -o perm "${DEV}s${SLICE}" /mnt
+ ditto -rsrc "$DESTDIR" /mnt
+ bless -folder /mnt/System/Library/CoreServices \
+ -bootinfo /mnt/usr/standalone/ppc/bootx.bootinfo \
+ -label "$VOLNAME"
+ umount /mnt
+ hdiutil eject "$DEV"
+ mv "$ISO.dmg" "$ISO"
+fi
Property changes on: trunk/darwinbuild/darwinmaster.sh.in
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+ /branches/PR-4841388/darwinbuild/darwinmaster.sh:399-419
/branches/PR-6358021/darwinbuild/darwinmaster.sh:442-443
/branches/PR-6392966/darwinbuild/darwinmaster.sh:423-427
/branches/PR-6398060/darwinbuild/darwinmaster.sh:433-434
/trunk/darwinbuild/darwinmaster.sh:432-434
Added: svn:eol-style
+ native
Deleted: trunk/darwinbuild/packageRoots.sh
===================================================================
--- trunk/darwinbuild/packageRoots.sh 2008-12-21 00:09:50 UTC (rev 446)
+++ trunk/darwinbuild/packageRoots.sh 2008-12-21 08:19:03 UTC (rev 447)
@@ -1,147 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005, Apple Computer, Inc. All rights reserved.
-#
-# @APPLE_BSD_LICENSE_HEADER_START@
-#
-# 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 of Apple Computer, Inc. ("Apple") nor the names of
-# its contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
-# ANY EXPRESS 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 APPLE OR ITS 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.
-#
-# @APPLE_BSD_LICENSE_HEADER_END@
-#
-# Kevin Van Vechten <kvv at apple.com>
-
-set -e
-
-PREFIX=/usr/local
-XREFDB=.build/xref.db
-DARWINXREF=$PREFIX/bin/darwinxref
-DATADIR=$PREFIX/share/darwinbuild
-COMMONFILE=$DATADIR/darwinbuild.common
-
-NORUN=""
-VERBOSE="true"
-TOOL="tar"
-
-###
-### Interpret our arguments:
-### -n Don't actually package anything, just say what we would do.
-function PrintUsage() {
- echo "usage: $(basename $0) [-n] [-x]" 1>&2
- exit
-}
-
-args=`getopt nxv $*`
-if [ $? -ne 0 ]; then
- PrintUsage
-fi
-
-set -- $args
-
-for i; do
- case "$i" in
- -n)
- NORUN="true"
- shift
- ;;
- -x)
- TOOL="xar"
- shift
- ;;
- -v)
- VERBOSE="echo"
- shift
- ;;
- --)
- shift
- ;;
- esac
-done
-
-###
-### Include some common subroutines
-###
-. "$COMMONFILE"
-
-shopt -s nullglob
-
-###
-### Check that we're property situated in an initialized directory
-###
-CheckDarwinBuildRoot
-
-if [ ! -d "$DARWIN_BUILDROOT/Packages" ]; then
- mkdir "$DARWIN_BUILDROOT/Packages"
-fi
-
-$TOOL --version > /dev/null
-echo "Archive tool: $($TOOL --version | head -1)"
-
-function PackageThem() {
- local DIR="$1"
- local SFX="$2"
- echo "*** Packaging $DIR"
- "$DARWINXREF" version '*' | while read PROJVERS; do
- local PROJ="${PROJVERS/-*/}"
- local FILE=""
- local ARGS=""
- local SRCARG=""
- local build_version=$(GetBuildVersion $DARWIN_BUILDROOT/$DIR/$PROJ/$PROJVERS*)
- local SOURCEDIR="$DARWIN_BUILDROOT/$DIR/$PROJ/$PROJVERS$SFX~$build_version"
-
- case "$TOOL" in
- tar)
- FILE="$DARWIN_BUILDROOT/Packages/$PROJ$SFX.tar.gz"
- ARGS="zcf"
- SRCARG="."
- ;;
- xar)
- FILE="$DARWIN_BUILDROOT/Packages/$PROJ$SFX.xar"
- ARGS="-s /tmp/$PROJ.$$.xml -n darwinbuild -c -f"
- SRCARG="."
- ;;
- *)
- FILE="$DARWIN_BUILDROOT/Packages/$PROJ$SFX.$TOOL"
- ARGS=""
- SRCARG="."
- ;;
- esac
-
- if [ -n "$build_version" -a \
- "$SOURCEDIR" -nt "$FILE" ]; then
- echo "$PROJVERS~$build_version"
- $VERBOSE cd "$DARWIN_BUILDROOT"
- cd "$DARWIN_BUILDROOT"
- $VERBOSE "$DARWINXREF" exportProject -xml $PROJ
- "$DARWINXREF" exportProject -xml $PROJ > /tmp/$PROJ.$$.xml
- $VERBOSE cd "$SOURCEDIR"
- cd "$SOURCEDIR"
- $VERBOSE $TOOL $ARGS "$FILE" "$SRCARG"
- $NORUN $TOOL $ARGS "$FILE" "$SRCARG"
- rm -f /tmp/$PROJ.$$.xml
- fi
- done
-}
-PackageThem Headers .hdrs
-PackageThem Roots .root
Copied: trunk/darwinbuild/packageRoots.sh.in (from rev 445, trunk/darwinbuild/packageRoots.sh)
===================================================================
--- trunk/darwinbuild/packageRoots.sh.in (rev 0)
+++ trunk/darwinbuild/packageRoots.sh.in 2008-12-21 08:19:03 UTC (rev 447)
@@ -0,0 +1,147 @@
+#!/bin/sh
+#
+# Copyright (c) 2005, Apple Computer, Inc. All rights reserved.
+#
+# @APPLE_BSD_LICENSE_HEADER_START@
+#
+# 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 of Apple Computer, Inc. ("Apple") nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS 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 APPLE OR ITS 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.
+#
+# @APPLE_BSD_LICENSE_HEADER_END@
+#
+# Kevin Van Vechten <kvv at apple.com>
+
+set -e
+
+PREFIX=%%PREFIX%%
+XREFDB=.build/xref.db
+DARWINXREF=$PREFIX/bin/darwinxref
+DATADIR=$PREFIX/share/darwinbuild
+COMMONFILE=$DATADIR/darwinbuild.common
+
+NORUN=""
+VERBOSE="true"
+TOOL="tar"
+
+###
+### Interpret our arguments:
+### -n Don't actually package anything, just say what we would do.
+function PrintUsage() {
+ echo "usage: $(basename $0) [-n] [-x]" 1>&2
+ exit
+}
+
+args=`getopt nxv $*`
+if [ $? -ne 0 ]; then
+ PrintUsage
+fi
+
+set -- $args
+
+for i; do
+ case "$i" in
+ -n)
+ NORUN="true"
+ shift
+ ;;
+ -x)
+ TOOL="xar"
+ shift
+ ;;
+ -v)
+ VERBOSE="echo"
+ shift
+ ;;
+ --)
+ shift
+ ;;
+ esac
+done
+
+###
+### Include some common subroutines
+###
+. "$COMMONFILE"
+
+shopt -s nullglob
+
+###
+### Check that we're property situated in an initialized directory
+###
+CheckDarwinBuildRoot
+
+if [ ! -d "$DARWIN_BUILDROOT/Packages" ]; then
+ mkdir "$DARWIN_BUILDROOT/Packages"
+fi
+
+$TOOL --version > /dev/null
+echo "Archive tool: $($TOOL --version | head -1)"
+
+function PackageThem() {
+ local DIR="$1"
+ local SFX="$2"
+ echo "*** Packaging $DIR"
+ "$DARWINXREF" version '*' | while read PROJVERS; do
+ local PROJ="${PROJVERS/-*/}"
+ local FILE=""
+ local ARGS=""
+ local SRCARG=""
+ local build_version=$(GetBuildVersion $DARWIN_BUILDROOT/$DIR/$PROJ/$PROJVERS*)
+ local SOURCEDIR="$DARWIN_BUILDROOT/$DIR/$PROJ/$PROJVERS$SFX~$build_version"
+
+ case "$TOOL" in
+ tar)
+ FILE="$DARWIN_BUILDROOT/Packages/$PROJ$SFX.tar.gz"
+ ARGS="zcf"
+ SRCARG="."
+ ;;
+ xar)
+ FILE="$DARWIN_BUILDROOT/Packages/$PROJ$SFX.xar"
+ ARGS="-s /tmp/$PROJ.$$.xml -n darwinbuild -c -f"
+ SRCARG="."
+ ;;
+ *)
+ FILE="$DARWIN_BUILDROOT/Packages/$PROJ$SFX.$TOOL"
+ ARGS=""
+ SRCARG="."
+ ;;
+ esac
+
+ if [ -n "$build_version" -a \
+ "$SOURCEDIR" -nt "$FILE" ]; then
+ echo "$PROJVERS~$build_version"
+ $VERBOSE cd "$DARWIN_BUILDROOT"
+ cd "$DARWIN_BUILDROOT"
+ $VERBOSE "$DARWINXREF" exportProject -xml $PROJ
+ "$DARWINXREF" exportProject -xml $PROJ > /tmp/$PROJ.$$.xml
+ $VERBOSE cd "$SOURCEDIR"
+ cd "$SOURCEDIR"
+ $VERBOSE $TOOL $ARGS "$FILE" "$SRCARG"
+ $NORUN $TOOL $ARGS "$FILE" "$SRCARG"
+ rm -f /tmp/$PROJ.$$.xml
+ fi
+ done
+}
+PackageThem Headers .hdrs
+PackageThem Roots .root
Property changes on: trunk/darwinbuild/packageRoots.sh.in
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+ /branches/PR-4841388/darwinbuild/packageRoots.sh:399-419
/branches/PR-6358021/darwinbuild/packageRoots.sh:442-443
/branches/PR-6392966/darwinbuild/packageRoots.sh:423-427
/branches/PR-6398060/darwinbuild/packageRoots.sh:433-434
/trunk/darwinbuild/packageRoots.sh:432-434
Added: svn:eol-style
+ native
Deleted: trunk/darwinbuild/thinPackages.sh
===================================================================
--- trunk/darwinbuild/thinPackages.sh 2008-12-21 00:09:50 UTC (rev 446)
+++ trunk/darwinbuild/thinPackages.sh 2008-12-21 08:19:03 UTC (rev 447)
@@ -1,83 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005, Apple Computer, Inc. All rights reserved.
-#
-# @APPLE_BSD_LICENSE_HEADER_START@
-#
-# 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 of Apple Computer, Inc. ("Apple") nor the names of
-# its contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
-# ANY EXPRESS 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 APPLE OR ITS 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.
-#
-# @APPLE_BSD_LICENSE_HEADER_END@
-#
-# Kevin Van Vechten <kvv at apple.com>
-
-PREFIX=/usr/local
-XREFDB=.build/xref.db
-DARWINXREF=$PREFIX/bin/darwinxref
-DATADIR=$PREFIX/share/darwinbuild
-COMMONFILE=$DATADIR/darwinbuild.common
-
-THINFILE="$DATADIR/thinFile"
-
-###
-### Interpret our arguments:
-### the architecture to thin to
-ARCH="$1"
-
-if [ "$ARCH" != "ppc" -a "$ARCH" != "i386" ]; then
- echo "usage: $(basename $0) <arch>" 1>&2
- exit 1
-fi
-
-###
-### Include some common subroutines
-###
-. "$COMMONFILE"
-
-shopt -s nullglob
-
-###
-### Check that we're property situated in an initialized directory
-###
-CheckDarwinBuildRoot
-
-PKGDIR="$DARWIN_BUILDROOT/Packages"
-DESTDIR="${PKGDIR}_$ARCH"
-
-for X in $PKGDIR/*-*.tar.gz ; do
- Y=$(basename $X .gz).bz2
- if [ $X -nt $DESTDIR/$Y ]; then
- echo "Extracting $Y ..."
- rm -rf "$DESTDIR/tmp"
- mkdir -p "$DESTDIR/tmp"
- tar xzf $X -C "$DESTDIR/tmp" .
- echo "Thinning $Y ..."
- find "$DESTDIR/tmp" -type f -exec "$THINFILE" "$ARCH" {} ';'
- echo "Archiving $Y ..."
- tar cjf "$DESTDIR/$Y" -C "$DESTDIR/tmp" .
- #else
- # echo $Y is up to date
- fi
-done
-rm -rf "$DESTDIR/tmp"
Copied: trunk/darwinbuild/thinPackages.sh.in (from rev 445, trunk/darwinbuild/thinPackages.sh)
===================================================================
--- trunk/darwinbuild/thinPackages.sh.in (rev 0)
+++ trunk/darwinbuild/thinPackages.sh.in 2008-12-21 08:19:03 UTC (rev 447)
@@ -0,0 +1,83 @@
+#!/bin/sh
+#
+# Copyright (c) 2005, Apple Computer, Inc. All rights reserved.
+#
+# @APPLE_BSD_LICENSE_HEADER_START@
+#
+# 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 of Apple Computer, Inc. ("Apple") nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS 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 APPLE OR ITS 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.
+#
+# @APPLE_BSD_LICENSE_HEADER_END@
+#
+# Kevin Van Vechten <kvv at apple.com>
+
+PREFIX=%%PREFIX%%
+XREFDB=.build/xref.db
+DARWINXREF=$PREFIX/bin/darwinxref
+DATADIR=$PREFIX/share/darwinbuild
+COMMONFILE=$DATADIR/darwinbuild.common
+
+THINFILE="$DATADIR/thinFile"
+
+###
+### Interpret our arguments:
+### the architecture to thin to
+ARCH="$1"
+
+if [ "$ARCH" != "ppc" -a "$ARCH" != "i386" ]; then
+ echo "usage: $(basename $0) <arch>" 1>&2
+ exit 1
+fi
+
+###
+### Include some common subroutines
+###
+. "$COMMONFILE"
+
+shopt -s nullglob
+
+###
+### Check that we're property situated in an initialized directory
+###
+CheckDarwinBuildRoot
+
+PKGDIR="$DARWIN_BUILDROOT/Packages"
+DESTDIR="${PKGDIR}_$ARCH"
+
+for X in $PKGDIR/*-*.tar.gz ; do
+ Y=$(basename $X .gz).bz2
+ if [ $X -nt $DESTDIR/$Y ]; then
+ echo "Extracting $Y ..."
+ rm -rf "$DESTDIR/tmp"
+ mkdir -p "$DESTDIR/tmp"
+ tar xzf $X -C "$DESTDIR/tmp" .
+ echo "Thinning $Y ..."
+ find "$DESTDIR/tmp" -type f -exec "$THINFILE" "$ARCH" {} ';'
+ echo "Archiving $Y ..."
+ tar cjf "$DESTDIR/$Y" -C "$DESTDIR/tmp" .
+ #else
+ # echo $Y is up to date
+ fi
+done
+rm -rf "$DESTDIR/tmp"
Property changes on: trunk/darwinbuild/thinPackages.sh.in
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+ /branches/PR-4841388/darwinbuild/thinPackages.sh:399-419
/branches/PR-6358021/darwinbuild/thinPackages.sh:442-443
/branches/PR-6392966/darwinbuild/thinPackages.sh:423-427
/branches/PR-6398060/darwinbuild/thinPackages.sh:433-434
/trunk/darwinbuild/thinPackages.sh:432-434
Added: svn:eol-style
+ native
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20081221/383b3537/attachment-0001.html>
More information about the darwinbuild-changes
mailing list