From 1095305232b80fe23a14e0eb5d520bac91223572 Mon Sep 17 00:00:00 2001 From: Joe Poirier Date: Tue, 18 Oct 2011 15:51:45 +1100 Subject: [PATCH] misc/windows: automated toolchain packager A first run at fully automating the process. This CL supersedes https://golang.org/cl/4634114/ which I seemed to have lost. R=golang-dev, alex.brainman, adg CC=golang-dev https://golang.org/cl/5273041 --- misc/windows/README | 22 +++++++++ misc/windows/installer.iss | 98 ++++++++++++++++++++++++++++++++++++++ misc/windows/package.bash | 44 +++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 misc/windows/README create mode 100644 misc/windows/installer.iss create mode 100755 misc/windows/package.bash diff --git a/misc/windows/README b/misc/windows/README new file mode 100644 index 00000000000..a7e0d3fc4bd --- /dev/null +++ b/misc/windows/README @@ -0,0 +1,22 @@ +package.bash packages the Go toolchain for Window's in +zip and installer (exe) format. + +Dependencies +============ +- Inno Setup: http://www.jrsoftware.org/isinfo.php +- 7Zip command-line: http://www.7-zip.org/download.html +- MinGW/Msys tools + +Unzip and place 7za.exe in msys' bin directory. + +Packaging +========= +1) have a go tree at $GOROOT +2) make sure $GOBIN=$GOROOT\bin is empty +3) select appropriate version "hg up -r ..." +4) build go "cd $GOROOT/src; ./all.bash" +5) create Windows packages "cd $GOROOT/misc/windows; ./package.bash" + + + + diff --git a/misc/windows/installer.iss b/misc/windows/installer.iss new file mode 100644 index 00000000000..977a2cd1491 --- /dev/null +++ b/misc/windows/installer.iss @@ -0,0 +1,98 @@ +;; Copyright 2010 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. + +[Setup] +;; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{1AE268D9-FAE4-4EF8-AAE9-3B1B27D604F0} +AppName={#AppName} +AppVersion={#AppVersion} +AppPublisher=golang-nuts@googlegroups.com +AppPublisherURL=http://www.golang.org +DefaultDirName={sd}\Go +DisableDirPage=yes +DefaultGroupName={#AppName} +AllowNoIcons=yes +OutputBaseFilename={#AppNameLower}win{#AppVersion}_installer +Compression=lzma2/max +SolidCompression=yes +ChangesEnvironment=true +OutputDir=. + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" +Name: "basque"; MessagesFile: "compiler:Languages\Basque.isl" +Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" +Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl" +Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl" +Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl" +Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl" +Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl" +Name: "french"; MessagesFile: "compiler:Languages\French.isl" +Name: "german"; MessagesFile: "compiler:Languages\German.isl" +Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl" +Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl" +Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl" +Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" +Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl" +Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl" +Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl" +Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl" +Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl" +Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl" +Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" + +[Files] +Source: ".\go\*"; DestDir: "{sd}\Go"; Flags: ignoreversion recursesubdirs createallsubdirs + +[Registry] +;Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GOARCH"; ValueData: "386"; Flags: uninsdeletevalue +;Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GOOS"; ValueData: "windows"; Flags: uninsdeletevalue +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GOBIN"; ValueData: "{sd}/Go/bin"; Flags: uninsdeletevalue +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GOROOT"; ValueData: "{sd}/Go"; Flags: uninsdeletevalue +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{sd}/Go/bin"; Check: PathCheck('{sd}/Go/bin') + +;[Tasks] +;Name: AddToPath; Description: "&Adding Go's bin directory to your environment's search path. This allows the tools to be run from a shell without having to include the installation path as part of the command."; + +[Icons] +;Name: "{group}\{cm:UninstallProgram,Go}"; Filename: {uninstallexe} +Name: "{group}\Uninstall Go"; Filename: "{uninstallexe}" + +[Code] +function PathCheck(Param: string): Boolean; +var + OrigPath: String; + Index: Integer; +begin + // check for an empty path + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', OrigPath) + then begin + Result := True; + exit; + end; + + // Pos returns 0 if not found + Index := Pos(';' + Param + ';', ';' + OrigPath + ';'); + + if (IsUninstaller() = True) AND (Index > 0) then begin + Delete(OrigPath, Index, Length(Param)); + + // remove orphaned semicolon if necessary + if (Length(OrigPath) >= Index) AND (Copy(OrigPath, Index, 1) = ';') then begin + Delete(OrigPath, Index, 1); + end; + + RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', OrigPath); + end; + + // during installation, the check in the Registry + // section wants a Boolean value + Result := Index = 0; +end; + +function InitializeUninstall(): Boolean; +begin + PathCheck(ExpandConstant('{sd}/Go/bin')); + Result := True; +end; diff --git a/misc/windows/package.bash b/misc/windows/package.bash new file mode 100755 index 00000000000..92e90931718 --- /dev/null +++ b/misc/windows/package.bash @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Copyright 2010 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 + +ISCC="C:/Program Files/Inno Setup 5/ISCC.exe" + +echo "%%%%% Checking for Inno Setup %%%%%" 1>&2 +if ! test -f "$ISCC"; then + ISCC="C:/Program Files (x86)/Inno Setup 5/ISCC.exe" + if ! test -f "$ISCC"; then + echo "No Inno Setup installation found" 1>&2 + exit 1 + fi +fi + +echo "%%%%% Checking the packager's path %%%%%" 1>&2 +if ! test -f ../../src/env.bash; then + echo "package.bash must be run from $GOROOT/misc/windows" 1>&2 +fi + +echo "%%%%% Setting the go package version info %%%%%" 1>&2 +ver="$(bash ../../src/version.bash | sed 's/ .*//')" + +rm -rf go +mkdir go + +echo "%%%%% Cloning the go tree %%%%%" 1>&2 +hg clone -r $(hg id -n | sed 's/+//') $(hg root) go + +rm -rf ./go/.hg ./go/.hgignore ./go/.hgtags + +echo "%%%%% Copying pkg and bin %%%%%" 1>&2 +cp -a ../../pkg go/pkg +cp -a ../../bin go/bin + +echo "%%%%% Starting zip packaging %%%%%" 1>&2 +7za a -tzip -mx=9 gowin386"_"$ver.zip "go/" >/dev/null + +echo "%%%%% Starting installer packaging %%%%%" 1>&2 +"$ISCC" //dAppName=Go //dAppVersion=386"_"$ver //dAppNameLower=go installer.iss >/dev/null + +