summaryrefslogtreecommitdiff
path: root/misc/osx
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
commit4cecda6c347bd6902b960c6a35a967add7070b0d (patch)
treea462e224ff41ec9f3eb1a0b6e815806f9e8804ad /misc/osx
parent6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (diff)
downloadgolang-4cecda6c347bd6902b960c6a35a967add7070b0d.tar.gz
Imported Upstream version 2012.01.27upstream-weekly/2012.01.27
Diffstat (limited to 'misc/osx')
-rw-r--r--misc/osx/README9
-rw-r--r--misc/osx/ReadMe.txt4
-rw-r--r--misc/osx/etc/paths.d/go1
-rwxr-xr-xmisc/osx/etc/profile_go15
-rwxr-xr-xmisc/osx/image.bash38
-rwxr-xr-xmisc/osx/package.bash51
-rw-r--r--misc/osx/scripts/postinstall28
-rw-r--r--misc/osx/utils.bash31
8 files changed, 177 insertions, 0 deletions
diff --git a/misc/osx/README b/misc/osx/README
new file mode 100644
index 000000000..87476dabc
--- /dev/null
+++ b/misc/osx/README
@@ -0,0 +1,9 @@
+Use image.bash to construct a disk image.
+
+package.bash constructs a package file (Go.pkg) for installation on OS X, and
+is used by image.bash to construct a disk image. Strictly speaking, the disk
+image is unnecessary, but they are more common by convention.
+
+These scripts depend on PackageMaker (Developer Tools), osascript, and hdiutil.
+Appropriate checks are run in utils.bash, called at the beginning of each
+script.
diff --git a/misc/osx/ReadMe.txt b/misc/osx/ReadMe.txt
new file mode 100644
index 000000000..d8de1db79
--- /dev/null
+++ b/misc/osx/ReadMe.txt
@@ -0,0 +1,4 @@
+See http://golang.org/doc/go_tutorial.html for help getting started. Note that
+the installation steps described in the "getting started" guide are performed
+for you by the installer packaged in this directory.
+
diff --git a/misc/osx/etc/paths.d/go b/misc/osx/etc/paths.d/go
new file mode 100644
index 000000000..532e5f936
--- /dev/null
+++ b/misc/osx/etc/paths.d/go
@@ -0,0 +1 @@
+/usr/local/go/bin
diff --git a/misc/osx/etc/profile_go b/misc/osx/etc/profile_go
new file mode 100755
index 000000000..6c52ac4d5
--- /dev/null
+++ b/misc/osx/etc/profile_go
@@ -0,0 +1,15 @@
+#!/bin/bash
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# The output of this script will be eval'd by the user's shell on startup. This
+# script decides what type of shell is being used in the same way as
+# /usr/libexec/path_helper
+
+if echo $SHELL | grep csh$ > /dev/null; then
+ echo 'setenv GOROOT /usr/local/go'
+else
+ echo 'export GOROOT=/usr/local/go'
+fi
+
diff --git a/misc/osx/image.bash b/misc/osx/image.bash
new file mode 100755
index 000000000..ff8f76172
--- /dev/null
+++ b/misc/osx/image.bash
@@ -0,0 +1,38 @@
+#!/bin/bash
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+set -e
+
+source utils.bash
+
+if ! test -f ../../src/env.bash; then
+ echo "package.bash must be run from $GOROOT/misc/osx" 1>&2
+fi
+
+ROOT=`hg root`
+
+echo "Running package.bash"
+./package.bash
+
+echo "Preparing image directory"
+IMGDIR=/tmp/"Go `hg id`"
+rm -rf "${IMGDIR}"
+mkdir -p "${IMGDIR}"
+
+# Copy in files
+cp "Go `hg id`.pkg" "${IMGDIR}/Go.pkg"
+cp ${ROOT}/LICENSE "${IMGDIR}/License.txt"
+cp ReadMe.txt "${IMGDIR}/ReadMe.txt"
+cp "${ROOT}/doc/gopher/bumper640x360.png" "${IMGDIR}/.background"
+
+# Call out to applescript (osascript) to prettify things
+#${OSASCRIPT} prepare.applescript
+
+echo "Creating dmg"
+${HDIUTIL} create -srcfolder "${IMGDIR}" "Go `hg id`.dmg"
+
+echo "Removing image directory"
+rm -rf ${IMGDIR}
+
diff --git a/misc/osx/package.bash b/misc/osx/package.bash
new file mode 100755
index 000000000..ac3717642
--- /dev/null
+++ b/misc/osx/package.bash
@@ -0,0 +1,51 @@
+#!/bin/bash
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+set -e
+
+source utils.bash
+
+if ! test -f ../../src/env.bash; then
+ echo "package.bash must be run from $GOROOT/misc/osx" 1>&2
+fi
+
+BUILD=/tmp/go.build.tmp
+ROOT=`hg root`
+
+echo "Removing old images"
+rm -f *.pkg *.dmg
+
+echo "Preparing temporary directory"
+rm -rf ${BUILD}
+mkdir -p ${BUILD}
+
+echo "Preparing template"
+mkdir -p ${BUILD}/root/usr/local/
+
+echo "Copying go source distribution"
+cp -r $ROOT ${BUILD}/root/usr/local/go
+cp -r etc ${BUILD}/root/etc
+
+echo "Building go"
+pushd . > /dev/null
+cd ${BUILD}/root/usr/local/go
+GOROOT=`pwd`
+src/version.bash -save
+rm -rf .hg .hgignore .hgtags
+cd src
+./all.bash | sed "s/^/ /"
+cd ..
+popd > /dev/null
+
+echo "Building package"
+${PM} -v -r ${BUILD}/root -o "Go `hg id`.pkg" \
+ --scripts scripts \
+ --id com.googlecode.go \
+ --title Go \
+ --version "0.1" \
+ --target "10.5"
+
+echo "Removing temporary directory"
+rm -rf ${BUILD}
diff --git a/misc/osx/scripts/postinstall b/misc/osx/scripts/postinstall
new file mode 100644
index 000000000..f8545b8b0
--- /dev/null
+++ b/misc/osx/scripts/postinstall
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+GOROOT=/usr/local/go
+
+echo "Fixing permissions"
+cd $GOROOT
+find . -exec chmod ugo+r \{\} \;
+find bin -exec chmod ugo+rx \{\} \;
+find . -type d -exec chmod ugo+rx \{\} \;
+chmod o-w .
+
+echo "Setting GOROOT system-wide"
+echo "eval \`/etc/profile_go\`" >> /etc/csh.login
+echo "eval \`/etc/profile_go\`" >> /etc/zshenv
+echo "eval \`/etc/profile_go\`" >> /etc/profile
+
+echo "Fixing debuggers via sudo.bash"
+# setgrp procmod the debuggers (sudo.bash)
+cd $GOROOT/src
+./sudo.bash
+
+echo "Installing miscellaneous files:"
+XCODE_MISC_DIR="/Library/Application Support/Developer/Shared/Xcode/Specifications/"
+if [ -f $XCODE_MISC_DIR ]; then
+ echo " XCode"
+ cp $GOROOT/misc/xcode/* $XCODE_MISC_DIR
+fi
+
diff --git a/misc/osx/utils.bash b/misc/osx/utils.bash
new file mode 100644
index 000000000..022a0bdc0
--- /dev/null
+++ b/misc/osx/utils.bash
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+set -e
+
+echo "Attempting to locate needed utilities..."
+
+# PackageMaker
+PM=/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
+if [ ! -x ${PM} ]; then
+ PM=/Developer${PM}
+ if [ ! -x ${PM} ]; then
+ echo "Could not find PackageMaker; aborting!"
+ fi
+fi
+echo " PackageMaker : ${PM}"
+
+# hdiutil. If this doesn't exist, your OS X installation is horribly borked,
+# but let's check anyway...
+if which hdiutil > /dev/null; then
+ HDIUTIL=`which hdiutil`
+ echo " hdiutil : ${HDIUTIL}"
+fi
+
+# Ditto for osascript
+if which osascript > /dev/null; then
+ OSASCRIPT=`which osascript`
+ echo " osascript : ${OSASCRIPT}"
+fi