WebKit is the foundation to Apple's web services. It's an integral part of Safari and is Open Source. As a result of this (Or because of this? Maybe there's no relation at all..) the WebKit team frequently posts nightly builds of the latest WebKit sources online for anyone to run and try out. However there isn't any official way to automatically update WebKit to the latest available version.
I personally like to have the latest of everything whenever possible, so not being able to automatically update WebKit annoyed me. So, as a result, here's a quick bash script that I've hacked together to update to the latest WebKit build.
The script runs at 7am every day, as I'm usually asleep by then so it works out pretty well. If this isn't a good time for you (I'm aware some people wake up at 7am for whatever reason..) go to the plist example that's linked to below the bash script and change the 7 in 7 to whatever time works best for you.
Additionally, the script logs which WebKit build was downloaded and what build got replaced in ~/Library/Logs/WebKitUpdate.log. You can just view this in Console.app though.
Save the following bash script as webkitupdate.sh and place it in /Library/Scripts/
#-----------------------------------------------------------------------------
#!/bin/sh
#Automatically update to the latest WebKit nightly build.
#By Zach Drayer
#Set environment up
LOGGING_LOCATION="$HOME"/Library/Logs/WebKitUpdate.log
WEBKIT_BACKUP_LOCATION=""$HOME"/Documents/WebKit Backup/"
#Creates a temp working dir for WebKit and necessary files to be downloaded to
WEBKIT_TEMP_INSTALL_LOCATION="/tmp/WebKit-$RANDOM"
mkdir "$WEBKIT_TEMP_INSTALL_LOCATION"/
cd "$WEBKIT_TEMP_INSTALL_LOCATION"/
#Finds out what version of WebKit the nightly is at
curl -LOs "http://nightly.webkit.org/index.html"
WEBKIT_NIGHTLY_BUILT_VERSION=`cat index.html | grep trunk/mac | grep dmg \
| grep Mac | cut -c 79-83`
#Checks if WebKit needs updating or not
if [ -d /Applications/WebKit.app ]; then
WEBKIT_INSTALLED_VERSION=`cat \
/Applications/WebKit.app/Contents/Resources/VERSION`
if [ "$WEBKIT_NIGHTLY_BUILT_VERSION" == "$WEBKIT_INSTALLED_VERSION" ]; then
exit
fi
fi
#Checks if WebKit is running or not
ps aux | grep Web >> web.txt
cat web.txt | grep WebKit >> web2.txt
WEBKIT_RUNNING=`cat web2.txt`
if [ "$WEBKIT_RUNNING" != "" ]; then
kill -9 `cat web2.txt | sed s/"$USER"\ \ \ \ \ \ //g | cut -c 1-5`
fi
#Back WebKit up
if [ -d /Applications/Webkit.app ]; then
#Comment out this if/elseif block if you dont want to back WebKit up
#Start commenting below --v
if [ -d "$WEBKIT_BACKUP_LOCATION" ]; then
mv /Applications/WebKit.app "$WEBKIT_BACKUP_LOCATION"WebKit-r"\
$WEBKIT_INSTALLED_VERSION".app
else
mkdir "$WEBKIT_BACKUP_LOCATION"
mv /Applications/WebKit.app "$WEBKIT_BACKUP_LOCATION"WebKit-r"\
$WEBKIT_INSTALLED_VERSION".app
fi
echo "Downloading WebKit-r""$WEBKIT_NIGHTLY_BUILT_VERSION"" now"
curl -LOs "http://nightly.webkit.org/files/trunk/mac/WebKit-SVN-r"\
$WEBKIT_NIGHTLY_BUILT_VERSION".dmg"
else
#Stop Commmenting here --^
#Also uncomment the next line if you dont back WebKit up
# rm -rf /Applications/WebKit.app
echo "Downloading WebKit-r""$WEBKIT_NIGHTLY_BUILT_VERSION"" now"
curl -LOs "http://nightly.webkit.org/files/trunk/mac/WebKit-SVN-r"\
$WEBKIT_NIGHTLY_BUILT_VERSION".dmg"
fi
#Install WebKit
hdiutil attach -quiet "$WEBKIT_TEMP_INSTALL_LOCATION"/WebKit-SVN-r"\
$WEBKIT_NIGHTLY_BUILT_VERSION".dmg
cp -R /Volumes/WebKit/WebKit.app /Applications/
hdiutil detach -quiet /Volumes/WebKit
rm -rf "$WEBKIT_TEMP_INSTALL_LOCATION"/
echo "WebKit build " $WEBKIT_NIGHTLY_BUILT_VERSION " replaced build "\
$WEBKIT_INSTALLED_VERSION " on " `date` >> \
$HOME/Library/Logs/WebKitUpdate.log
#-----------------------------------------------------------------------------
And the plist needed can be downloaded here. Just ctrl + click and "Save As.." and move it to /Library/LaunchAgents. You can also download the script here and just place it in /Library/Scripts.
Filed under: #!/bin/bash, bash, nightly, update, webkit |