1#!/bin/sh 2# 3# Copyright (c) 2005-2010, Apple Computer, Inc. All rights reserved. 4# 5# @APPLE_BSD_LICENSE_HEADER_START@ 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 16# its contributors may be used to endorse or promote products derived 17# from this software without specific prior written permission. 18# 19# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND 20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22# ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR 23# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29# POSSIBILITY OF SUCH DAMAGE. 30# 31# @APPLE_BSD_LICENSE_HEADER_END@ 32 33 34### 35### Given a list of filenames, this function will 36### find the largest number after the '~' and return 37### its value. Used to calculate a non-conflicting build number. 38### 39function GetBuildVersion() { 40 local maxbuild="0" 41 if [ $# -eq 0 ]; then 42 echo "" 43 return 0 44 fi 45 for X in $* ; do 46 # Grab the numeric portion after the '~' 47 build=$(echo $X | sed -e 's/^.*~\([0-9]*\)$/\1/') 48 # If the regex fails, it somtimes prints the same line 49 if [ "$build" != "$X" -a "$build" != "" ]; then 50 # [ seems to things on the left of the -a, 51 # so do this in a different statement to avoid 52 # errors about non-numeric values of $build 53 if [ "$build" -gt "$maxbuild" ]; then 54 maxbuild="$build" 55 fi 56 fi 57 done 58 echo $maxbuild 59} 60 61### 62### Trap calls to ditto since it is only available on Mac OS X 63### Warning: only supports the directory-to-directory form 64function ditto() { 65 local srcdir="$1" 66 local dstdir="$2" 67 if [ -x /usr/bin/ditto ]; then 68 /usr/bin/ditto "$srcdir" "$dstdir" 69 else 70 tar c -C "$srcdir" . | tar xf - -C "$dstdir" 71 fi 72} 73 74CURLARGS=${CURLARGS:-} 75