Skip to content

Instantly share code, notes, and snippets.

@mfilej
Created March 19, 2010 10:48
Show Gist options
  • Save mfilej/337414 to your computer and use it in GitHub Desktop.
Save mfilej/337414 to your computer and use it in GitHub Desktop.
chromium_update (forked from http://pastie.org/819162)
#!/usr/bin/env ruby
# Script for OS X users to install and run the latest nightly Chromium build
#
# Save as file as "chromium_update" in your $PATH; and chmod +x chromium_update
#
# Written by Dr Nic Williams and Bo Jeanes from Mocra; [email protected]
# Updated by Miha Filej (github.com/mfilej)
require "pathname"
require "fileutils"
include FileUtils
URL = "http://build.chromium.org/buildbot/continuous/mac/LATEST"
APP = Pathname.new "/Applications/Chromium.app"
def running?
`ps ax | grep Chromium | grep -v grep`.any?
end
def installed?
APP.directory?
end
def installed
return 0 unless installed?
info = APP.join("Contents", "Info.plist").open
until info.readline.include? "SVNRevision"; end
info.readline =~ />(.+)</
$1.to_i
rescue
puts "Could not determine revision"
0
end
def nightly
%x[curl -s #{URL}/REVISION].to_i
end
unless nightly > installed
puts "Chromium is up to date (rev. #{installed})"
exit
end
if installed?
puts "Chromium #{nightly} is available (you have #{installed}). Updating..."
else
puts "Chromium not found, installing..."
end
chdir("/tmp") do
%x[rm -rf chrome-mac*]
%x[curl -O #{URL}/chrome-mac.zip]
%x[unzip chrome-mac.zip]
if running?
puts "Please quit Chromium (I'll restart it in a minute, all shiny and new)..."
end
loop do
break unless running?
sleep 2
end
if installed?
puts "Deleting existing Chromium.app"
rm_rf APP
end
cp_r "chrome-mac/Chromium.app", "/Applications"
puts "Chromium #{nightly} installed. Enjoy."
end
%x[open -a #{APP}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment