~ubuntu-branches/ubuntu/trusty/aegisub/trusty

« back to all changes in this revision

Viewing changes to scripts/osx-dmg.sh

  • Committer: Package Import Robot
  • Author(s): Sebastian Reichel
  • Date: 2012-03-16 22:58:00 UTC
  • Revision ID: package-import@ubuntu.com-20120316225800-yfb8h9e5n04rk46a
Tags: upstream-2.1.9
ImportĀ upstreamĀ versionĀ 2.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# USAGE: osx-dmg.sh [Bundle Directory] "[Package Name]"
 
3
#
 
4
# Amar Takhar <verm@aegisub.org>
 
5
#
 
6
# -------------------------------------------------------------------------------------
 
7
# This script is based on osx-dmg.sh from the Inkscape Project http://www.inkscape.org/
 
8
#
 
9
# Jean-Olivier Irisson <jo.irisson@gmail.com>
 
10
# Michael Wybrow <mjwybrow@users.sourceforge.net>
 
11
#
 
12
# Copyright (C) 2006-2010
 
13
# Released under GNU GPL, read the file 'COPYING' from the Inkscape project for more
 
14
# information.
 
15
 
 
16
TMP_DMG="temp_dmg"
 
17
PKG_DIR="${1}.app"
 
18
PKG_NAME="${2}"
 
19
PKG_NAME_RW="${1}_rw.dmg"
 
20
PKG_NAME_VOLUME="${2}"
 
21
 
 
22
if ! test -d "${PKG_DIR}"; then
 
23
  echo "\"${PKG_DIR}\" does not exist, please run 'make osx-bundle'"
 
24
  exit 1;
 
25
fi
 
26
 
 
27
rm -rf "${TMP_DMG}" "${PKG_NAME}.dmg"
 
28
mkdir -v "${TMP_DMG}"
 
29
echo
 
30
echo "---- Copying ${1} into ${TMP_DMG}/ ----"
 
31
cp -R "${PKG_DIR}" "${TMP_DMG}"
 
32
 
 
33
echo
 
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"
 
39
 
 
40
echo
 
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 $?
 
43
 
 
44
echo
 
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}"
 
48
 
 
49
echo
 
50
echo "---- Setting bless -openfolder ----"
 
51
bless -openfolder "/Volumes/${PKG_NAME_VOLUME}" || exit $?
 
52
 
 
53
echo
 
54
echo "---- Setting root icon using SetFile ----"
 
55
SetFile -a C "/Volumes/${PKG_NAME_VOLUME}" || exit $?
 
56
 
 
57
echo
 
58
if test -n "${SET_STYLE}"; then
 
59
  echo "---- Running AppleScript to set style ----"
 
60
  SCRIPT_TMP=`mktemp /tmp/aegisub_dmg_as.XXX`
 
61
 
 
62
  sed -f scripts/osx-bundle.sed packages/osx_dmg/dmg_set_style.applescript > ${SCRIPT_TMP}
 
63
 
 
64
  /usr/bin/osacompile -o ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
 
65
 
 
66
  /usr/bin/osascript ${SCRIPT_TMP}.scpt
 
67
  open "/Volumes/${PKG_NAME_VOLUME}"
 
68
 
 
69
  echo "********************************************************"
 
70
  echo "Please move the window to the center of the screen then"
 
71
  echo "close it."
 
72
  echo "********************************************************"
 
73
  echo
 
74
  echo "PRESS ENTER WHEN DONE"
 
75
  open "/Volumes/${PKG_NAME_VOLUME}"
 
76
  read -e DUMB
 
77
 
 
78
  hdiutil detach "${DEV_NAME}"
 
79
 
 
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}"
 
82
 
 
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}"
 
86
 
 
87
  rm -rf "${TMP_DMG}"  "${PKG_NAME_RW}" ${SCRIPT_TMP}.scpt ${SCRIPT_TMP}
 
88
  exit 0
 
89
else
 
90
  echo "---- Installing DS_Store ----"
 
91
  cp -v packages/osx_dmg/DS_Store "/Volumes/${PKG_NAME_VOLUME}/.DS_Store"
 
92
fi
 
93
 
 
94
echo
 
95
echo "---- Detaching ----"
 
96
/usr/bin/hdiutil detach "${DEV_NAME}" -force || exit $?
 
97
 
 
98
echo
 
99
echo "---- Compressing ----"
 
100
/usr/bin/hdiutil convert "${PKG_NAME_RW}" -format UDZO -imagekey zlib-level=9 -o "${PKG_NAME}.dmg" || exit $?
 
101
 
 
102
echo
 
103
echo "---- Removing \"${TMP_DMG}\", \"${PKG_NAME_RW}\" ----"
 
104
rm -rf "${TMP_DMG}"  "${PKG_NAME_RW}" || exit $?
 
105
 
 
106
echo
 
107
echo "Done!"