From http://www.jwz.org/xscreensaver/xscreensaver-5.36.tar.gz
[xscreensaver] / OSX / installer.sh
index 329a7c18574ae7425563053a7038d005920761a9..fa92beb3a962e2ef84cb36da926d478e163aef3e 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# XScreenSaver, Copyright © 2013-2014 Jamie Zawinski <jwz@jwz.org>
+# XScreenSaver, Copyright © 2013-2016 Jamie Zawinski <jwz@jwz.org>
 #
 # Permission to use, copy, modify, distribute, and sell this software and its
 # documentation for any purpose is hereby granted without fee, provided that
@@ -67,11 +67,14 @@ DST1="$DSTVOLUME/Library/Screen Savers"
 DST2="$DSTVOLUME/Applications"
 PU="$DSTVOLUME/$HOME/Library/Screen Savers"
 
-# 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.
+# Because of Sparkle.framework weirdness, "XScreenSaverUpdater.app" is
+# in the DMG as a compressed tar file instead of an app, and we unpack
+# it when installing.  Without this, auto-updates won't work: If there's
+# an .app there, Sparkle thinks that "XScreenSaverUpdater.app" is the
+# thing it should be updating instead of "Install Everything.pkg".
 #
-UPDATER=".XScreenSaverUpdater.app"
+UPDATER_SRC="XScreenSaver.updater"
+UPDATER_DST="XScreenSaverUpdater.app"
 
 
 cd "$SRC" || error "The 'Screen Savers' folder does not exist.
@@ -94,20 +97,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} "$UPDATER" ; 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
 
-  f2=`echo "$f" | sed 's/^\.//'`   # install ".foo" as "foo"
-  DD="$DST/$f2"
+  DD="$DST/$f"
 
   echo "Installing $DD" >&2
   rm -rf "$DD" || error "Unable to delete $DD"
-  cp -pR "$f" "$DD/" || 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"