Skip to content

Instantly share code, notes, and snippets.

@stevenringo
Forked from mxcl/install_homebrew.markdown
Created August 30, 2011 10:46
Show Gist options
  • Save stevenringo/1180642 to your computer and use it in GitHub Desktop.
Save stevenringo/1180642 to your computer and use it in GitHub Desktop.

Revisions

  1. stevenringo revised this gist Aug 30, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -128,7 +128,7 @@ def macos_version
    # pipefail to cause the exit status from curl to propogate if it fails
    # we use -k because OS X curl has a bunch of bad SSL certificates
    # you may want to remove the -k flag from your fork!
    system "/bin/bash -o pipefail -c '/usr/bin/curl -skSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    system "/bin/bash -o pipefail -c '/usr/bin/curl -skSfL https://github.com/mxcl/homebrew/tarball/164a9804267b2205cfa465b342b9d9fd2de2c0ba | /usr/bin/tar xz -m --strip 1'"
    end

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
  2. @mxcl mxcl revised this gist Aug 29, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -66,6 +66,10 @@ def macos_version
    @macos_version ||= /(10\.\d+)(\.\d+)?/.match(`/usr/bin/sw_vers -productVersion`).captures.first.to_f
    end

    # The block form of Dir.chdir fails later if Dir.CWD doesn't exist which I
    # guess is fair enough. Also sudo prints a warning message for no good reason
    Dir.chdir "/usr"

    ####################################################################### script
    abort "MacOS too old, see: https://gist.github.com/1144389" if macos_version < 10.5
    abort "/usr/local/.git already exists!" unless Dir["/usr/local/.git/*"].empty?
  3. @mxcl mxcl revised this gist Aug 24, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -108,12 +108,12 @@ def macos_version
    end

    if File.directory? "/usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/bin/chmod", "g+rwx", *chmods unless chmods.empty?
    # all admin users are in staff
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    else
    sudo "/bin/mkdir /usr/local"
    sudo "/bin/chmod g+w /usr/local"
    sudo "/bin/chmod g+rwx /usr/local"
    # the group is set to wheel by default for some reason
    sudo "/usr/bin/chgrp staff /usr/local"
    end
  4. @mxcl mxcl revised this gist Aug 23, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -122,7 +122,9 @@ def macos_version
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    # we use -k because OS X curl has a bunch of bad SSL certificates
    # you may want to remove the -k flag from your fork!
    system "/bin/bash -o pipefail -c '/usr/bin/curl -skSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
  5. @mxcl mxcl revised this gist Aug 23, 2011. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -125,8 +125,6 @@ def macos_version
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    ohai "Installation successful!"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"

  6. @mxcl mxcl revised this gist Aug 23, 2011. 1 changed file with 15 additions and 19 deletions.
    34 changes: 15 additions & 19 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -84,16 +84,12 @@ def macos_version
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w( share/man lib/pkgconfig var/log share/locale
    chmods = %w( . bin etc include lib lib/pkgconfig Library sbin share var var/log share/locale share/man
    share/man/man1 share/man/man2 share/man/man3 share/man/man4
    share/man/man5 share/man/man6 share/man/man7 share/man/man8
    share/info share/doc share/aclocal ).map{ |d| "/usr/local/#{d}" }
    root_dirs = []
    %w(bin Cellar etc include lib Library sbin share var .git).each do |d|
    d = "/usr/local/#{d}"
    if File.directory? d then chmods else root_dirs end << d
    end
    chmods = chmods.select{ |d| File.directory? d and not File.writable? d }
    share/info share/doc share/aclocal ).
    map{ |d| "/usr/local/#{d}" }.
    select{ |d| File.directory? d and not File.writable? d }
    chgrps = chmods.reject{ |d| File.stat(d).grpowned? }

    unless chmods.empty?
    @@ -105,19 +101,22 @@ def macos_version
    puts *chgrps
    end


    if STDIN.tty?
    puts
    puts "Press enter to continue"
    abort unless getc == 13
    end

    sudo "/bin/mkdir /usr/local" unless File.directory? "/usr/local"
    sudo "/bin/chmod o+w /usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    system "/bin/mkdir", *root_dirs unless root_dirs.empty?

    if File.directory? "/usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    # all admin users are in staff
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    else
    sudo "/bin/mkdir /usr/local"
    sudo "/bin/chmod g+w /usr/local"
    # the group is set to wheel by default for some reason
    sudo "/usr/bin/chgrp staff /usr/local"
    end

    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    @@ -126,10 +125,7 @@ def macos_version
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    # we reset the permissions of /usr/local because we want to minimise the
    # amount of fiddling we do to the system. Some tools require /usr/local to be
    # by non-writable for non-root users.
    sudo "/bin/chmod o-w /usr/local"
    ohai "Installation successful!"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"
  7. @mxcl mxcl revised this gist Aug 23, 2011. 1 changed file with 15 additions and 16 deletions.
    31 changes: 15 additions & 16 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -114,24 +114,23 @@ def macos_version

    sudo "/bin/mkdir /usr/local" unless File.directory? "/usr/local"
    sudo "/bin/chmod o+w /usr/local"
    begin
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    system "/bin/mkdir", *root_dirs unless root_dirs.empty?

    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end
    ensure
    # we reset the permissions of /usr/local because we want to minimise the
    # amount of fiddling we do to the system. Some tools require /usr/local to
    # be by non-writable for non-root users.
    sudo "/bin/chmod o-w /usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    system "/bin/mkdir", *root_dirs unless root_dirs.empty?


    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    # we reset the permissions of /usr/local because we want to minimise the
    # amount of fiddling we do to the system. Some tools require /usr/local to be
    # by non-writable for non-root users.
    sudo "/bin/chmod o-w /usr/local"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"

  8. @mxcl mxcl revised this gist Aug 15, 2011. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -62,7 +62,12 @@ def badlibs
    end
    end

    def macos_version
    @macos_version ||= /(10\.\d+)(\.\d+)?/.match(`/usr/bin/sw_vers -productVersion`).captures.first.to_f
    end

    ####################################################################### script
    abort "MacOS too old, see: https://gist.github.com/1144389" if macos_version < 10.5
    abort "/usr/local/.git already exists!" unless Dir["/usr/local/.git/*"].empty?
    abort "Don't run this as root!" if Process.uid == 0
    abort <<-EOABORT unless `groups`.split.include? "staff"
  9. @mxcl mxcl revised this gist Aug 6, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ def sudo *args
    args = if args.length > 1
    args.unshift "/usr/bin/sudo"
    else
    "/usr/bin/sudo #{args}"
    "/usr/bin/sudo #{args.first}"
    end
    ohai *args
    system *args
  10. @mxcl mxcl revised this gist Aug 6, 2011. 1 changed file with 16 additions and 15 deletions.
    31 changes: 16 additions & 15 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -109,23 +109,24 @@ def badlibs

    sudo "/bin/mkdir /usr/local" unless File.directory? "/usr/local"
    sudo "/bin/chmod o+w /usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    system "/bin/mkdir", *root_dirs unless root_dirs.empty?


    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    begin
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    system "/bin/mkdir", *root_dirs unless root_dirs.empty?

    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end
    ensure
    # we reset the permissions of /usr/local because we want to minimise the
    # amount of fiddling we do to the system. Some tools require /usr/local to
    # be by non-writable for non-root users.
    sudo "/bin/chmod o-w /usr/local"
    end

    # we reset the permissions of /usr/local because we want to minimise the
    # amount of fiddling we do to the system. Some tools require /usr/local to be
    # by non-writable for non-root users.
    sudo "/bin/chmod o-w /usr/local"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"

  11. @mxcl mxcl revised this gist Jul 29, 2011. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -53,6 +53,15 @@ def getc # NOTE only tested on OS X
    system "/bin/stty -raw echo"
    end

    def badlibs
    @badlibs ||= begin
    Dir['/usr/local/lib/*.dylib'].select do |dylib|
    ENV['dylib'] = dylib
    File.file? dylib and not File.symlink? dylib and `/usr/bin/file "$dylib"` =~ /shared library/
    end
    end
    end

    ####################################################################### script
    abort "/usr/local/.git already exists!" unless Dir["/usr/local/.git/*"].empty?
    abort "Don't run this as root!" if Process.uid == 0
    @@ -119,3 +128,12 @@ def getc # NOTE only tested on OS X

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"

    unless badlibs.empty?
    warn "The following *evil* dylibs exist in /usr/local/lib"
    puts "They may break builds or worse. You should consider deleting them:"
    puts *badlibs
    end

    ohai "Installation successful!"
    puts "Now type: brew help"
  12. @mxcl mxcl revised this gist Jul 29, 2011. 1 changed file with 19 additions and 15 deletions.
    34 changes: 19 additions & 15 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -70,12 +70,16 @@ def getc # NOTE only tested on OS X
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w( . bin etc include lib lib/pkgconfig Library sbin share var var/log share/locale share/man
    chmods = %w( share/man lib/pkgconfig var/log share/locale
    share/man/man1 share/man/man2 share/man/man3 share/man/man4
    share/man/man5 share/man/man6 share/man/man7 share/man/man8
    share/info share/doc share/aclocal ).
    map{ |d| "/usr/local/#{d}" }.
    select{ |d| File.directory? d and not File.writable? d }
    share/info share/doc share/aclocal ).map{ |d| "/usr/local/#{d}" }
    root_dirs = []
    %w(bin Cellar etc include lib Library sbin share var .git).each do |d|
    d = "/usr/local/#{d}"
    if File.directory? d then chmods else root_dirs end << d
    end
    chmods = chmods.select{ |d| File.directory? d and not File.writable? d }
    chgrps = chmods.reject{ |d| File.stat(d).grpowned? }

    unless chmods.empty?
    @@ -87,22 +91,19 @@ def getc # NOTE only tested on OS X
    puts *chgrps
    end


    if STDIN.tty?
    puts
    puts "Press enter to continue"
    abort unless getc == 13
    end

    if File.directory? "/usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    # all admin users are in staff
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    else
    sudo "/bin/mkdir /usr/local"
    sudo "/bin/chmod g+w /usr/local"
    # the group is set to wheel by default for some reason
    sudo "/usr/bin/chgrp staff /usr/local"
    end
    sudo "/bin/mkdir /usr/local" unless File.directory? "/usr/local"
    sudo "/bin/chmod o+w /usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
    sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty?
    system "/bin/mkdir", *root_dirs unless root_dirs.empty?


    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    @@ -111,7 +112,10 @@ def getc # NOTE only tested on OS X
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    ohai "Installation successful!"
    # we reset the permissions of /usr/local because we want to minimise the
    # amount of fiddling we do to the system. Some tools require /usr/local to be
    # by non-writable for non-root users.
    sudo "/bin/chmod o-w /usr/local"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"
  13. @mxcl mxcl revised this gist Jul 29, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -54,7 +54,7 @@ def getc # NOTE only tested on OS X
    end

    ####################################################################### script
    abort "/usr/local/.git already exists!" if File.directory? "/usr/local/.git"
    abort "/usr/local/.git already exists!" unless Dir["/usr/local/.git/*"].empty?
    abort "Don't run this as root!" if Process.uid == 0
    abort <<-EOABORT unless `groups`.split.include? "staff"
    This script requires the user #{ENV['USER']} to be in the staff group. If this
  14. @mxcl mxcl revised this gist Jul 29, 2011. 1 changed file with 0 additions and 18 deletions.
    18 changes: 0 additions & 18 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,6 @@
    #!/usr/bin/ruby
    #
    # This script installs to /usr/local only. To install elsewhere you can just
    # untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
    #
    #
    # 30th March 2010:
    # Added a check to make sure user is in the staff group. This was a problem
    # for me, and I think it was due to me migrating my account over several
    # versions of OS X. I cannot verify that for sure, and it was tested on
    # 10.6.2 using the Directory Service command line utility and my laptop.
    #
    # My assumptions are:
    # - you are running OS X 10.6.x
    # - your machine is not managed as part of a group using networked
    # Directory Services
    # - you have not recently killed any baby seals or kittens
    #
    # 14th March 2010:
    # Adapted CodeButler's fork: http://gist.github.com/331512
    #

    module Tty extend self
    def blue; bold 34; end
  15. @mxcl mxcl revised this gist Apr 13, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ def getc # NOTE only tested on OS X
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w( . bin etc include lib lib/pkgconfig Library sbin share var share/locale share/man
    chmods = %w( . bin etc include lib lib/pkgconfig Library sbin share var var/log share/locale share/man
    share/man/man1 share/man/man2 share/man/man3 share/man/man4
    share/man/man5 share/man/man6 share/man/man7 share/man/man8
    share/info share/doc share/aclocal ).
  16. @mxcl mxcl revised this gist Dec 7, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/ruby
    #
    # This script installs to /usr/local only. To install elsewhere you can just
    # untar http://github.com/mxcl/homebrew/tarball/master anywhere you like.
    # untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
    #
    #
    # 30th March 2010:
  17. @mxcl mxcl revised this gist Nov 3, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -126,7 +126,7 @@ def getc # NOTE only tested on OS X
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL http://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    ohai "Installation successful!"
  18. @mxcl mxcl revised this gist Sep 23, 2010. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -125,7 +125,8 @@ def getc # NOTE only tested on OS X
    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    system "/usr/bin/curl -sSfL http://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1"
    # pipefail to cause the exit status from curl to propogate if it fails
    system "/bin/bash -o pipefail -c '/usr/bin/curl -sSfL http://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
    end

    ohai "Installation successful!"
  19. @adamv adamv revised this gist Aug 16, 2010. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,10 @@ def getc # NOTE only tested on OS X
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w(bin etc include lib lib/pkgconfig Library sbin share var . share/locale share/man share/man/man1 share/info share/doc share/aclocal).
    chmods = %w( . bin etc include lib lib/pkgconfig Library sbin share var share/locale share/man
    share/man/man1 share/man/man2 share/man/man3 share/man/man4
    share/man/man5 share/man/man6 share/man/man7 share/man/man8
    share/info share/doc share/aclocal ).
    map{ |d| "/usr/local/#{d}" }.
    select{ |d| File.directory? d and not File.writable? d }
    chgrps = chmods.reject{ |d| File.stat(d).grpowned? }
  20. @adamv adamv revised this gist Aug 16, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -52,9 +52,9 @@ def system *args

    def sudo *args
    args = if args.length > 1
    args.unshift "sudo"
    args.unshift "/usr/bin/sudo"
    else
    "sudo #{args}"
    "/usr/bin/sudo #{args}"
    end
    ohai *args
    system *args
  21. @adamv adamv revised this gist Jul 1, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ def getc # NOTE only tested on OS X
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w(bin etc include lib libexec Library sbin share var . share/locale share/man share/man/man1 share/info share/doc share/aclocal).
    chmods = %w(bin etc include lib lib/pkgconfig Library sbin share var . share/locale share/man share/man/man1 share/info share/doc share/aclocal).
    map{ |d| "/usr/local/#{d}" }.
    select{ |d| File.directory? d and not File.writable? d }
    chgrps = chmods.reject{ |d| File.stat(d).grpowned? }
  22. @adamv adamv revised this gist Jun 28, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ def getc # NOTE only tested on OS X
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w(bin etc include lib libexec Library sbin share var . share/locale share/man share/info share/doc share/aclocal).
    chmods = %w(bin etc include lib libexec Library sbin share var . share/locale share/man share/man/man1 share/info share/doc share/aclocal).
    map{ |d| "/usr/local/#{d}" }.
    select{ |d| File.directory? d and not File.writable? d }
    chgrps = chmods.reject{ |d| File.stat(d).grpowned? }
  23. @mxcl mxcl revised this gist Jun 23, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -128,4 +128,4 @@ def getc # NOTE only tested on OS X
    ohai "Installation successful!"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode." unless Kernel.system "/usr/bin/which -s gcc"
    warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc"
  24. @mxcl mxcl revised this gist Jun 23, 2010. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -102,9 +102,11 @@ def getc # NOTE only tested on OS X
    puts *chgrps
    end

    puts
    puts "Press enter to continue"
    abort unless getc == 13
    if STDIN.tty?
    puts
    puts "Press enter to continue"
    abort unless getc == 13
    end

    if File.directory? "/usr/local"
    sudo "/bin/chmod", "g+w", *chmods unless chmods.empty?
  25. @mxcl mxcl revised this gist Jun 16, 2010. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -45,11 +45,9 @@ def ohai *args
    def warn warning
    puts "#{Tty.red}Warning#{Tty.reset}: #{warning.chomp}"
    end

    alias :system_orig :system

    def system *args
    abort "Failed during: #{args.shell_s}" unless system_orig *args
    abort "Failed during: #{args.shell_s}" unless Kernel.system *args
    end

    def sudo *args
    @@ -128,4 +126,4 @@ def getc # NOTE only tested on OS X
    ohai "Installation successful!"

    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode." unless system "/usr/bin/which gcc"
    warn "Now install Xcode." unless Kernel.system "/usr/bin/which -s gcc"
  26. @mxcl mxcl revised this gist Jun 16, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/ruby
    #
    # This script is for installation to /usr/local only. To install eleswhere
    # just untar http://github.com/mxcl/homebrew/tarball/master anywhere you like.
    # This script installs to /usr/local only. To install elsewhere you can just
    # untar http://github.com/mxcl/homebrew/tarball/master anywhere you like.
    #
    #
    # 30th March 2010:
  27. @mxcl mxcl revised this gist Jun 16, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ def getc # NOTE only tested on OS X
    puts "/usr/local/Library/Formula/..."
    puts "/usr/local/Library/Homebrew/..."

    chmods = %w(bin etc include lib sbin share var . share/locale share/man share/info share/doc share/aclocal).
    chmods = %w(bin etc include lib libexec Library sbin share var . share/locale share/man share/info share/doc share/aclocal).
    map{ |d| "/usr/local/#{d}" }.
    select{ |d| File.directory? d and not File.writable? d }
    chgrps = chmods.reject{ |d| File.stat(d).grpowned? }
  28. @mxcl mxcl revised this gist Jun 15, 2010. 1 changed file with 3 additions and 11 deletions.
    14 changes: 3 additions & 11 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,8 @@
    #!/usr/bin/ruby
    #
    # Download and execute this script in one-line with no temporary files:
    # This script is for installation to /usr/local only. To install eleswhere
    # just untar http://github.com/mxcl/homebrew/tarball/master anywhere you like.
    #
    # ruby -e "$(curl http://gist.github.com/raw/323731/install_homebrew.rb)"
    #
    #
    # I deliberately didn't DRY /usr/local references into a variable as this
    # 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, please ensure you add a comment here that explains what the
    # changes are intended to do and how well you tested them.
    #
    # 30th March 2010:
    # Added a check to make sure user is in the staff group. This was a problem
    @@ -130,7 +122,7 @@ def getc # NOTE only tested on OS X
    Dir.chdir "/usr/local" do
    ohai "Downloading and Installing Homebrew..."
    # -m to stop tar erroring out if it can't modify the mtime for root owned directories
    system "/usr/bin/curl -sfL http://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1"
    system "/usr/bin/curl -sSfL http://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1"
    end

    ohai "Installation successful!"
  29. @mxcl mxcl revised this gist Jun 5, 2010. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -72,7 +72,11 @@ def sudo *args

    def getc # NOTE only tested on OS X
    system "/bin/stty raw -echo"
    STDIN.getbyte
    if RUBY_VERSION >= '1.8.7'
    STDIN.getbyte
    else
    STDIN.getc
    end
    ensure
    system "/bin/stty -raw echo"
    end
  30. @mxcl mxcl revised this gist May 27, 2010. 1 changed file with 2 additions and 8 deletions.
    10 changes: 2 additions & 8 deletions install_homebrew.rb
    Original file line number Diff line number Diff line change
    @@ -131,11 +131,5 @@ def getc # NOTE only tested on OS X

    ohai "Installation successful!"

    if ENV['PATH'].split(':').include? '/usr/local/bin'
    puts "Yay! Now learn to brew:"
    puts
    puts " brew help"
    puts
    else
    warn "/usr/local/bin is not in your PATH"
    end
    warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin'
    warn "Now install Xcode." unless system "/usr/bin/which gcc"