2
# USAGE: osx-dmg.sh [Bundle Directory] "[Package Name]"
4
# Amar Takhar <verm@aegisub.org>
6
# -------------------------------------------------------------------------------------
7
# This script is based on osx-dmg.sh from the Inkscape Project http://www.inkscape.org/
9
# Jean-Olivier Irisson <jo.irisson@gmail.com>
10
# Michael Wybrow <mjwybrow@users.sourceforge.net>
12
# Copyright (C) 2006-2010
13
# Released under GNU GPL, read the file 'COPYING' from the Inkscape project for more
19
PKG_NAME_RW="${1}_rw.dmg"
20
PKG_NAME_VOLUME="${2}"
22
if ! test -d "${PKG_DIR}"; then
23
echo "\"${PKG_DIR}\" does not exist, please run 'make osx-bundle'"
27
rm -rf "${TMP_DMG}" "${PKG_NAME}.dmg"
30
echo "---- Copying ${1} into ${TMP_DMG}/ ----"
31
cp -R "${PKG_DIR}" "${TMP_DMG}"
34
echo "---- Setting up ----"
35
ln -vsf /Applications "${TMP_DMG}"
36
mkdir -v "${TMP_DMG}/.background"
37
cp -v packages/osx_dmg/dmg_background.png "${TMP_DMG}/.background/background.png"
38
cp -v packages/osx_bundle/Contents/Resources/Aegisub.icns "${TMP_DMG}/.VolumeIcon.icns"
41
echo "---- Creating image ----"
42
/usr/bin/hdiutil create -srcfolder "${TMP_DMG}" -volname "${PKG_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "${PKG_NAME_RW}" || exit $?
45
echo "---- Mounting image ----"
46
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "${PKG_NAME_RW}" |awk '/Apple_partition_scheme/ {print $1}'` || exit $?
47
echo "Device name: ${DEV_NAME}"
50
echo "---- Setting bless -openfolder ----"
51
bless -openfolder "/Volumes/${PKG_NAME_VOLUME}" || exit $?
54
echo "---- Setting root icon using SetFile ----"
55
SetFile -a C "/Volumes/${PKG_NAME_VOLUME}" || exit $?
58
if test -n "${SET_STYLE}"; then
59
echo "---- Running AppleScript to set style ----"
60
SCRIPT_TMP=`mktemp /tmp/aegisub_dmg_as.XXX`
62
sed -f scripts/osx-bundle.sed packages/osx_dmg/dmg_set_style.applescript > ${SCRIPT_TMP}
64
/usr/bin/osacompile -o ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
66
/usr/bin/osascript ${SCRIPT_TMP}.scpt
67
open "/Volumes/${PKG_NAME_VOLUME}"
69
echo "********************************************************"
70
echo "Please move the window to the center of the screen then"
72
echo "********************************************************"
74
echo "PRESS ENTER WHEN DONE"
75
open "/Volumes/${PKG_NAME_VOLUME}"
78
hdiutil detach "${DEV_NAME}"
80
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "${PKG_NAME_RW}" |awk '/Apple_partition_scheme/ {print $1}'` || exit $?
81
echo "Device name: ${DEV_NAME}"
83
cp -v "/Volumes/${PKG_NAME_VOLUME}/.DS_Store" packages/osx_dmg/DS_Store
84
SetFile -a v packages/osx_dmg/DS_Store
85
hdiutil detach "${DEV_NAME}"
87
rm -rf "${TMP_DMG}" "${PKG_NAME_RW}" ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
90
echo "---- Installing DS_Store ----"
91
cp -v packages/osx_dmg/DS_Store "/Volumes/${PKG_NAME_VOLUME}/.DS_Store"
95
echo "---- Detaching ----"
96
/usr/bin/hdiutil detach "${DEV_NAME}" -force || exit $?
99
echo "---- Compressing ----"
100
/usr/bin/hdiutil convert "${PKG_NAME_RW}" -format UDZO -imagekey zlib-level=9 -o "${PKG_NAME}.dmg" || exit $?
103
echo "---- Removing \"${TMP_DMG}\", \"${PKG_NAME_RW}\" ----"
104
rm -rf "${TMP_DMG}" "${PKG_NAME_RW}" || exit $?