Release/GrowlMail/scripts/postflight.sh
author Peter Hosey <hg@boredzo.org>
Fri Sep 11 05:52:27 2009 -0700 (2009-09-11)
changeset 4393 6328e4c4dd23
parent 4282 c4c6f65d4d31
child 4405 33214e271a53
permissions -rwxr-xr-x
Changed GrowlMail's Installer package to install to a subdirectory of /tmp, and then move these files to the correct place within the user's Home folder, as suggested by Jonathan “Wolf” Rentzsch on Twitter.

This sucks, but it appears to be the only way to overcome x-radar://problem/7215243, where Installer installs to the base of the volume that the user's Home folder is on instead of to the Home folder itself.
     1 #!/bin/sh
     2 
     3 # Move our temporary installation into the real destination.
     4 mkdir -p ~/Library/Mail/Bundles
     5 rm -R ~/Library/Mail/Bundles/GrowlMail.mailbundle
     6 mv "$2/GrowlMail.mailbundle" ~/Library/Mail/Bundles
     7 
     8 ######
     9 # Note that we are running sudo'd, so these defaults will be written to
    10 # /Library/Preferences/com.apple.mail.plist
    11 #
    12 # Mail must NOT be running by the time this script executes
    13 ######
    14 if [ `whoami` == root ] ; then
    15     #defaults acts funky when asked to write to the root domain but seems to work with a full path
    16 	domain=/Library/Preferences/com.apple.mail
    17 else
    18     domain=com.apple.mail
    19 fi
    20 
    21 macosx_minor_version=$(sw_vers | /usr/bin/sed -Ene 's/.*[[:space:]]10\.([0-9][0-9]*)\.*[0-9]*/\1/p;')
    22 if [[ "$macosx_minor_version" == "" ]]; then
    23 	echo 'Unrecognized Mac OS X version!' > /dev/stderr
    24 	sw_vers > /dev/stderr
    25 elif [[ "$macosx_minor_version" -eq 5 ]]; then
    26 	bundle_compatibility_version=3
    27 else
    28 	bundle_compatibility_version=4
    29 fi
    30 
    31 defaults write "$domain" EnableBundles -bool YES
    32 
    33 # Mac OS X 10.5's Mail.app requires bundle version 3 or greater
    34 defaults write "$domain" BundleCompatibilityVersion -int "$bundle_compatibility_version"