2008-12-29 09:07:06 +01:00
|
|
|
#!/bin/sh
|
2010-01-21 01:37:04 +01:00
|
|
|
# USAGE: osx-dmg.sh [Bundle Directory] "[Package Name]"
|
2008-12-29 09:07:06 +01:00
|
|
|
#
|
2010-01-21 01:37:04 +01:00
|
|
|
# Amar Takhar <verm@aegisub.org>
|
|
|
|
#
|
|
|
|
# -------------------------------------------------------------------------------------
|
2008-12-29 09:07:06 +01:00
|
|
|
# This script is based on osx-dmg.sh from the Inkscape Project http://www.inkscape.org/
|
|
|
|
#
|
|
|
|
# Jean-Olivier Irisson <jo.irisson@gmail.com>
|
|
|
|
# Michael Wybrow <mjwybrow@users.sourceforge.net>
|
|
|
|
#
|
2010-01-21 01:37:04 +01:00
|
|
|
# Copyright (C) 2006-2010
|
|
|
|
# Released under GNU GPL, read the file 'COPYING' from the Inkscape project for more
|
|
|
|
# information.
|
2008-12-29 09:07:06 +01:00
|
|
|
|
2013-10-17 19:08:27 +02:00
|
|
|
set -e
|
|
|
|
|
2008-12-29 09:07:06 +01:00
|
|
|
TMP_DMG="temp_dmg"
|
2012-08-19 23:33:50 +02:00
|
|
|
PKG_DIR="Aegisub.app"
|
|
|
|
PKG_NAME="Aegisub-${1}"
|
|
|
|
PKG_NAME_RW="Aegisub-${1}_rw.dmg"
|
|
|
|
PKG_NAME_VOLUME="Aegisub-${1}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
2008-12-29 11:36:21 +01:00
|
|
|
if ! test -d "${PKG_DIR}"; then
|
2009-06-02 02:16:45 +02:00
|
|
|
echo "\"${PKG_DIR}\" does not exist, please run 'make osx-bundle'"
|
2008-12-29 11:36:21 +01:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2009-06-02 02:16:45 +02:00
|
|
|
rm -rf "${TMP_DMG}" "${PKG_NAME}.dmg"
|
|
|
|
mkdir -v "${TMP_DMG}"
|
2008-12-29 09:07:06 +01:00
|
|
|
echo
|
|
|
|
echo "---- Copying ${1} into ${TMP_DMG}/ ----"
|
2009-06-02 02:16:45 +02:00
|
|
|
cp -R "${PKG_DIR}" "${TMP_DMG}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Setting up ----"
|
|
|
|
ln -vsf /Applications "${TMP_DMG}"
|
2009-06-02 02:16:45 +02:00
|
|
|
mkdir -v "${TMP_DMG}/.background"
|
|
|
|
cp -v packages/osx_dmg/dmg_background.png "${TMP_DMG}/.background/background.png"
|
|
|
|
cp -v packages/osx_bundle/Contents/Resources/Aegisub.icns "${TMP_DMG}/.VolumeIcon.icns"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Creating image ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
/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}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Mounting image ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "${PKG_NAME_RW}" |awk '/GUID_partition_scheme/ {print $1}'`
|
2008-12-29 09:07:06 +01:00
|
|
|
echo "Device name: ${DEV_NAME}"
|
|
|
|
|
|
|
|
echo
|
2008-12-30 12:38:08 +01:00
|
|
|
echo "---- Setting bless -openfolder ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
bless -openfolder "/Volumes/${PKG_NAME_VOLUME}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
2008-12-29 12:05:30 +01:00
|
|
|
echo
|
|
|
|
echo "---- Setting root icon using SetFile ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
SetFile -a C "/Volumes/${PKG_NAME_VOLUME}"
|
2008-12-29 12:05:30 +01:00
|
|
|
|
2010-01-21 01:37:04 +01:00
|
|
|
echo
|
|
|
|
if test -n "${SET_STYLE}"; then
|
|
|
|
echo "---- Running AppleScript to set style ----"
|
|
|
|
SCRIPT_TMP=`mktemp /tmp/aegisub_dmg_as.XXX`
|
|
|
|
|
|
|
|
sed -f scripts/osx-bundle.sed packages/osx_dmg/dmg_set_style.applescript > ${SCRIPT_TMP}
|
|
|
|
|
|
|
|
/usr/bin/osacompile -o ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
|
|
|
|
|
|
|
|
/usr/bin/osascript ${SCRIPT_TMP}.scpt
|
|
|
|
open "/Volumes/${PKG_NAME_VOLUME}"
|
|
|
|
|
|
|
|
echo "********************************************************"
|
|
|
|
echo "Please move the window to the center of the screen then"
|
|
|
|
echo "close it."
|
|
|
|
echo "********************************************************"
|
|
|
|
echo
|
|
|
|
echo "PRESS ENTER WHEN DONE"
|
|
|
|
open "/Volumes/${PKG_NAME_VOLUME}"
|
|
|
|
read -e DUMB
|
|
|
|
|
|
|
|
hdiutil detach "${DEV_NAME}"
|
|
|
|
|
2013-10-17 19:08:27 +02:00
|
|
|
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "${PKG_NAME_RW}" |awk '/GUID_partition_scheme/ {print $1}'`
|
2010-01-21 01:37:04 +01:00
|
|
|
echo "Device name: ${DEV_NAME}"
|
|
|
|
|
|
|
|
cp -v "/Volumes/${PKG_NAME_VOLUME}/.DS_Store" packages/osx_dmg/DS_Store
|
|
|
|
SetFile -a v packages/osx_dmg/DS_Store
|
|
|
|
hdiutil detach "${DEV_NAME}"
|
|
|
|
|
|
|
|
rm -rf "${TMP_DMG}" "${PKG_NAME_RW}" ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "---- Installing DS_Store ----"
|
|
|
|
cp -v packages/osx_dmg/DS_Store "/Volumes/${PKG_NAME_VOLUME}/.DS_Store"
|
|
|
|
fi
|
|
|
|
|
2008-12-29 09:07:06 +01:00
|
|
|
echo
|
|
|
|
echo "---- Detaching ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
echo /usr/bin/hdiutil detach "${DEV_NAME}" -force
|
|
|
|
/usr/bin/hdiutil detach "${DEV_NAME}" -force
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Compressing ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
/usr/bin/hdiutil convert "${PKG_NAME_RW}" -format UDBZ -imagekey bzip2-level=9 -o "${PKG_NAME}.dmg"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
2009-06-02 02:16:45 +02:00
|
|
|
echo "---- Removing \"${TMP_DMG}\", \"${PKG_NAME_RW}\" ----"
|
2013-10-17 19:08:27 +02:00
|
|
|
rm -rf "${TMP_DMG}" "${PKG_NAME_RW}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Done!"
|