Skip to content

Instantly share code, notes, and snippets.

@supaspoida
Created January 11, 2010 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supaspoida/274011 to your computer and use it in GitHub Desktop.
Save supaspoida/274011 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fileutils'
def fail!(msg = "Failure!")
puts(msg)
exit(1)
end
REPOSITORY_URL = 'git://github.com/mxcl/homebrew.git'
PACKAGE_URL = 'http://github.com/mxcl/homebrew/tarball/master'
if File.exists?('/usr/local')
fail! "/usr/local already exists, you'll want to move this out of the way first!"
end
puts "* Downloading and unpacking homebrew to /usr/local"
Dir.chdir("/tmp") # seems like a sane place to do the hard work
if system("curl -L -o homebrew.tar #{PACKAGE_URL} && tar xf homebrew.tar")
system("sudo mv mxcl-homebrew-* /usr/local")
system("sudo chown -R `whoami`:staff /usr/local") # so we don't need sudo again
else
fail! "Couldn't install homebrew!"
end
puts "* Installing git using homebrew"
fail! unless system("brew install git")
puts "* Connecting homebrew installation to master on Github"
if system("git clone #{REPOSITORY_URL}")
FileUtils.mv('homebrew/.git', '/usr/local/.git')
system("cd /usr/local && git pull origin master")
else
fail! "Couldn't clone git repository"
end
# quick cleanup
system("sudo rm -rf /tmp/homebrew*")
puts "* Done. Run 'cd /usr/local && git pull origin master' to update formulae."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment