Skip to content

Instantly share code, notes, and snippets.

@somebox
Forked from indirect/README
Created September 20, 2011 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save somebox/1230756 to your computer and use it in GitHub Desktop.
Save somebox/1230756 to your computer and use it in GitHub Desktop.
Update WebKit nightly
To use this:
1. check out the gist somewhere
2. edit the plist to contain the path to the .rb file
3. run this:
chmod +x update-webkit.rb
launchctl load com.indirect.update-webkit.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.indirect.update-webkit</string>
<key>ProgramArguments</key>
<array>
<string>/Users/andre/sw/bash/update-webkit/update-webkit.rb</string>
</array>
<key>QueueDirectories</key>
<array/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>WatchPaths</key>
<array/>
</dict>
</plist>
#!/usr/bin/env ruby
# Automatically update to the latest WebKit nightly build
# written 2008-10-09 by Andre Arko <andre@arko.net>
# http://github.com/indirect
LOG_FILE = "~/Library/Logs/WebKitUpdate.log"
TEMP_DIR = "/tmp/webkit/"
require 'fileutils'
# Get the current nightly's info
`curl -Ls "http://nightly.webkit.org/index.html"`.match(/"(.*?\/mac\/WebKit-SVN-r(.*?).dmg)"/)
nightly_link = $1
nightly_version = $2
installed_version = `cat /Applications/WebKit.app/Contents/Resources/VERSION`.chomp if File.exist?("/Applications/WebKit.app")
begin
# Kill running WebKit
wk_pid = `ps ux | awk '/WebKit/ && !/awk/ {print $2}'`.chomp
`kill -9 #{wk_pid}` unless wk_pid.empty?
# Create the temp dir and download the nightly dmg into it
FileUtils.mkdir_p(TEMP_DIR)
Dir.chdir(TEMP_DIR)
`curl -LOs #{nightly_link}`
# Mount the dmg, copy the nightly webkit, unmount the dmg
dmg_path = File.join(TEMP_DIR, "WebKit-SVN-r#{nightly_version}.dmg")
raise ArgumentError, "cannot find dmg" unless File.exist?(dmg_path)
`hdiutil attach -quiet #{dmg_path}`
`rm -rf /Applications/WebKit.app`
`cp -R /Volumes/WebKit/WebKit.app /Applications/`
`hdiutil detach -quiet /Volumes/WebKit`
# Remove the temp dir
`rm -rf #{TEMP_DIR}`
# Log the update
File.open(File.expand_path(LOG_FILE), "w+") do |f|
f.write "WebKit build #{nightly_version} replaced build #{installed_version} on #{`date`}"
end
rescue => e
File.open(File.expand_path(LOG_FILE), "w+") do |f|
f.write e.inspect
end
end unless installed_version.any? && (nightly_version == installed_version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment