Fork me on GitHub

Thursday, January 7, 2010

A Better Chromium for Mac Updater

I modified Dominic Barnes' Chromium Updater AppleScript to perform more how I wanted and am providing the script below:



--Developed by Aaron Daubman, original by Dominic Barnes (http://dombarnes.com)

--http://www.ajd.us

--Version 0.5


--specify a proxy, set to "" if none

set proxHost to ""


--find latest build number

set the_source to do shell script "curl http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/LATEST " & proxHost


--locate the installed Chromium's plist to get the version

set appPath to POSIX path of (path to applications folder) & "/Chromium.app"

set appPlist to appPath & "/Contents/Info.plist"


set curVer to "Not Found"

try

    tell application "System Events"

        set curVer to value of property list item "SVNRevision" of property list file appPlist

    end tell

end try


display dialog "Your version of Chromium is: " & curVer & "

Latest version is: " & the_source buttons {"Cancel", "Upgrade!"} default button 2


--set local directory info

set remFile to "chrome-mac.zip"

set locDir to "~/Downloads/"

set locFile to "chrome-mac.zip"


--quit running chromium

set wasRunning to false

if application "Chromium" is running then

    display dialog "Chromium is currently running, continuing will quit!" buttons {"Cancel", "Continue and Quit!"} default button 2

    set wasRunning to true

    tell application "Chromium" to quit

end if


--download latest build using build number in the_source

do shell script "curl http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/" & the_source & "/" & remFile & " -o " & locDir & locFile & " " & proxHost


--unpack and copy

do shell script "unzip -o " & locDir & locFile & " -d " & locDir


--move existing Chromium and copy new

try

    do shell script "cp -pR " & appPath & " " & appPath & ".OLD"

    do shell script "rm -R " & appPath

end try


do shell script "mkdir -p " & appPath

do shell script "mkdir -p " & appPath & "/Contents"

do shell script "cp -pR " & locDir & "chrome-mac/Chromium.app/Contents " & appPath


--Cleanup folders and files

do shell script "rm -R " & locDir & "chrome-mac*"

try

    do shell script "rm -R " & appPath & ".OLD"

end try


--re-open chromium if it was open

if wasRunning then

    tell application "Chromium" to activate

end if


display dialog "Chromium build " & the_source & " has been installed"



Copy the code above and paste it into the 'AppleScript Editor' app, and save as something like "UpdateChromium.scpt". Running the script (or saving it as an application to run more easily) should then provide you with the necessary options to stay up to date with the latest Chromium builds.

Why would you want the latest builds, you might ask? Well, for one, as of this writing, extensions were still not enabled in the official Mac beta of Chrome - however they seem to be working quite well for me in the latest Chromium builds.

Happy (and Speedy!) Browsing!