Code

* macosx/osx-dmg.sh: Added code to allow packagers to create a new
[inkscape.git] / packaging / macosx / osx-dmg.sh
1 #!/bin/sh
2 #
3 # Inkscape packaging script for Mac OS X
4 #
5 # The script creates a read-write disk image, 
6 # copies Inkscape in it, customizes its appearance using a 
7 # previously created .DS_Store file (inkscape.ds_store),
8 # and then compresses the disk image for distribution.
9 #
10 # Authors:
11 #       Jean-Olivier Irisson <jo.irisson@gmail.com>
12 #       Michael Wybrow <mjwybrow@users.sourceforge.net>
13 #
14 # Copyright 2006
15 # Licensed under GNU General Public License
16 #
17 #
18 # How to update the disk image layout:
19 # ------------------------------------
20 #
21 # Modify the 'dmg_background.svg' file and generate a new 
22 # 'dmg_background.png' file.
23 #
24 # Update the AppleScript file 'dmg_set_style.scpt'.
25 #
26 # Run this script with the '-s' option.  It will apply the
27 # 'dmg_set_style.scpt' AppleScript file, and then prompt the
28 # user to check the window size # and position before writing
29 # a new 'inkscape.ds_store' file to work around a bug in Finder
30 # and AppleScript.  The updated 'inkscape.ds_store' will need 
31 # to be commited to the repository when this is done.
32 #
34 set_ds_store=false
35 if [ "$1" = "-s" ]; then
36         set_ds_store=true
37         shift
38 fi
40 RWNAME="RWinkscape.dmg"
41 VOLNAME="Inkscape"
42 FIRSTTIME="false"
43 TMPDIR="/tmp/dmg-$$"
45 # Create temp directory with desired contents of the release volume.
46 rm -rf "$TMPDIR"
47 mkdir "$TMPDIR"
49 echo "Copying files to temp directory..."
50 # Copy Inkscape.app folder.
51 cp -rf ../Inkscape.app "$TMPDIR"/
53 # link to Applications in order to drag and drop inkscape onto it.
54 ln -sf /Applications "$TMPDIR"/
55         
56 # Copy a background image inside a hidden directory so the image
57 # file itself won't be shown.
58 mkdir "$TMPDIR/.background"
59 cp dmg_background.png "$TMPDIR/.background/background.png"
61 AUTOOPENOPT=
62 if [ ${set_ds_store} = "false" ]; then
63         # Copy the .DS_Store file which contains information about
64         # window size, appearance, etc.  Most of this can be set
65         # with Apple script but involves # user intervention so we
66         # just keep a copy of the correct settings and use that instead.
67         cp inkscape.ds_store "$TMPDIR/.DS_Store"
68         AUTOOPENOPT=-noautoopen
69 fi
71 # Create a new RW image from the temp directory.
72 echo "Creating a new RW disk image..."
73 rm -f "$RWNAME"
74 /usr/bin/hdiutil create -srcfolder "tmp-dmg" -volname "$VOLNAME" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "$RWNAME"
76 # We're finished with the temp directory, remove it.
77 rm -rf "$TMPDIR"
79 # Mount the created image.
80 echo "Mounting the disk image..."
81 MOUNT_DIR="/Volumes/$VOLNAME"
82 DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $AUTOOPENOPT  "$RWNAME" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
84 # Have the disk image window open automatically when mounted.
85 bless -openfolder /Volumes/$VOLNAME
87 if [ ${set_ds_store} = "true" ]; then
88         /usr/bin/osascript dmg_set_style.scpt
90         open "/Volumes/$VOLNAME"
91         # BUG: one needs to move and close the window manually for the
92         # changes in appearance to be retained... 
93         echo " 
94         ************************************** 
95         *  Please move the disk image window * 
96         *    to the center of the screen     *  
97         *   then close it and press enter    * 
98         ************************************** 
99         " 
100         read -e DUMB
102         # .DS_Store files aren't written till the disk is unmounted, 
103         # or finder is restarted.
104         hdiutil detach "$DEV_NAME"
105         AUTOOPENOPT=-noautoopen
106         DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $AUTOOPENOPT  "$RWNAME" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
107         echo
108         echo "New inkscape.ds_store file written."
109         cp /Volumes/$VOLNAME/.DS_Store ./inkscape.ds_store
111         # Unmount the disk image.
112         hdiutil detach "$DEV_NAME"
113         rm -f "$RWNAME"
115         exit 0
116 fi
118 # Unmount the disk image.
119 hdiutil detach "$DEV_NAME"
121 # Create the offical release image by compressing the RW one.
122 DATE=`date "+%Y%m%d"`
123 /usr/bin/hdiutil convert "$RWNAME" -format UDZO -imagekey zlib-level=9 -o "../Inkscape_$DATE.dmg"
124 rm -f "$RWNAME"