Created
December 18, 2008 21:29
-
-
Save indirect/37669 to your computer and use it in GitHub Desktop.
Update WebKit nightly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Automatically update to the latest WebKit nightly build | |
# written 2008-10-09 by Andre Arko <[email protected]> | |
# 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