Wrap text
Report abuse
#!/bin/bash
#===============================================================================
#
# FILE: install_safari_beta.sh
#
# USAGE: ./install_safari_beta.sh
#
# DESCRIPTION: Installs a stand alone version of the Safari beta browser.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: Credit http://vasi.dyndns.org:3128/svn/SafariBeta/HOWTO.txt
# AUTHOR: SpookyET, spookyet@gmail.com
# COMPANY: ---
# VERSION: 1.0
# CREATED: 2008-02-27 02:52 UTC
# REVISION: ---
#===============================================================================
DISK_IMAGE_MD5="150f262c68147d7efac77e9517efd115"
LAUNCHER_MD5="dee6b4dfcdf2179f264e950e7b0d60ad"
DISK_IMAGE_NAME="Safari4.0BetaLeo.dmg"
DISK_IMAGE_VOLUME_NAME="Safari 4 (Manual) (Leo)"
LAUNCHER_NAME="WebKitLauncher.zip"
DISK_IMAGE_DOWNLOAD_URL="http://appldnld.apple.com.edgesuite.net/content.info.apple.com/Safari4/061-4669.20090224.lpsaf/${DISK_IMAGE_NAME}"
LAUNCHER_DOWNLOAD_URL="http://vasi.dyndns.org:3128/svn/SafariBeta/${LAUNCHER_NAME}"
DISK_IMAGE_MOUNTED_PATH="/Volumes/Safari 4 (Manual) (Leo)"
PACKAGE_NAME="Safari4.0BetaLeo.pkg"
PACKAGE_PATH="${DISK_IMAGE_MOUNTED_PATH}/${PACKAGE_NAME}"
function cleanup()
{
echo "Cleaning up..."
rm -rf BetaFiles
hdiutil detach "/Volumes/${DISK_IMAGE_VOLUME_NAME}" > /dev/null
rm -rf $DISK_IMAGE_NAME
rm -rf $LAUNCHER_NAME
rm -rf $PACKAGE_NAME
exit;
}
echo "Downloading Safari..."
curl -O ${DISK_IMAGE_DOWNLOAD_URL}
echo "Downloading WebKit Launcher..."
curl -O ${LAUNCHER_DOWNLOAD_URL}
echo "Checking downloaded files..."
LAUNCHER_MD5_RETURN=`md5 $LAUNCHER_NAME | sed -e 's/MD5 (WebKitLauncher.zip) = //g'`
DISK_IMAGE_MD5_RETURN=`md5 ${DISK_IMAGE_NAME} | sed -e 's/MD5 (Safari4.0BetaLeo.dmg) = //g'`
if [[ "$DISK_IMAGE_MD5" != "$DISK_IMAGE_MD5_RETURN" ]]
then
echo "ERROR: The Safari disk image is corrupt."
cleanup
fi
if [[ "$LAUNCHER_MD5" != "$LAUNCHER_MD5_RETURN" ]]
then
echo "ERROR: The WebKit Launcher archive is corrupt."
cleanup
fi
echo "Unzipping WebKit Launcher..."
unzip $LAUNCHER_NAME > /dev/null
echo "Mounting Safari disk image..."
hdiutil attach $DISK_IMAGE_NAME > /dev/null
if [[ -z "$PACKAGE_PATH" ]]
then
echo "ERROR: Could not find the Safari package."
cleanup
fi;
echo "Building Safari Beta..."
cp "/Volumes/${DISK_IMAGE_VOLUME_NAME}/${PACKAGE_NAME}" .
mkdir BetaFiles
cd BetaFiles
xar -xf ../Safari4.0BetaLeo.pkg
pax -rz -pp -f Safari4.0BetaLeo.pkg/Payload
cd ..
cp -R BetaFiles/Applications/* WebKitLauncher.app/Contents/Resources/
find BetaFiles -name \*.framework \
| /usr/bin/xargs -J% cp -R % WebKitLauncher.app/Contents/Resources/
find WebKitLauncher.app/Contents/Resources/ -name Frameworks \
| /usr/bin/xargs rm -r
touch WebKitLauncher.app
echo "Disabling plugins..."
defaults write SafariBeta 'NSUseCocoaInputServers' -bool false
echo "Installing in '/Applications/Safari 4 Beta.app'..."
mv WebKitLauncher.app "/Applications/Safari 4 Beta.app"
echo "To uninstall, simply drag 'Safari 4 Beta' to Trash."
cleanup