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 (
"bytes"
"compress/gzip"
"encoding/base64"
"errors"
"flag"
"fmt"
"io"
......@@ -41,8 +40,7 @@ var (
)
const (
packageMaker = "/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
uploadURL = "https://go.googlecode.com/files"
uploadURL = "https://go.googlecode.com/files"
)
var preBuildCleanFiles = []string{
......@@ -231,7 +229,7 @@ func (b *Build) Do() error {
return err
}
localDir := filepath.Join(work, "usr/local")
err = os.MkdirAll(localDir, 0744)
err = os.MkdirAll(localDir, 0755)
if err != nil {
return err
}
......@@ -240,27 +238,29 @@ func (b *Build) Do() error {
return err
}
// build package
pkginfo, err := createPackageInfo(work)
pkgdest, err := ioutil.TempDir("", "pkgdest")
if err != nil {
return err
}
defer os.Remove(pkginfo)
pm := packageMaker
if !exists(pm) {
pm = "/Developer" + pm
if !exists(pm) {
return errors.New("couldn't find PackageMaker")
}
defer os.RemoveAll(pkgdest)
dist := filepath.Join(runtime.GOROOT(), "misc/dist")
_, err = b.run("", "pkgbuild",
"--identifier", "com.googlecode.go",
"--version", "1.0",
"--scripts", filepath.Join(dist, "darwin/scripts"),
"--root", work,
filepath.Join(pkgdest, "com.googlecode.go.pkg"))
if err != nil {
return err
}
targ := base + ".pkg"
scripts := filepath.Join(work, "usr/local/go/misc/dist/darwin/scripts")
_, err = b.run("", pm, "-v",
"-r", work,
"-o", targ,
"--info", pkginfo,
"--scripts", scripts,
"--title", "Go",
"--target", "10.5")
_, err = b.run("", "productbuild",
"--distribution", filepath.Join(dist, "darwin/Distribution"),
"--package-path", pkgdest,
targ)
if err != nil {
return err
}
targs = append(targs, targ)
case "windows":
// Create ZIP file.
......@@ -806,30 +806,3 @@ func tarFileInfoHeader(fi os.FileInfo, filename string) (*tar.Header, error) {
}
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 \{\} \;
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
if [ -d "$XCODE_MISC_DIR" ]; then
echo " XCode"
cp $GOROOT/misc/xcode/* $XCODE_MISC_DIR
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