]> Cypherpunks repositories - gostls13.git/commitdiff
dist: fix postinstall script for Darwin
authorAlexandre Normand <alexandre.normand@gmail.com>
Mon, 15 Jul 2013 00:52:38 +0000 (10:52 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 15 Jul 2013 00:52:38 +0000 (10:52 +1000)
The postinstall script causes the installation to fail because the last
step that copies files for Xcode is broken. Two details can cause the
command to fail:
  1. The XCODE_MISC_DIR value has a space. Without quotes in the cp
     command, cp will just complain that this is an invalid syntax.
  2. The source of the cp is a directory with two subdirectories.
     We actually want the files for either Xcode 3 or Xcode 4 to be copied.
     Using xcodebuild -version, we check for the Xcode version and
     select which of xcode/3/* or xcode/4/* should be the source
     of the copy.

Fixes #5874.

R=golang-dev, minux.ma, adg
CC=golang-dev
https://golang.org/cl/10893044

misc/dist/darwin/scripts/postinstall

index 4410a3004ef01ce9b1c8c2ea2a1e3880133c96fb..35c840a37b934ad1177e0379a3c4ac45d99cedbd 100755 (executable)
@@ -10,9 +10,22 @@ find . -type d -exec chmod ugo+rx \{\} \;
 chmod o-w .
 
 echo "Installing miscellaneous files:"
-XCODE_MISC_DIR="/Library/Application Support/Developer/Shared/Xcode/Specifications/"
-if [ -d "$XCODE_MISC_DIR" ]; then
-       echo "  XCode"
-       cp $GOROOT/misc/xcode/* $XCODE_MISC_DIR
+XCODE_SHARED_DIR="/Library/Application Support/Developer/Shared/Xcode"
+XCODE_MISC_DIR="$XCODE_SHARED_DIR/Specifications/"
+if [ -d "$XCODE_SHARED_DIR" ]; then
+       # Create the XCODE_MISC_DIR if it doesn't exist already
+       mkdir -p "$XCODE_MISC_DIR"
+
+       version=`/usr/bin/xcodebuild -version | sed -n -E 's/^Xcode ([0-9]+)\..*$/\1/p'`
+        
+        # Since command line tools are optional with Xcode 4, a failure of the 
+       # xcodebuild -version command is interpreted as meaning Xcode 4 is the 
+       # version used.
+       if [[ $? -ne 0 ]]; then
+               version=4
+       fi
+
+        echo "  Xcode $version"
+       cp $GOROOT/misc/xcode/$version/* "$XCODE_MISC_DIR"
 fi