WebKit (Safari) Browser nightly builds update script

thirdshiftdj

I feel funny...
Messages
3,808
Location
Lowell,Ma
"WebKit is an open source web browser engine. WebKit is also the name of the Mac OS X system framework version of the engine that's used by Safari, Dashboard, Mail, and many other OS X applications. WebKit's HTML and JavaScript code began as a branch of the KHTML and KJS libraries from KDE."

The WebKit Open Source Project

Since we all like to live bleeding edge, and I was really bored -- I created a script to update WebKit nightlies that you can use as cron or w/ launchd. It checks versioning, downloads, mounts and installs webkits nightly builds. It's working directory is /tmp.

Code:
#!/bin/bash
#Update to the latest WebKit nightly build.

#-----------------------------------------------------------------------------
#Temp workspace
#-----------------------------------------------------------------------------
export TMP_INSTALL_LOCATION="/tmp/WebKit"
mkdir "$TMP_INSTALL_LOCATION"
cd "$TMP_INSTALL_LOCATION"

#-----------------------------------------------------------------------------
#Set environment
#-----------------------------------------------------------------------------
export LOGGING="$HOME"/Library/Logs/WebKitUpdate.log
curl -LOs "http://nightly.webkit.org/index.html"
export WEBKIT_NIGHTLY=`cat index.html | grep mac/WebKit-SVN | grep Download | cut -c 75-80`

#Check Current vs Nightly version
if [ -d /Applications/WebKit.app ]; then
  export WEBKIT_INSTALLED=`cat /Applications/WebKit.app/Contents/Resources/VERSION`
  if [ "$WEBKIT_NIGHTLY" == "$WEBKIT_INSTALLED" ]; then
    echo "Installed version $WEBKIT_INSTALLED matches Nightly $WEBKIT_NIGHTLY"
    rm -r "$TMP_INSTALL_LOCATION"
    echo "Exiting in 3 seconds"
    sleep 3
    exit
  fi
fi

#-----------------------------------------------------------------------------
#Checks if WebKit is running
#-----------------------------------------------------------------------------
echo "-------------------------------------"
echo "checking for WebKit processes -- killing if found"
ps aux |grep "WebKit.app"|grep -v grep >> "$TMP_INSTALL_LOCATION"/pid.txt
PROC=`awk '{print $2;}' pid.txt |awk 'NR==1'`
PROC2=`awk '{print $2;}' pid.txt |awk 'NR==2'`
if [ "$PROC" ]; then
  kill -9 "$PROC" && kill -9 "$PROC2"
  else
        echo "No running processes"
fi

#-----------------------------------------------------------------------------
#Remove old and download new
#-----------------------------------------------------------------------------
echo "-------------------------------------"
echo "Removing installed version"
rm -rf /Applications/WebKit.app
echo "-------------------------------------"
echo "Downloading WebKit-SVN-r"$WEBKIT_NIGHTLY".dmg"
curl -LO "http://nightly.webkit.org/files/trunk/mac/WebKit-SVN-r"$WEBKIT_NIGHTLY".dmg"

#-----------------------------------------------------------------------------
#Install WebKit
#-----------------------------------------------------------------------------
echo "-------------------------------------"
echo "Mounting WebKit-SVN-r"$WEBKIT_NIGHTLY".dmg"
hdiutil attach -quiet ""$TMP_INSTALL_LOCATION"/WebKit-SVN-r"$WEBKIT_NIGHTLY".dmg"
cp -R /Volumes/WebKit/WebKit.app /Applications/
hdiutil detach -quiet /Volumes/WebKit
rm -rf "$TMP_INSTALL_LOCATION"

#-----------------------------------------------------------------------------
#Log 
#-----------------------------------------------------------------------------
echo "-------------------------------------"
echo "WebKit build "$WEBKIT_NIGHTLY" replaced build "$WEBKIT_INSTALLED" on `date`"
 
Last edited:
Back
Top Bottom