source: launchers/macosx/osx_create_dmg.sh @ 3b38f5a

Last change on this file since 3b38f5a was 3b38f5a, checked in by meeh <meeh@…>, 2 years ago

Mac OS X Launcher:

  • In general bugfixes
  • Introduced event manager for better control flow
  • Splitted RouterStatusView? to own file
  • Added shell script to setup and produce dmg file
  • Property mode set to 100755
File size: 3.5 KB
Line 
1#!/bin/bash
2
3APP_NAME="I2PLauncher"
4VERSION="0.9.36"
5DMG_BACKGROUND_IMG="Background.png"
6
7APP_EXE="${APP_NAME}.app/Contents/MacOS/${APP_NAME}"
8VOL_NAME="${APP_NAME} ${VERSION}"
9DMG_TMP="${VOL_NAME}-temp.dmg"
10DMG_FINAL="${VOL_NAME}.dmg"
11STAGING_DIR="/tmp/mkdmg$$"
12
13# Check the background image DPI and convert it if it isn't 72x72
14_BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
15_BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
16
17if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then
18   echo "WARNING: The background image's DPI is not 72.  This will result in distorted backgrounds on Mac OS X 10.7+."
19   echo "         I will convert it to 72 DPI for you."
20
21   _DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}"
22
23   sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_IMG} --out ${_DMG_BACKGROUND_TMP}
24
25   DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}"
26fi
27
28# clear out any old data
29rm -rf "${STAGING_DIR}" "${DMG_TMP}" "${DMG_FINAL}"
30
31# copy over the stuff we want in the final disk image to our staging dir
32mkdir -p "${STAGING_DIR}"
33cp -rpf "${APP_NAME}.app" "${STAGING_DIR}"
34# ... cp anything else you want in the DMG - documentation, etc.
35
36# figure out how big our DMG needs to be
37#  assumes our contents are at least 1M!
38SIZE=`du -sh "${STAGING_DIR}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
39SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`
40
41if [ $? -ne 0 ]; then
42   echo "Error: Cannot compute size of staging dir"
43   exit
44fi
45
46# create the temp DMG file
47hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \
48      -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"
49
50echo "Created DMG: ${DMG_TMP}"
51
52# mount it and save the device
53DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \
54         egrep '^/dev/' | sed 1q | awk '{print $1}')
55
56sleep 2
57
58# add a link to the Applications dir
59echo "Add link to /Applications"
60pushd /Volumes/"${VOL_NAME}"
61ln -s /Applications
62popd
63
64# add a background image
65mkdir /Volumes/"${VOL_NAME}"/.background
66cp "${DMG_BACKGROUND_IMG}" /Volumes/"${VOL_NAME}"/.background/
67
68# tell the Finder to resize the window, set the background,
69#  change the icon size, place the icons in the right position, etc.
70echo '
71   tell application "Finder"
72     tell disk "'${VOL_NAME}'"
73           open
74           set current view of container window to icon view
75           set toolbar visible of container window to false
76           set statusbar visible of container window to false
77           set the bounds of container window to {400, 100, 920, 440}
78           set viewOptions to the icon view options of container window
79           set arrangement of viewOptions to not arranged
80           set icon size of viewOptions to 72
81           set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG}'"
82           set position of item "'${APP_NAME}'.app" of container window to {160, 205}
83           set position of item "Applications" of container window to {360, 205}
84           close
85           open
86           update without registering applications
87           delay 2
88     end tell
89   end tell
90' | osascript
91
92sync
93
94# unmount it
95hdiutil detach "${DEVICE}"
96
97# now make the final image a compressed disk image
98echo "Creating compressed image"
99hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"
100
101# clean up
102rm -rf "${DMG_TMP}"
103rm -rf "${STAGING_DIR}"
104
105echo 'Done.'
106
107exit
Note: See TracBrowser for help on using the repository browser.