Commit c17d09a6 authored by Mikkel Krautz's avatar Mikkel Krautz Committed by Andrew Gerrand

misc/dist: require 10.6 or later for OS X .pkgs

This changes the misc/dist program to generate OS X
packages using pkgbuild and productbuild.

The productbuild utility makes it easy to generate
packages with a custom Distribution file.  This allows
us to add an installcheck script that presents a
friendly message to users who are running on an old
version of Mac OS X.

The change also fixes a few issues with the
postinstall script:

 - In-repo version of the script has been made
   executable. Installers generated using the new
   tools couldn't execute it otherwise.

 - It now uses -d for checking for the existence
   of the Xcode specs directory.

 - The call to sudo.bash has been dropped since cov
   and prof aren't bundled with the binary
   distributions.

Fixes #3455.

Tested on 10.5.8, 10.6.0, 10.6.8 and 10.7.3.

R=adg, golang-dev
CC=golang-dev
https://golang.org/cl/5987044
parent 5583060c
...@@ -13,7 +13,6 @@ import ( ...@@ -13,7 +13,6 @@ import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"encoding/base64" "encoding/base64"
"errors"
"flag" "flag"
"fmt" "fmt"
"io" "io"
...@@ -41,7 +40,6 @@ var ( ...@@ -41,7 +40,6 @@ var (
) )
const ( const (
packageMaker = "/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
uploadURL = "https://go.googlecode.com/files" uploadURL = "https://go.googlecode.com/files"
) )
...@@ -231,7 +229,7 @@ func (b *Build) Do() error { ...@@ -231,7 +229,7 @@ func (b *Build) Do() error {
return err return err
} }
localDir := filepath.Join(work, "usr/local") localDir := filepath.Join(work, "usr/local")
err = os.MkdirAll(localDir, 0744) err = os.MkdirAll(localDir, 0755)
if err != nil { if err != nil {
return err return err
} }
...@@ -240,27 +238,29 @@ func (b *Build) Do() error { ...@@ -240,27 +238,29 @@ func (b *Build) Do() error {
return err return err
} }
// build package // build package
pkginfo, err := createPackageInfo(work) pkgdest, err := ioutil.TempDir("", "pkgdest")
if err != nil { if err != nil {
return err return err
} }
defer os.Remove(pkginfo) defer os.RemoveAll(pkgdest)
pm := packageMaker dist := filepath.Join(runtime.GOROOT(), "misc/dist")
if !exists(pm) { _, err = b.run("", "pkgbuild",
pm = "/Developer" + pm "--identifier", "com.googlecode.go",
if !exists(pm) { "--version", "1.0",
return errors.New("couldn't find PackageMaker") "--scripts", filepath.Join(dist, "darwin/scripts"),
} "--root", work,
filepath.Join(pkgdest, "com.googlecode.go.pkg"))
if err != nil {
return err
} }
targ := base + ".pkg" targ := base + ".pkg"
scripts := filepath.Join(work, "usr/local/go/misc/dist/darwin/scripts") _, err = b.run("", "productbuild",
_, err = b.run("", pm, "-v", "--distribution", filepath.Join(dist, "darwin/Distribution"),
"-r", work, "--package-path", pkgdest,
"-o", targ, targ)
"--info", pkginfo, if err != nil {
"--scripts", scripts, return err
"--title", "Go", }
"--target", "10.5")
targs = append(targs, targ) targs = append(targs, targ)
case "windows": case "windows":
// Create ZIP file. // Create ZIP file.
...@@ -806,30 +806,3 @@ func tarFileInfoHeader(fi os.FileInfo, filename string) (*tar.Header, error) { ...@@ -806,30 +806,3 @@ func tarFileInfoHeader(fi os.FileInfo, filename string) (*tar.Header, error) {
} }
return h, nil return h, nil
} }
// createPackageInfo creates a PackageInfo template file for use with PackageMaker.
// The returned filename points to a file in a temporary directory on the filesystem,
// and should be removed after use.
func createPackageInfo(work string) (filename string, err error) {
var size, nfiles int64
err = filepath.Walk(work, func(path string, info os.FileInfo, err error) error {
nfiles++
size += info.Size()
return nil
})
if err != nil {
return "", err
}
pi, err := ioutil.TempFile("", "PackageInfo")
if err != nil {
return "", err
}
defer pi.Close()
_, err = fmt.Fprintf(pi, "<pkg-info identifier=\"com.googlecode.go\" version=\"1.0\" followSymLinks=\"true\">\n"+
"\t<payload installKBytes=\"%v\" numberOfFiles=\"%v\"/>\n"+
"</pkg-info>\n", size/1024, nfiles)
if err != nil {
return "", err
}
return pi.Name(), nil
}
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-script minSpecVersion="1.000000">
<title>Go</title>
<options customize="never" allow-external-scripts="no"/>
<domains enable_localSystem="true" />
<installation-check script="installCheck();"/>
<script>
function installCheck() {
if(!(system.compareVersions(system.version.ProductVersion, '10.6.0') >= 0)) {
my.result.title = 'Unable to install';
my.result.message = 'Go requires Mac OS X 10.6 or later.';
my.result.type = 'Fatal';
return false;
}
return true;
}
</script>
<choices-outline>
<line choice="com.googlecode.go.choice"/>
</choices-outline>
<choice id="com.googlecode.go.choice" title="Go">
<pkg-ref id="com.googlecode.go.pkg"/>
</choice>
<pkg-ref id="com.googlecode.go.pkg" auth="Root">com.googlecode.go.pkg</pkg-ref>
</installer-script>
...@@ -9,14 +9,9 @@ find bin -exec chmod ugo+rx \{\} \; ...@@ -9,14 +9,9 @@ find bin -exec chmod ugo+rx \{\} \;
find . -type d -exec chmod ugo+rx \{\} \; find . -type d -exec chmod ugo+rx \{\} \;
chmod o-w . chmod o-w .
echo "Fixing debuggers via sudo.bash"
# setgrp procmod the debuggers (sudo.bash)
cd $GOROOT/src
./sudo.bash
echo "Installing miscellaneous files:" echo "Installing miscellaneous files:"
XCODE_MISC_DIR="/Library/Application Support/Developer/Shared/Xcode/Specifications/" XCODE_MISC_DIR="/Library/Application Support/Developer/Shared/Xcode/Specifications/"
if [ -f $XCODE_MISC_DIR ]; then if [ -d "$XCODE_MISC_DIR" ]; then
echo " XCode" echo " XCode"
cp $GOROOT/misc/xcode/* $XCODE_MISC_DIR cp $GOROOT/misc/xcode/* $XCODE_MISC_DIR
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment