Created
October 15, 2015 22:34
-
-
Save probablycorey/05f6cab9f59070aa0680 to your computer and use it in GitHub Desktop.
dmg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
cd "$(dirname $0)/.." | |
DIST_PATH=dist | |
APP_NAME=Toolbelt | |
APP_PATH="$DIST_PATH/$APP_NAME.app" | |
BACKGROUND_PNG=app/assets/install.tiff | |
( | |
cd $(dirname $BACKGROUND_PNG) | |
tiffutil -cathidpicheck install.png [email protected] -out install.tiff 2> /dev/null | |
) | |
# DMG building based on http://stackoverflow.com/questions/96882/how-do-i-create-a-nice-looking-dmg-for-mac-os-x-using-command-line-tools | |
SIZE=$(expr $(du -sH $APP_PATH | cut -f1 ) + 5000) | |
TEMP_DMG_PATH=$DIST_PATH/tmp | |
TEMP_DMG="$TEMP_DMG_PATH.dmg" | |
VOLNAME="Toolbelt" | |
MOUNT_DIR="/Volumes/$VOLNAME" | |
if [ -d "$MOUNT_DIR" ]; then | |
hdiutil detach "$MOUNT_DIR" | |
fi | |
hdiutil create -srcfolder "$APP_PATH" -volname "$VOLNAME" -format UDRW -size ${SIZE}k "$TEMP_DMG_PATH" | |
DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "$TEMP_DMG" | head -n 1 | cut -f1) | |
mkdir "$MOUNT_DIR/.background" | |
cp "$BACKGROUND_PNG" "$MOUNT_DIR/.background/$(basename $BACKGROUND_PNG)" | |
echo ' | |
tell application "Finder" | |
tell disk "'$VOLNAME'" | |
open | |
set current view of container window to icon view | |
set toolbar visible of container window to false | |
set statusbar visible of container window to false | |
set the bounds of container window to {400, 100, 800, 600} | |
set theViewOptions to the icon view options of container window | |
set arrangement of theViewOptions to not arranged | |
set icon size of theViewOptions to 100 | |
set background picture of theViewOptions to file ".background:'$(basename $BACKGROUND_PNG)'" | |
set position of item "'$APP_NAME'" of container window to {200, 300} | |
close | |
update without registering applications | |
delay 5 | |
end tell | |
end tell | |
' | osascript | |
# HACK: output is sent to /dev/null to supress permission errors when chmodding .Trashes | |
chmod -Rf go-w "/Volumes/$VOLNAME" >& /dev/null || true | |
sync | |
sync | |
hdiutil detach $DEVICE | |
hdiutil convert "$TEMP_DMG" -format UDZO -imagekey zlib-level=9 -o "$DIST_PATH/toolbelt.dmg" | |
rm -rf "$TEMP_DMG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment