From http://www.jwz.org/xscreensaver/xscreensaver-5.25.tar.gz
[xscreensaver] / OSX / installer.sh
index e2a155dd3dcd8235f99976df343bdc8441c0e3da..06a1a135fe9f0df872030315bfa1b72b259c25f7 100755 (executable)
@@ -19,6 +19,8 @@
 #exec >/tmp/xscreensaver.log 2>&1
 #set -x
 
+export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PATH"
+
 REQUIRED_SPACE=140     # MB. Highly approximate.
 
 DEBUG=0
@@ -66,17 +68,30 @@ fi
 mkdir -p "$DST1" || error "Unable to create directory $DST1/"
 mkdir -p "$DST2" || error "Unable to create directory $DST2/"
 
-# Install the savers in /System/Library/Screen Savers/
-# Plus the updater.
+# Install the savers and the updater in /System/Library/Screen Savers/
+# Install the other apps in /Applications/
 #
-for f in *.saver "$UPDATER" ; do
-  DD="$DST1/$f"
+for f in *.{saver,app} ; do
+  EXT=`echo "$f" | sed 's/^.*\.//'`
+  if [ "$EXT" = "app" -a "$f" != "$UPDATER" ]; 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" "$DST1/" || error "Unable to install $f in $DST1/"
+  cp -pR "$f" "$DST/" || error "Unable to install $f in $DST/"
+
+  # Eliminate the "this was downloaded from the interweb" warning.
   xattr -r -d com.apple.quarantine "$DD"
 
-  # If this saver is also installed in the per-user directory,
+  if [ "$EXT" = "app" ]; then
+    # Eliminate the "this is from an unknown developer" warning.
+    spctl --add "$DD"
+  fi
+
+  # If this saver or app is also installed in the per-user directory,
   # delete that copy so that we don't have conflicts.
   #
   if [ "$DEBUG" = 0 ]; then
@@ -84,20 +99,6 @@ for f in *.saver "$UPDATER" ; do
   fi
 done
 
-
-# Install the apps in /Applications/
-# But not the updater.
-#
-for f in *.app ; do
-  if [ "$f" != "$UPDATER" ]; then
-    DD="$DST2/$f"
-    echo "Installing $DD" >&2
-    rm -rf "$DD" || error "Unable to delete $DD"
-    cp -pR "$f" "$DST2/" || error "Unable to install $f in $DST2/"
-    xattr -r -d com.apple.quarantine "$DD"
-  fi
-done
-
 # Launch System Preferences with the Screen Saver pane selected.
 #
 open /System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane &