diff --git a/.hgignore b/.hgignore index c8150bac5d6..9cb9c54c64f 100644 --- a/.hgignore +++ b/.hgignore @@ -29,6 +29,8 @@ doc/codelab/wiki/*.bin misc/cgo/life/run.out misc/dashboard/builder/gobuilder misc/goplay/goplay +misc/osx/*.pkg +misc/osx/*.dmg src/Make.inc src/cmd/6a/6a src/cmd/?l/enam.c diff --git a/misc/osx/README b/misc/osx/README new file mode 100644 index 00000000000..87476dabc47 --- /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 00000000000..d8de1db790e --- /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 00000000000..532e5f93644 --- /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 00000000000..6c52ac4d583 --- /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 00000000000..ff8f7617292 --- /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 00000000000..ac3717642f0 --- /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 00000000000..2f2c53c783f --- /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 00000000000..022a0bdc09a --- /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