-
-
Save plastictrophy/282562 to your computer and use it in GitHub Desktop.
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 | |
require 'fileutils' | |
def fail!(msg = "Failure!") | |
puts(msg) | |
exit(1) | |
end | |
REPOSITORY_URL = 'git://github.com/plastictrophy/homebrew.git' | |
PACKAGE_URL = 'http://github.com/plastictrophy/homebrew/tarball/masterbrew' | |
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 Github repo" | |
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 /tmp/homebrew*") | |
puts "* Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment