4
# osx-dmg [-s] -p /path/to/Inkscape.app
6
# The script creates a read-write disk image,
7
# copies Inkscape in it, customizes its appearance using a
8
# previously created .DS_Store file (inkscape.ds_store),
9
# and then compresses the disk image for distribution.
12
# Jean-Olivier Irisson <jo.irisson@gmail.com>
13
# Michael Wybrow <mjwybrow@users.sourceforge.net>
15
# Copyright (C) 2006-2007
16
# Released under GNU GPL, read the file 'COPYING' for more information
19
# How to update the disk image layout:
20
# ------------------------------------
22
# Modify the 'dmg_background.svg' file and generate a new
23
# 'dmg_background.png' file.
25
# Update the AppleScript file 'dmg_set_style.scpt'.
27
# Run this script with the '-s' option. It will apply the
28
# 'dmg_set_style.scpt' AppleScript file, and then prompt the
29
# user to check the window size and position before writing
30
# a new 'inkscape.ds_store' file to work around a bug in Finder
31
# and AppleScript. The updated 'inkscape.ds_store' will need
32
# to be commited to the repository when this is done.
37
ds_store_file="inkscape.ds_store"
39
rw_name="RWinkscape.dmg"
40
volume_name="Inkscape"
45
#----------------------------------------------------------
49
Create a custom dmg file to distribute Inkscape
52
$0 [-s] -p /path/to/Inkscape.app
55
\033[1m-h,--help\033[0m
56
display this help message
58
set a new apperance (do not actually creates a bundle)
59
\033[1m-p,--package\033[0m
60
set the path to the Inkscape.app that should be copie
65
# Parse command line arguments
78
echo "Invalid command line option"
85
if [ ! -e "$package" ]; then
86
echo "Cannot find package: $package"
90
echo "\n\033[1mCREATE INKSCAPE DISK IMAGE\033[0m\n"
92
# Create temp directory with desired contents of the release volume.
96
echo "\033[1mCopying files to temp directory\033[0m"
99
cp -rf "$package" "$tmp_dir"/
100
# link to Applications in order to drag and drop inkscape onto it
101
ln -sf /Applications "$tmp_dir"/
103
# Copy a background image inside a hidden directory so the image file itself won't be shown.
104
mkdir "$tmp_dir/.background"
105
cp dmg_background.png "$tmp_dir/.background/background.png"
107
# If the appearance settings are not to be modified we just copy them
108
if [ ${set_ds_store} = "false" ]; then
109
# Copy the .DS_Store file which contains information about
110
# window size, appearance, etc. Most of this can be set
111
# with Apple script but involves user intervention so we
112
# just keep a copy of the correct settings and use that instead.
113
cp $ds_store_file "$tmp_dir/.DS_Store"
114
auto_open_opt=-noautoopen
117
# Create a new RW image from the temp directory.
118
echo "\033[1mCreating a temporary disk image\033[0m"
120
/usr/bin/hdiutil create -srcfolder "$tmp_dir" -volname "$volume_name" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "$rw_name"
122
# We're finished with the temp directory, remove it.
125
# Mount the created image.
126
MOUNT_DIR="/Volumes/$volume_name"
127
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $auto_open_opt "$rw_name" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
129
# Have the disk image window open automatically when mounted.
130
bless -openfolder /Volumes/$volume_name
132
# In case the apperance has to be modified, mount the image and apply the base settings to it via Applescript
133
if [ ${set_ds_store} = "true" ]; then
134
/usr/bin/osascript dmg_set_style.scpt
136
open "/Volumes/$volume_name"
137
# BUG: one needs to move and close the window manually for the
138
# changes in appearance to be retained...
140
**************************************
141
* Please move the disk image window *
142
* to the center of the screen *
143
* then close it and press enter *
144
**************************************
148
# .DS_Store files aren't written till the disk is unmounted, or finder is restarted.
149
hdiutil detach "$DEV_NAME"
150
auto_open_opt=-noautoopen
151
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $auto_open_opt "$rw_name" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
153
echo "New $ds_store_file file written. Re-run $0 without the -s option to use it"
154
cp /Volumes/$volume_name/.DS_Store ./$ds_store_file
155
SetFile -a v ./$ds_store_file
157
# Unmount the disk image.
158
hdiutil detach "$DEV_NAME"
164
# Unmount the disk image.
165
hdiutil detach "$DEV_NAME"
167
# Create the offical release image by compressing the RW one.
168
echo "\033[1mCompressing the final disk image\033[0m"
169
img_name="Inkscape.dmg"
170
# TODO make this a command line option
171
if [ -e "$img_name" ]; then
172
echo "$img_name already exists."
175
/usr/bin/hdiutil convert "$rw_name" -format UDZO -imagekey zlib-level=9 -o "$img_name"