X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Finstaller.sh;h=05e1b23f36e0e3200a8f4e9f7e6749b8fdf752c4;hb=d5186197bc394e10a4402f7f6d23fbb14103bc50;hp=06a1a135fe9f0df872030315bfa1b72b259c25f7;hpb=ffcd2e7e3da122dbba5c4188e05d3a63d0ede26e;p=xscreensaver diff --git a/OSX/installer.sh b/OSX/installer.sh index 06a1a135..05e1b23f 100755 --- a/OSX/installer.sh +++ b/OSX/installer.sh @@ -1,5 +1,5 @@ #!/bin/sh -# XScreenSaver, Copyright © 2013 Jamie Zawinski +# XScreenSaver, Copyright © 2013-2014 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -19,37 +19,61 @@ #exec >/tmp/xscreensaver.log 2>&1 #set -x +DEBUG=0 +REQUIRED_SPACE=160 # MB. Highly approximate. + export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PATH" -REQUIRED_SPACE=140 # MB. Highly approximate. +function error() { + echo "XScreenSaver Installer: Error: $@" >&2 -DEBUG=0 + # Using "System Events" says "No user interaction allowed" on 10.9. + # But using "SystemUIServer" or "Automator Runner" still seems to work. + # + runner="System Events" + if [ -d "/System/Library/CoreServices/SystemUIServer.app" ]; then + runner="SystemUIServer" + elif [ -d "/System/Library/CoreServices/Automator Runner.app" ]; then + runner="Automator Runner" + fi + + ( + osascript <<__EOF__ + tell app "$runner" to \ + display dialog "$@" \ + buttons "Bummer" \ + default button 1 \ + with icon 0 \ + with title "Installation Error" +__EOF__ + ) /dev/null 2>&1 & + exit 1 +} + + +#if[ x"$DSTVOLUME" = x ]; then error "DSTVOLUME unset"; fi +if [ x"$PACKAGE_PATH" = x ]; then error "PACKAGE_PATH unset"; fi +if [ x"$HOME" = x ]; then error "HOME unset"; fi -if [ x"$USER" = xjwz ]; then - DEBUG=1 -fi echo "Destination: $DSTVOLUME" >&2 -if [ "$DEBUG" != 0 ]; then - DSTVOLUME=/tmp -fi +if [ x"$USER" = xjwz ]; then DEBUG=1; fi + +if [ "$DEBUG" != 0 ]; then DSTVOLUME=/tmp; fi SRC=`dirname "$PACKAGE_PATH"`/"Screen Savers" DST1="$DSTVOLUME/Library/Screen Savers" DST2="$DSTVOLUME/Applications" PU="$DSTVOLUME/$HOME/Library/Screen Savers" -UPDATER="XScreenSaverUpdater.app" -function error() { - echo "Error: $@" >&2 - ( - osascript <<__EOF__ - tell app "System Events" to display dialog "$@" buttons "Bummer" default button 1 with icon 0 with title "Installation Error" -__EOF__ - ) /dev/null 2>&1 & - exit 1 -} +# Because of Sparkle.framework weirdness, ".XScreenSaverUpdater.app" +# is in the DMG, and we remove the leading dot when installing it. +# Without this, auto-updates won't work right. +# +UPDATER_SRC="XScreenSaver.updater" +UPDATER_DST="XScreenSaverUpdater.app" + cd "$SRC" || error "The 'Screen Savers' folder does not exist. @@ -71,17 +95,26 @@ mkdir -p "$DST2" || error "Unable to create directory $DST2/" # Install the savers and the updater in /System/Library/Screen Savers/ # Install the other apps in /Applications/ # -for f in *.{saver,app} ; do +for f in *.{saver,app} "$UPDATER_SRC" ; do EXT=`echo "$f" | sed 's/^.*\.//'` - if [ "$EXT" = "app" -a "$f" != "$UPDATER" ]; then + if [ "$f" = "$UPDATER_SRC" ]; then + DST="$DST1" + elif [ "$EXT" = "app" ]; then DST="$DST2" else DST="$DST1" fi + DD="$DST/$f" + echo "Installing $DD" >&2 rm -rf "$DD" || error "Unable to delete $DD" - cp -pR "$f" "$DST/" || error "Unable to install $f in $DST/" + + if [ "$f" = "$UPDATER_SRC" ]; then + ( cd "$DST/" && tar -xzf - ) < "$f" || error "Unable to unpack $f in $DST/" + else + cp -pR "$f" "$DD" || error "Unable to install $f in $DST/" + fi # Eliminate the "this was downloaded from the interweb" warning. xattr -r -d com.apple.quarantine "$DD"