Created
January 27, 2015 12:12
-
-
Save krzyspmac/394ef99ca3a13e960a2d to your computer and use it in GitHub Desktop.
Create distribution DMG with application, link to /Applications folder and backdrop image in MacOS X.
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 | |
# This script needs to have specific folders set. See the code below. | |
if [[ -z "$2" ]]; then | |
echo >&2 "MakeReleaseDMG creates a release disk image ready to be uploaded to the server." | |
echo >&2 "Remember to turn on Support for Assistive Devices in Universal Control" | |
echo >&2 "MakeReleaseDMG <Xcode archive path> <output dmg path>" | |
exit 1 | |
fi | |
XCODE_ARCHIVE="$1" | |
DMG_OUTPUT="$2" | |
APPLICATION_NAME="SingleIssueCreator" | |
BASEDIR=$(dirname $0) | |
DIR=`pwd`'/'$BASEDIR | |
# Background image | |
BACKGROUND_IMGNAME="DmgBackground.png" | |
BACKGROUND_IMG=$DIR"/"$BACKGROUND_IMGNAME | |
# Create an empty disk image | |
BASE_FOLDER=$DIR"/Base" | |
TMP_DMG="/tmp/"$RANDOM".dmg" | |
VOL_NAME="SingleIssueCreator" | |
hdiutil create -srcfolder $BASE_FOLDER -volname $VOL_NAME -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size 40000k $TMP_DMG | |
# Mount the newly created image | |
MOUNTED_PATH=$(hdiutil attach -readwrite -noverify -noautoopen $TMP_DMG | egrep '^/dev/' | awk '{print $3}') | |
# Copy image | |
mkdir $MOUNTED_PATH/.background | |
cp $BACKGROUND_IMG $MOUNTED_PATH/.background/$BACKGROUND_IMGNAME | |
# Copy the application | |
IN_APPLICATION=$XCODE_ARCHIVE"/Products/Applications/"$APPLICATION_NAME".app" | |
cp -r "$IN_APPLICATION" $MOUNTED_PATH | |
# Make Application alias | |
ln -s /Applications $MOUNTED_PATH/Applications | |
# Rearrange by using AppleScript | |
cat $DIR/Rearrange.scpt | sed -e "s/REPLACE_DISK_NAME/$VOL_NAME/" -e "s/REPLACE_APPLICATION_NAME/$APPLICATION_NAME/" | osascript | |
# Finalize DMG | |
chmod -Rf go-w $MOUNTED_PATH | |
sync | |
sync | |
hdiutil detach $MOUNTED_PATH | |
hdiutil convert $TMP_DMG -format UDZO -imagekey zlib-level=9 -o "$DMG_OUTPUT" | |
rm -rf $TMP_DMG | |
# Sign update using Sparkle | |
echo "Signed update using dsa private key:" | |
$DIR/../Frameworks/Sparkle-1.8.0/bin/sign_update.sh "$DMG_OUTPUT" $DIR/../Frameworks/Sparkle-1.8.0/bin/dsa_priv.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment