Chromium Mac Build Bot Updater Script

When I read on MacRumors that the Chromium builds for the Mac were available and were actually launching the “stupid” geek in me jumped at the opportunity to try the unfinished, unpolished software. By “stupid” I refer to the side of near any geek who sees the OOO SHINY and is fully prepared to deal with the instability and issues that will crop up with using pre-alpha/alpha software. Naturally when I saw how fast and furious the updates were happening alongside the fact there was no automatic update mechanism apparent in Chromium (I don’t have the Google Updater installed and don’t want to) I sought to find out how to automate the updates to make the pain of manual downloads, copies and such go away.

Using my previous WebKit script, 5 minutes looking at the Chromium application layout and how the builds are stored on the server I changed the script. I fully expect it to break horribly in the future as Google changes folder layouts and/or adds Chromium support to their own “silent” updating mechanism.

#! /bin/bash

# Based off my WebKit nightly script (now defunct as WebKit uses Sparkle)
# Copyright 2009 Micheal Jones
# Software License: Do whatever you want.

#Find current revision
currentRevision=`/usr/libexec/PlistBuddy -c 'Print :SVNRevision' /Applications/Chromium.app/Contents/Info.plist`

#Get latest revision
latestRevision=`curl -s http://build.chromium.org/f/buildbot/snapshots/chromium-rel-mac/LATEST`

#Abort if there is no update
if [ $latestRevision -le $currentRevision ]
then
	echo "There is no update for Chromium available"
	exit
fi

#Append download address
address='http://build.chromium.org/f/buildbot/snapshots/chromium-rel-mac/'${latestRevision}'/chrome-mac.zip'

echo "Downloading... $address"
curl -s $address -o /tmp/chrome.zip

#Abort if the build is not available
if [ "`head -n 3 /tmp/chrome.zip | tail -n 1`" = "404 Not Found" ];
then
	echo "Latest Version is not available yet (try again in a couple minutes)"
	rm -rf /tmp/chrome-mac.zip
	exit
fi

#Unzip
unzip /tmp/chrome.zip 1>/dev/null

echo "Copying..."
#Copy to Applications
cp -RfL /tmp/chrome-mac/Chromium.app /Applications/ 2>/dev/null

echo "Cleaning up..."
#Clean up
rm -rf /tmp/chrome*

revision=`/usr/libexec/PlistBuddy -c 'Print :SVNRevision' /Applications/Chromium.app/Contents/Info.plist`

echo "Finished. (r$revision)"

Realistically you should be looking for the latest source at the link below:

As always this script can be found in my git repository on GitHub.

WebKit Nightly Update Script

This is a repost of a much older post that was lost when I transitioned from Moveable Type 3 to 4.

I personally like using WebKit nightlies as my main browser as it’s more or less Safari with a better, faster, and much more current rendering engine underneath it. That and the gold logo looks much better than the silver. It does have bugs occasionally (for example I was unable to post comments to Flickr with WebKit nightlies for a couple weeks) but all in all the experience is very positive. This is the script I use to keep WebKit updated whenever it bugs me for an update. I use an alias in my .bashrc file so I can just type ‘wkupdate’ to run the shell script. The best part is that if I copy it and I’m still using the program the changes won’t take effect until I restart but it allows me to copy it still. (Not advisable however)

#! /bin/bash

#Find current revision
currentRevision=`cat /Applications/WebKit.app/Contents/Resources/VERSION`

#Get address
#Download start page and find address
address=`curl -s http://nightly.webkit.org/start/trunk/$currentRevision | grep 'WebKit-SVN-r[0-9]*' -o | head -n 1`

#Abort if there is no update
if [ "$address" == "" ]
then
	echo "There is no update for WebKit available"
	exit
fi

#Append download address
address='http://nightly.webkit.org/files/trunk/mac/'${address}'.dmg'

echo "Downloading... $address"
curl -s $address -o /tmp/WebKit.dmg
#Mount Image
hdid -readonly -quiet /tmp/WebKit.dmg

echo "Copying..."
#Copy to Applications
revision=`cat /Volumes/WebKit/WebKit.app/Contents/Resources/VERSION`

cp -RfL /Volumes/WebKit/* /Applications/ 2>/dev/null
ls /Volumes/WebKit/

echo "Cleaning up..."
#Clean up
hdiutil detach /Volumes/WebKit/ -quiet
rm -rf /tmp/WebKit.dmg

echo "Finished. (r$revision)"

EDIT: Updated 12/30/08 - Fixed URL check. Realistically you should be looking for the latest source at the link below:

As always this script can be found in my git repository on GitHub.

Opening/Copying Locked DVDs

At work we sometimes receive DVDs that we need footage off of that are locked. They will play back fine in DVD Player but we don’t want it for playback. The resulting DVD images are always titled SONATA_VOLUME and are created by a stand alone Sony DVD Recorder.

In order to copy the VIDEO_TS file off of the DVD you require sudo access but given that sudo access is limited to administrators (and not the editors) - this gets to be a bit of hassle because I have to be called to copy the DVD which adds unnecessary overhead to just get some footage off a simple DVD.

The solution? Create a droplet application (in this case AppleScript with shell scripts) so the editors don’t have to disrupt their workflow to get me to unlock the footage they need.

The source follows:

(* Files dropped onto the application will be copied to the root folder
of the main hard drive and set so the user has ownership - allowing 
them to move, rename and delete said file/folder. *)
on open files_
	repeat with file_ in files_
		--Get name of file, path, and the current username of editor
		set name_ to name of (info for file_)
		set file_ to POSIX path of file_
		set username_ to short user name of (system info)
		(* The 3 shell commands here can be condensed into one longer line
			but I left them separate for debugging and readability reasons
		*)
		do shell script "/bin/cp -R " & quoted form of file_ & " /" & quoted form of name_ user name "ADMIN_USER_NAME" password "PASSWORD" with administrator privileges
		do shell script "/bin/chmod -R 777 /" & quoted form of name_ user name "ADMIN_USER_NAME" password "PASSWORD"" with administrator privileges
		do shell script "/usr/sbin/chown -R " & username_ & " /" & quoted form of name_ user name "ADMIN_USER_NAME" password "PASSWORD"smoke@#$" with administrator privileges
		do shell script "open /"
	end repeat
end open

Tab Count to Growl for Safari

The following AppleScript snippet figures out how many tabs are open in the frontmost window and spits it out to Growl. Helps when I don’t feel like counting how many tabs I’ve opened in WebKit/Safari. Note: To get this to work with Safari change WebKit to Safari.

tell application "WebKit"
    activate
    set numtabs to index of last tab of front window
    tell application "GrowlHelperApp"
        set the allNotificationsList to {"Number of Tabs"}
        set the enabledNotificationsList to {"Number of Tabs"}
        register as application "Growl AppleScript Sample" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "WebKit"

        notify with name "Number of Tabs" title "Number of Tabs" description "" & numtabs application name "Growl AppleScript Sample"
    end tell
end tell