From fedc277013d7b8d2812c3ccb869e1a8530b5f6f5 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Thu, 9 Feb 2012 11:15:14 +1100 Subject: [PATCH] misc/dist: new hierarchy for binary distribution packaging scripts R=golang-dev, rsc, bradfitz CC=golang-dev https://golang.org/cl/5639063 --- misc/dist/README | 4 ++ misc/dist/darwin/README | 3 ++ misc/dist/darwin/dist.bash | 69 ++++++++++++++++++++++++++++ misc/dist/darwin/etc/paths.d/go | 1 + misc/dist/darwin/scripts/postinstall | 23 ++++++++++ 5 files changed, 100 insertions(+) create mode 100644 misc/dist/README create mode 100644 misc/dist/darwin/README create mode 100755 misc/dist/darwin/dist.bash create mode 100644 misc/dist/darwin/etc/paths.d/go create mode 100644 misc/dist/darwin/scripts/postinstall diff --git a/misc/dist/README b/misc/dist/README new file mode 100644 index 00000000000..06136c4c58c --- /dev/null +++ b/misc/dist/README @@ -0,0 +1,4 @@ +This directory contains the binary distribution packaging scripts for the +supported GOOSes. + +To build a package, run $GOOS/dist.bash. diff --git a/misc/dist/darwin/README b/misc/dist/darwin/README new file mode 100644 index 00000000000..25aeb8ca63a --- /dev/null +++ b/misc/dist/darwin/README @@ -0,0 +1,3 @@ +Use dist.bash to construct a package file (Go.pkg) for installation on OS X. + +This script depends on PackageMaker (Developer Tools). diff --git a/misc/dist/darwin/dist.bash b/misc/dist/darwin/dist.bash new file mode 100755 index 00000000000..adade2e2239 --- /dev/null +++ b/misc/dist/darwin/dist.bash @@ -0,0 +1,69 @@ +#!/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 + +if ! test -f ../../../src/all.bash; then + echo >&2 "dist.bash must be run from $GOROOT/misc/dist/darwin" + exit 1 +fi + +echo >&2 "Locating PackageMaker..." +PM=/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker +if [ ! -x $PM ]; then + PM=/Developer$PM + if [ ! -x $PM ]; then + echo >&2 "could not find PackageMaker; aborting" + exit 1 + fi +fi +echo >&2 " Found: $PM" + +BUILD=/tmp/go.build.tmp +ROOT=`hg root` +export GOROOT=$BUILD/root/usr/local/go +export GOROOT_FINAL=/usr/local/go + +echo >&2 "Removing old images" +rm -f *.pkg *.dmg + +echo >&2 "Preparing temporary directory" +rm -rf $BUILD +mkdir -p $BUILD +trap "rm -rf $BUILD" 0 + +echo >&2 "Copying go source distribution" +mkdir -p $BUILD/root/usr/local +cp -r $ROOT $GOROOT +cp -r etc $BUILD/root/etc + +pushd $GOROOT > /dev/null + +echo >&2 "Detecting version..." +pushd src > /dev/null +./make.bash --dist-tool > /dev/null +../bin/tool/dist version > /dev/null +popd > /dev/null +mv VERSION.cache VERSION +VERSION="$(cat VERSION | awk '{ print $1 }')" +echo >&2 " Version: $VERSION" + +echo >&2 "Pruning Mercurial metadata" +rm -rf .hg .hgignore .hgtags + +echo >&2 "Building Go" +pushd src +./all.bash 2>&1 | sed "s/^/ /" >&2 +popd > /dev/null + +popd > /dev/null + +echo >&2 "Building package" +$PM -v -r $BUILD/root -o "go.darwin.$VERSION.pkg" \ + --scripts scripts \ + --id com.googlecode.go \ + --title Go \ + --version "0.1" \ + --target "10.5" diff --git a/misc/dist/darwin/etc/paths.d/go b/misc/dist/darwin/etc/paths.d/go new file mode 100644 index 00000000000..532e5f93644 --- /dev/null +++ b/misc/dist/darwin/etc/paths.d/go @@ -0,0 +1 @@ +/usr/local/go/bin diff --git a/misc/dist/darwin/scripts/postinstall b/misc/dist/darwin/scripts/postinstall new file mode 100644 index 00000000000..3748721c744 --- /dev/null +++ b/misc/dist/darwin/scripts/postinstall @@ -0,0 +1,23 @@ +#!/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 "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 +