X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=packaging%2Fmacosx%2Fosx-dmg.sh;h=91aefdd41d6be74cdae6f0b878635009c5773064;hb=a4d12a5147f3d1d6b568a326e39ef5dca384248d;hp=7402f6c10f52905dd727da5a018cd1099e4357d9;hpb=408e9460dd70bf3c99f32030e78a901bf959da89;p=inkscape.git diff --git a/packaging/macosx/osx-dmg.sh b/packaging/macosx/osx-dmg.sh index 7402f6c10..91aefdd41 100755 --- a/packaging/macosx/osx-dmg.sh +++ b/packaging/macosx/osx-dmg.sh @@ -3,8 +3,10 @@ # Inkscape packaging script for Mac OS X # # The script creates a read-write disk image, -# copies Inkscape in it, customizes its appearance through -# an applescript and compresses the disk image for distribution +# copies Inkscape in it, copies additional python packages +# if needed, customizes its appearance using a +# previously created .DS_Store file (inkscape*.ds_store), +# and then compresses the disk image for distribution. # # Authors: # Jean-Olivier Irisson @@ -13,54 +15,147 @@ # Copyright 2006 # Licensed under GNU General Public License # +# +# How to update the disk image layout: +# ------------------------------------ +# +# Modify the 'dmg_background.svg' file and generate a new +# 'dmg_background.png' file. +# +# Update the AppleScript file 'dmg_set_style.scpt'. +# +# Run this script with the '-s' option. It will apply the +# 'dmg_set_style.scpt' AppleScript file, and then prompt the +# user to check the window size and position before writing +# a new 'inkscape.ds_store' file to work around a bug in Finder +# and AppleScript. The updated 'inkscape.ds_store' will need +# to be commited to the repository when this is done. +# +# Defaults +set_ds_store=false +add_python=false +ds_store_file="inkscape.ds_store" +package="Inkscape.app" RWNAME="RWinkscape.dmg" VOLNAME="Inkscape" -FIRSTTIME="false" TMPDIR="/tmp/dmg-$$" +AUTOOPENOPT= + +# Parse command line arguments +while [ "$1" != "" ] +do + case $1 in + -s) + set_ds_store=true ;; + -py|--with-python) + add_python=true + python_dir="$2" + ds_store_file="inkscape_python.ds_store" + shift 1 ;; + esac + shift 1 +done +# some checks +if [ ! -e "$package" ]; then + echo "Cannot find $package" + exit 1 +fi +if [ ${add_python} = "true" ]; then + if [ ! -e "$python_dir" ]; then + echo "Cannot find your python packages directory" + exit 1 + fi +fi # Create temp directory with desired contents of the release volume. rm -rf "$TMPDIR" mkdir "$TMPDIR" -# Copy Inkscape.app folder. -cp -rf ../Inkscape.app "$TMPDIR"/ - +echo "Copying files to temp directory..." +# Inkscape itself +# copy Inkscape.app +cp -rf "$package" "$TMPDIR"/ # link to Applications in order to drag and drop inkscape onto it. ln -sf /Applications "$TMPDIR"/ - + +# Python +if [ ${add_python} = "true" ]; then + # copy python libraries + cp -rf "$python_dir"/* "$TMPDIR"/ + # link python environment in order to drag and drop inkscape onto it + ln -sf /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages "$TMPDIR"/Python\ site-packages +fi + # Copy a background image inside a hidden directory so the image # file itself won't be shown. mkdir "$TMPDIR/.background" cp dmg_background.png "$TMPDIR/.background/background.png" -# Copy the .DS_Store file which contains information about window size, -# appearance, etc. Most of this can be set with Apple script but involves -# user intervention so we just keep a copy of the correct settings and -# use that instead. -cp inkscape.ds_store "$TMPDIR/.DS_Store" +# If the appearance settings are not to be modified we just copy them +if [ ${set_ds_store} = "false" ]; then + # Copy the .DS_Store file which contains information about + # window size, appearance, etc. Most of this can be set + # with Apple script but involves user intervention so we + # just keep a copy of the correct settings and use that instead. + cp $ds_store_file "$TMPDIR/.DS_Store" + AUTOOPENOPT=-noautoopen +fi # Create a new RW image from the temp directory. +echo "Creating a new RW disk image..." rm -f "$RWNAME" -/usr/bin/hdiutil create -srcfolder "tmp-dmg" -volname "$VOLNAME" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "$RWNAME" +/usr/bin/hdiutil create -srcfolder "$TMPDIR" -volname "$VOLNAME" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "$RWNAME" # We're finished with the temp directory, remove it. rm -rf "$TMPDIR" # Mount the created image. +echo "Mounting the disk image..." MOUNT_DIR="/Volumes/$VOLNAME" -DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify -noautoopen "$RWNAME" | egrep '^/dev/' | sed 1q | awk '{print $1}'` - -# /usr/bin/osascript dmg_set_style.scpt +DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $AUTOOPENOPT "$RWNAME" | egrep '^/dev/' | sed 1q | awk '{print $1}'` # Have the disk image window open automatically when mounted. bless -openfolder /Volumes/$VOLNAME +# In case the apperance has to be modified, mount the image and apply the base settings to it via Applescript +if [ ${set_ds_store} = "true" ]; then + /usr/bin/osascript dmg_set_style.scpt + + open "/Volumes/$VOLNAME" + # BUG: one needs to move and close the window manually for the + # changes in appearance to be retained... + echo " + ************************************** + * Please move the disk image window * + * to the center of the screen * + * then close it and press enter * + ************************************** + " + read -e DUMB + + # .DS_Store files aren't written till the disk is unmounted, + # or finder is restarted. + hdiutil detach "$DEV_NAME" + AUTOOPENOPT=-noautoopen + DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $AUTOOPENOPT "$RWNAME" | egrep '^/dev/' | sed 1q | awk '{print $1}'` + echo + echo "New $ds_store_file file written. Re-run $0 without the -s option to use it" + cp /Volumes/$VOLNAME/.DS_Store ./$ds_store_file + SetFile -a v ./$ds_store_file + + # Unmount the disk image. + hdiutil detach "$DEV_NAME" + rm -f "$RWNAME" + + exit 0 +fi + # Unmount the disk image. hdiutil detach "$DEV_NAME" # Create the offical release image by compressing the RW one. -DATE=`date "+%Y%m%d"` -/usr/bin/hdiutil convert "$RWNAME" -format UDZO -imagekey zlib-level=9 -o "../Inkscape_$DATE.dmg" +/usr/bin/hdiutil convert "$RWNAME" -format UDZO -imagekey zlib-level=9 -o "Inkscape.dmg" rm -f "$RWNAME" +exit 0