Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: tools/mac_build_editor_dmg.sh

Issue 16831019: Initial support for mac installers. Currently only on our editor builders on FYI (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/mac_build_editor_bundle.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by
4 # BSD-style license that can be found in the LICENSE file.
5
6 # This is partly based on
7 # https://bitbucket.org/rmacnak/nsvm/src/
8 # b2de52432a2baff9c4ada099430fb16a771d34ef/vm/onebuild/installer-Darwin.gmk
9
10 # Fail if a command failed
11 set -e
12
13 if [ $# -ne 4 ]; then
14 echo "Usage $0 <output.dmg> <app-folder> <icon.icns> <volume-name>"
15 exit 1
16 fi
17
18 OUTPUT_DMG_FILE=$1
19 INPUT_APP_FOLDER_PATH=$2
20 INPUT_ICON=$3
21 INPUT_VOLUME_NAME=$4
22
23 APP_FOLDER_NAME=$(basename "$INPUT_APP_FOLDER_PATH")
24 VOLUME_MOUNTPOINT="/Volumes/$INPUT_VOLUME_NAME"
25 SPARSEIMAGE="$OUTPUT_DMG_FILE.sparseimage"
26
27 # Input validations
28 if [ "${INPUT_APP_FOLDER_PATH##*.}" != "app" ]; then
29 echo "Application folder has to end in '.app' " \
30 "(but was $INPUT_APP_FOLDER_PATH)."
31 exit 1
32 fi
33 if [ "${INPUT_ICON##*.}" != "icns" ]; then
34 echo "Volume icon has to end in '.icns'."
35 exit 1
36 fi
37
38 # If an old image is still mounted, umount it
39 if [ -e "$VOLUME_MOUNTPOINT" ]; then
40 hdiutil eject "$VOLUME_MOUNTPOINT"
41 fi
42
43 # Remove old output files
44 if [ -f "$SPARSEIMAGE" ]; then
45 rm "$SPARSEIMAGE"
46 fi
47 if [ -f "$OUTPUT_DMG_FILE" ]; then
48 rm "$OUTPUT_DMG_FILE"
49 fi
50
51 # Create a new image and attach it
52 hdiutil create -size 300m -type SPARSE -volname "$INPUT_VOLUME_NAME" -fs \
53 'Journaled HFS+' "$SPARSEIMAGE"
54 hdiutil attach "$SPARSEIMAGE"
55
56 # Add link to /Applications (so the user can drag-and-drop into it)
57 ln -s /Applications "$VOLUME_MOUNTPOINT/"
58 # Copy our application
59 ditto "$INPUT_APP_FOLDER_PATH" "$VOLUME_MOUNTPOINT/$APP_FOLDER_NAME"
60 # Make sure that the folder gets opened when mounting the image
61 bless --folder "$VOLUME_MOUNTPOINT" --openfolder "$VOLUME_MOUNTPOINT"
62 # Copy the volume icon
63 cp "$INPUT_ICON" "$VOLUME_MOUNTPOINT/.VolumeIcon.icns"
64
65 # Set the 'custom-icon' attribute on the volume
66 SetFile -a C "$VOLUME_MOUNTPOINT"
67
68 # Use an applescript to setup the layout of the folder.
69 osascript << EOF
70 tell application "Finder"
71 tell disk "$INPUT_VOLUME_NAME"
72 open
73 tell container window
74 set current view to icon view
75 set toolbar visible to false
76 set statusbar visible to false
77 set position to {100, 100}
78 set bounds to {100, 100, 512, 256}
79 end tell
80 tell icon view options of container window
81 set arrangement to not arranged
82 set icon size to 128
83 end tell
84 set position of item "$APP_FOLDER_NAME" to {64, 64}
85 set position of item "Applications" to {320, 64}
86 eject
87 end tell
88 end tell
89 EOF
90
91 # Wait until the script above has umounted the image
92 while [ -e "$VOLUME_MOUNTPOINT" ]; do
93 echo "Waiting for Finder to eject $VOLUME_MOUNTPOINT"
94 sleep 2
95 done
96
97 # Compress the sparse image
98 hdiutil convert "$SPARSEIMAGE" -format UDBZ -o "$OUTPUT_DMG_FILE"
99
100 # Remove sparse image
101 rm "$SPARSEIMAGE"
102
OLDNEW
« no previous file with comments | « tools/mac_build_editor_bundle.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698