Changes to annotated step scripts: dart-editor-installer-* builders will build installer

R=ricow@google.com

Review URL: https://codereview.chromium.org//28773003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28857 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
kustermann@google.com 2013-10-18 14:12:34 +00:00
parent e227dbd349
commit 2d51255501
4 changed files with 91 additions and 35 deletions

View file

@ -87,6 +87,8 @@ def ProcessTools(mode, name, version):
toolsBuildScript = os.path.join('.', 'editor', 'build', 'build.py')
build_installer = name.startswith('dart-editor-installer')
# TODO(devoncarew): should we move this into GetBuildInfo()?
# get the latest changed revision from the current repository sub-tree
version = GetLatestChangedRevision()
@ -95,6 +97,8 @@ def ProcessTools(mode, name, version):
cmds = [sys.executable, toolsBuildScript,
'--mode=' + mode, '--revision=' + version,
'--name=' + name, '--out=' + outdir]
if build_installer:
cmds.append('--build-installer')
local_env = EnvironmentWithoutBotoConfig()
#if 'linux' in name:
# javahome = os.path.join(os.path.expanduser('~'), 'jdk1.6.0_25')

View file

@ -76,6 +76,7 @@ class GCSNamer(object):
-{linux,macos,windows}-{ia32,x64}-release.zip
- /sdk/dartsdk-{linux,macos,windows}-{ia32,x64}-release.zip
- /editor/darteditor-{linux,macos,windows}-{ia32,x64}.zip
- /editor/darteditor-installer-macos-{ia32,x64}.dmg
- /editor-eclipse-update
/{index.html,features/,plugins/,artifacts.jar,content.jar}
"""
@ -98,6 +99,10 @@ class GCSNamer(object):
return '/'.join([self.editor_directory(revision),
self.editor_zipfilename(system, arch)])
def editor_installer_zipfilepath(self, revision, system, arch, extension):
return '/'.join([self.editor_directory(revision),
self.editor_installer_zipfilename(system, arch, extension)])
def sdk_zipfilepath(self, revision, system, arch, mode):
return '/'.join([self.sdk_directory(revision),
self.sdk_zipfilename(system, arch, mode)])
@ -139,6 +144,11 @@ class GCSNamer(object):
return 'darteditor-%s-%s.zip' % (
SYSTEM_RENAMES[system], ARCH_RENAMES[arch])
def editor_installer_zipfilename(self, system, arch, extension):
assert extension in ['dmg']
return 'darteditor-installer-%s-%s.%s' % (
SYSTEM_RENAMES[system], ARCH_RENAMES[arch], extension)
def sdk_zipfilename(self, system, arch, mode):
assert mode in Mode.ALL_MODES
return 'dartsdk-%s-%s-%s.zip' % (

View file

@ -9,29 +9,26 @@
# Fail if a command failed
set -e
set -o errexit
set -o nounset
if [ $# -ne 4 ]; then
echo "Usage $0 <output.dmg> <app-folder> <icon.icns> <volume-name>"
echo "Usage $0 <output.dmg> <raw-editor-bundle> <folder-icon> <volume-name>"
exit 1
fi
OUTPUT_DMG_FILE=$1
INPUT_APP_FOLDER_PATH=$2
INPUT_ICON=$3
INPUT_FOLDER_PATH=$2
FOLDER_ICON=$3
INPUT_VOLUME_NAME=$4
APP_FOLDER_NAME=$(basename "$INPUT_APP_FOLDER_PATH")
FOLDER_NAME="Dart"
VOLUME_MOUNTPOINT="/Volumes/$INPUT_VOLUME_NAME"
SPARSEIMAGE="$OUTPUT_DMG_FILE.sparseimage"
# Input validations
if [ "${INPUT_APP_FOLDER_PATH##*.}" != "app" ]; then
echo "Application folder has to end in '.app' " \
"(but was $INPUT_APP_FOLDER_PATH)."
exit 1
fi
if [ "${INPUT_ICON##*.}" != "icns" ]; then
echo "Volume icon has to end in '.icns'."
if [ ! -d "$INPUT_FOLDER_PATH" ]; then
echo "Editor bundle folder does not exist ($INPUT_FOLDER_PATH)"
exit 1
fi
@ -48,43 +45,75 @@ if [ -f "$OUTPUT_DMG_FILE" ]; then
rm "$OUTPUT_DMG_FILE"
fi
# This function will set (or replace) the icon of a folder.
# Finder displays a default folder icon. Since the installer
# will consist of a folder and a link to "/Applications", we want
# the folder to have a nice icon.
# In order to make Finder display a custom icon, we need to
# - Have a "FOLDER/Icon\r" file which contains the icon resource
# (i.e. the metadata of this file will contain an icon)
# - Have the 'custom icon' attribute set on "FOLDER"
# Additionally we mark the "FOLDER/Icon\r" file as invisible, so it
# is not shown in Finder (although it's visible on the commandline).
replace_folder_icon() {
FOLDER="$1"
ICON="$2"
TEMP_ICON_RESOURCE='/tmp/icns.rsrc'
ICON_RESOURCE="$FOLDER"/$'Icon\r'
# Add finder icon to the image file
sips -i "$ICON" > /dev/null
# Extract the finder icon resource
DeRez -only icns "$ICON" > "$TEMP_ICON_RESOURCE"
# Create the icon resource
rm -f "$ICON_RESOURCE"
Rez -append "$TEMP_ICON_RESOURCE" -o "$ICON_RESOURCE"
rm "$TEMP_ICON_RESOURCE"
# Set the 'custom icon' attribute on $FOLDER
SetFile -a C "$FOLDER"
# Make the $ICON_RESOURCE invisible for finder
SetFile -a V "$ICON_RESOURCE"
}
# Create a new image and attach it
hdiutil create -size 300m -type SPARSE -volname "$INPUT_VOLUME_NAME" -fs \
hdiutil create -size 400m -type SPARSE -volname "$INPUT_VOLUME_NAME" -fs \
'Journaled HFS+' "$SPARSEIMAGE"
hdiutil attach "$SPARSEIMAGE"
# Add link to /Applications (so the user can drag-and-drop into it)
ln -s /Applications "$VOLUME_MOUNTPOINT/"
# Copy our application
ditto "$INPUT_APP_FOLDER_PATH" "$VOLUME_MOUNTPOINT/$APP_FOLDER_NAME"
# Make sure that the folder gets opened when mounting the image
ditto "$INPUT_FOLDER_PATH" "$VOLUME_MOUNTPOINT/$FOLDER_NAME"
# Set custom icon on this folder
replace_folder_icon "$VOLUME_MOUNTPOINT/$FOLDER_NAME" "$FOLDER_ICON"
# Make sure that the dmg gets opened when mounting the image
bless --folder "$VOLUME_MOUNTPOINT" --openfolder "$VOLUME_MOUNTPOINT"
# Copy the volume icon
cp "$INPUT_ICON" "$VOLUME_MOUNTPOINT/.VolumeIcon.icns"
# Set the 'custom-icon' attribute on the volume
SetFile -a C "$VOLUME_MOUNTPOINT"
# Use an applescript to setup the layout of the folder.
osascript << EOF
tell application "Finder"
tell disk "$INPUT_VOLUME_NAME"
open
tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set position to {100, 100}
set bounds to {100, 100, 512, 256}
end tell
tell icon view options of container window
set arrangement to not arranged
set icon size to 128
end tell
set position of item "$APP_FOLDER_NAME" to {64, 64}
set position of item "Applications" to {320, 64}
tell disk "$INPUT_VOLUME_NAME"
open
tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set position to {100, 100}
set bounds to {100, 100, 512, 256}
end tell
tell icon view options of container window
set arrangement to not arranged
set icon size to 128
end tell
set position of item "$FOLDER_NAME" to {64, 64}
set position of item "Applications" to {320, 64}
eject
end tell
end tell
end tell
EOF

View file

@ -462,6 +462,19 @@ class TempDir(object):
def __exit__(self, *_):
shutil.rmtree(self._temp_dir, ignore_errors=True)
class ChangedWorkingDirectory(object):
def __init__(self, working_directory):
self._working_directory = working_directory
def __enter__(self):
self._old_cwd = os.getcwd()
print "Enter directory = ", self._working_directory
os.chdir(self._working_directory)
def __exit__(self, *_):
print "Enter directory = ", self._old_cwd
os.chdir(self._old_cwd)
if __name__ == "__main__":
import sys