aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormxcl2010-03-13 06:24:44 -0700
committermxcl2010-03-13 06:24:44 -0700
commita6d9371bc901da75e508b09ec7522841a522b0c4 (patch)
treee4727fcc29fbb5f62858e4a94e837e00063b24da
parent93d86f92eecba82fdf68f48fd1c3e54879184cf3 (diff)
downloadhomebrew-a6d9371bc901da75e508b09ec7522841a522b0c4.tar.bz2
-rw-r--r--install_homebrew.rb46
1 files changed, 29 insertions, 17 deletions
diff --git a/install_homebrew.rb b/install_homebrew.rb
index fee66f3d4..a0a9b33bb 100644
--- a/install_homebrew.rb
+++ b/install_homebrew.rb
@@ -4,8 +4,8 @@
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
#
-# If you do fork ensure you add a comment here that explains what the changes
-# are intended to do and how well you tested them.
+# If you do fork, please ensure you add a comment here that explains what the
+# changes are intended to do and how well you tested them.
#
module Tty extend self
@@ -16,7 +16,7 @@ module Tty extend self
def underline; underline 39; end
def bold n; escape "1;#{n}" end
def underline n; escape "4;#{n}" end
- def escape n; "\033[#{n}m" if $stdout.tty? end
+ def escape n; "\033[#{n}m" if STDOUT.tty? end
end
def ohai s
@@ -24,20 +24,29 @@ def ohai s
end
def sudo *params
- params.unshift "sudo"
- ohai params.map{ |p| p.gsub ' ', '\\ ' } * ' '
- system *params
+ if params.length == 1
+ cmd = "sudo #{params.first}"
+ ohai cmd
+ system cmd
+ else
+ ohai "sudo" + params.map{ |p| p.gsub ' ', '\\ ' } * ' '
+ system "sudo", *params
+ end
end
def opoo warning
puts "#{Tty.red}Warning#{Tty.reset}: #{warning}"
end
-####################################################################### script
-require 'fileutils'
-include FileUtils
+def getc # NOTE only tested on OS X
+ system "stty raw -echo"
+ STDIN.getc
+ensure
+ system "stty -raw echo"
+end
-#abort "/usr/local/.git already exists!" if File.directory? '/usr/local/.git'
+####################################################################### script
+abort "/usr/local/.git already exists!" if File.directory? "/usr/local/.git"
ohai "This script will install:"
puts "/usr/local/bin/brew"
@@ -55,26 +64,29 @@ end
puts
puts "Press enter to continue"
-abort if gets != "\n"
+abort unless getc == 13
-if File.directory? '/usr/local'
+if File.directory? "/usr/local"
sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
else
- sudo "/bin/mkdir", '/usr/local'
- sudo "/bin/chmod", "g+w", '/usr/local'
+ sudo "/bin/mkdir /usr/local"
+ sudo "/bin/chmod g+w /usr/local"
end
-cd '/usr/local' do
+Dir.chdir "/usr/local" do
tarball = "http://github.com/mxcl/homebrew/tarball/master"
ohai "Extracting: #{tarball}"
# -m to stop tar erroring out if it can't modify the mtime for root owned directories
system "/usr/bin/curl -#L #{tarball} | /usr/bin/tar xz -m --strip 1"
end
-ohai "Installation successful"
+ohai "Installation successful!"
if ENV['PATH'].split(':').include? '/usr/local/bin'
- puts "Now try: brew help"
+ puts "Yay! Now learn to brew:"
+ puts
+ puts " brew help"
+ puts
else
opoo "/usr/local/bin is not in your PATH"
end