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
|
|
|
|
|
2021-10-12 09:37:49 +02:00
|
|
|
SRC_DIR="${1}"
|
|
|
|
BUILD_DIR="${2}"
|
|
|
|
AEGI_VER="${3}"
|
|
|
|
|
|
|
|
PKG_NAME="Aegisub-${AEGI_VER}"
|
|
|
|
PKG_NAME_VOLUME="${PKG_NAME}"
|
|
|
|
|
|
|
|
PKG_DIR="${BUILD_DIR}/Aegisub.app"
|
|
|
|
DMG_TMP_DIR="${BUILD_DIR}/temp_dmg"
|
|
|
|
DMG_PATH="${BUILD_DIR}/${PKG_NAME}.dmg"
|
|
|
|
DMG_RW_PATH="${BUILD_DIR}/${PKG_NAME}_rw.dmg"
|
|
|
|
|
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
|
|
|
|
|
2008-12-29 09:07:06 +01:00
|
|
|
echo
|
2021-10-12 09:37:49 +02:00
|
|
|
echo "---- Removing old \"${DMG_TMP_DIR}\", \"${DMG_PATH}\", \"${DMG_RW_PATH}\" ----"
|
|
|
|
rm -rf "${DMG_TMP_DIR}" "${DMG_PATH}" "${DMG_RW_PATH}"
|
|
|
|
mkdir -v "${DMG_TMP_DIR}"
|
|
|
|
echo
|
|
|
|
echo "---- Copying ${AEGI_VER} into ${DMG_TMP_DIR}/ ----"
|
|
|
|
cp -R "${PKG_DIR}" "${DMG_TMP_DIR}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Setting up ----"
|
2021-10-12 09:37:49 +02:00
|
|
|
ln -vsf /Applications "${DMG_TMP_DIR}"
|
|
|
|
mkdir -v "${DMG_TMP_DIR}/.background"
|
|
|
|
cp -v "${SRC_DIR}/packages/osx_dmg/dmg_background.png" "${DMG_TMP_DIR}/.background/background.png"
|
|
|
|
cp -v "${SRC_DIR}/packages/osx_bundle/Contents/Resources/Aegisub.icns" "${DMG_TMP_DIR}/.VolumeIcon.icns"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Creating image ----"
|
2021-10-12 09:37:49 +02:00
|
|
|
/usr/bin/hdiutil create -srcfolder "${DMG_TMP_DIR}" -volname "${PKG_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "${DMG_RW_PATH}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "---- Mounting image ----"
|
2021-10-12 09:37:49 +02:00
|
|
|
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "${DMG_RW_PATH}" |awk '/GUID_partition_scheme/ {print $1}'`
|
2008-12-29 09:07:06 +01:00
|
|
|
echo "Device name: ${DEV_NAME}"
|
|
|
|
|
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`
|
|
|
|
|
2021-10-12 09:37:49 +02:00
|
|
|
sed -f "${SRC_DIR}/scripts/osx-bundle.sed" "${SRC_DIR}/packages/osx_dmg/dmg_set_style.applescript" > ${SCRIPT_TMP}
|
2010-01-21 01:37:04 +01:00
|
|
|
|
|
|
|
/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}"
|
|
|
|
|
2021-10-12 09:37:49 +02:00
|
|
|
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "${DMG_RW_PATH}" |awk '/GUID_partition_scheme/ {print $1}'`
|
2010-01-21 01:37:04 +01:00
|
|
|
echo "Device name: ${DEV_NAME}"
|
|
|
|
|
2021-10-12 09:37:49 +02:00
|
|
|
cp -v "/Volumes/${PKG_NAME_VOLUME}/.DS_Store" "${SRC_DIR}/packages/osx_dmg/DS_Store"
|
|
|
|
SetFile -a v "${SRC_DIR}/packages/osx_dmg/DS_Store"
|
2010-01-21 01:37:04 +01:00
|
|
|
hdiutil detach "${DEV_NAME}"
|
|
|
|
|
2021-10-12 09:37:49 +02:00
|
|
|
rm -rf "${DMG_TMP_DIR}" "${DMG_RW_PATH}" ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
|
2010-01-21 01:37:04 +01:00
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "---- Installing DS_Store ----"
|
2021-10-12 09:37:49 +02:00
|
|
|
cp -v "${SRC_DIR}/packages/osx_dmg/DS_Store" "/Volumes/${PKG_NAME_VOLUME}/.DS_Store"
|
2010-01-21 01:37:04 +01:00
|
|
|
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 ----"
|
2021-10-12 09:37:49 +02:00
|
|
|
/usr/bin/hdiutil convert "${DMG_RW_PATH}" -format UDBZ -imagekey bzip2-level=9 -o "${DMG_PATH}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
2021-10-12 09:37:49 +02:00
|
|
|
echo "---- Removing temp dmg \"${DMG_RW_PATH}\" ----"
|
|
|
|
rm -rf "${DMG_RW_PATH}"
|
2008-12-29 09:07:06 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Done!"
|