From 93d86f92eecba82fdf68f48fd1c3e54879184cf3 Mon Sep 17 00:00:00 2001 From: mxcl Date: Sat, 6 Mar 2010 08:14:26 -0700 Subject: --- install_homebrew.rb | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 install_homebrew.rb diff --git a/install_homebrew.rb b/install_homebrew.rb new file mode 100644 index 000000000..fee66f3d4 --- /dev/null +++ b/install_homebrew.rb @@ -0,0 +1,80 @@ +#!/usr/bin/ruby +# +# 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 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 + def blue; bold 34; end + def white; bold 39; end + def red; underline 31; end + def reset; escape 0; end + 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 +end + +def ohai s + puts "#{Tty.blue}==>#{Tty.white} #{s}#{Tty.reset}" +end + +def sudo *params + params.unshift "sudo" + ohai params.map{ |p| p.gsub ' ', '\\ ' } * ' ' + system *params +end + +def opoo warning + puts "#{Tty.red}Warning#{Tty.reset}: #{warning}" +end + +####################################################################### script +require 'fileutils' +include FileUtils + +#abort "/usr/local/.git already exists!" if File.directory? '/usr/local/.git' + +ohai "This script will install:" +puts "/usr/local/bin/brew" +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). + map{ |d| "/usr/local/#{d}" }. + select{ |d| File.directory? d and not File.writable? d } + +unless chmods.empty? + ohai "The following directories will be made group writable:" + puts *chmods +end + +puts +puts "Press enter to continue" +abort if gets != "\n" + +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' +end + +cd '/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" + +if ENV['PATH'].split(':').include? '/usr/local/bin' + puts "Now try: brew help" +else + opoo "/usr/local/bin is not in your PATH" +end -- cgit v1.2.3 From a6d9371bc901da75e508b09ec7522841a522b0c4 Mon Sep 17 00:00:00 2001 From: mxcl Date: Sat, 13 Mar 2010 06:24:44 -0700 Subject: --- install_homebrew.rb | 46 +++++++++++++++++++++++++++++----------------- 1 file 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 -- cgit v1.2.3 From 35292268657f1f21c543c0ff8c7ac792598d0ef2 Mon Sep 17 00:00:00 2001 From: mxcl Date: Sun, 14 Mar 2010 05:20:27 -0700 Subject: Advise user if they are not in the right group --- install_homebrew.rb | 60 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index a0a9b33bb..8c5caaf92 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -7,35 +7,50 @@ # 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. # +# 14th March 2010: +# Adapted CodeButler's fork: http://gist.github.com/331512 +# module Tty extend self def blue; bold 34; end def white; bold 39; end def red; underline 31; end def reset; escape 0; end - 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 end -def ohai s - puts "#{Tty.blue}==>#{Tty.white} #{s}#{Tty.reset}" +class Array + def shell_s + cp = dup + first = cp.shift + cp.map{ |arg| arg.gsub " ", "\\ " }.unshift(first) * " " + end end -def sudo *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 +def ohai *args + puts "#{Tty.blue}==>#{Tty.white} #{args.shell_s}#{Tty.reset}" +end + +def warn warning + puts "#{Tty.red}Warning#{Tty.reset}: #{warning.chomp}" end -def opoo warning - puts "#{Tty.red}Warning#{Tty.reset}: #{warning}" +alias :system_orig :system + +def system *args + abort "Failed during: #{args.shell_s}" unless system_orig *args +end + +def sudo *args + args = if args.length > 1 + args.unshift "sudo" + else + "sudo #{args}" + end + ohai *args + system *args end def getc # NOTE only tested on OS X @@ -47,6 +62,7 @@ end ####################################################################### script abort "/usr/local/.git already exists!" if File.directory? "/usr/local/.git" +abort "Don't run this as root!" if Process.uid == 0 ohai "This script will install:" puts "/usr/local/bin/brew" @@ -56,11 +72,16 @@ puts "/usr/local/Library/Homebrew/..." chmods = %w(bin etc include lib 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? } unless chmods.empty? ohai "The following directories will be made group writable:" puts *chmods end +unless chgrps.empty? + ohai "The following directories will have their group set to #{Tty.underline 39}staff#{Tty.reset}:" + puts *chgrps +end puts puts "Press enter to continue" @@ -68,16 +89,19 @@ abort unless getc == 13 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 - tarball = "http://github.com/mxcl/homebrew/tarball/master" - ohai "Extracting: #{tarball}" + 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 -#L #{tarball} | /usr/bin/tar xz -m --strip 1" + system "/usr/bin/curl -sfL http://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1" end ohai "Installation successful!" @@ -88,5 +112,5 @@ if ENV['PATH'].split(':').include? '/usr/local/bin' puts " brew help" puts else - opoo "/usr/local/bin is not in your PATH" + warn "/usr/local/bin is not in your PATH" end -- cgit v1.2.3 From e12165138fe4064d42a016249d13daa40db8c070 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 12:03:17 +0000 Subject: Add user to staff if necessary --- install_homebrew.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/install_homebrew.rb b/install_homebrew.rb index 8c5caaf92..e0e28ed43 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -7,6 +7,18 @@ # 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 +# 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 # @@ -74,6 +86,10 @@ chmods = %w(bin etc include lib sbin share var . share/locale share/man share/in select{ |d| File.directory? d and not File.writable? d } chgrps = chmods.reject{ |d| File.stat(d).grpowned? } +unless `groups`.split.include?("staff") + ohai "The user #{`whoami`.strip} will be added to the staff group." +end + unless chmods.empty? ohai "The following directories will be made group writable:" puts *chmods @@ -87,6 +103,10 @@ puts puts "Press enter to continue" abort unless getc == 13 +unless `groups`.split.include?("staff") + sudo "dscl /Local/Default -append /Groups/staff GroupMembership #{`whoami`.strip}" +end + if File.directory? "/usr/local" sudo "/bin/chmod", "g+w", *chmods unless chmods.empty? # all admin users are in staff -- cgit v1.2.3 From 16352d90b492a05a1feb09a0a1e475235eb37f60 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 6 Apr 2010 13:45:16 +0100 Subject: Moved code to top ready for amend --- install_homebrew.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index e0e28ed43..66c78d154 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -76,6 +76,10 @@ end abort "/usr/local/.git already exists!" if File.directory? "/usr/local/.git" abort "Don't run this as root!" if Process.uid == 0 +unless `groups`.split.include?("staff") + ohai "The user #{`whoami`.strip} will be added to the staff group." +end + ohai "This script will install:" puts "/usr/local/bin/brew" puts "/usr/local/Library/Formula/..." @@ -86,10 +90,6 @@ chmods = %w(bin etc include lib sbin share var . share/locale share/man share/in select{ |d| File.directory? d and not File.writable? d } chgrps = chmods.reject{ |d| File.stat(d).grpowned? } -unless `groups`.split.include?("staff") - ohai "The user #{`whoami`.strip} will be added to the staff group." -end - unless chmods.empty? ohai "The following directories will be made group writable:" puts *chmods -- cgit v1.2.3 From ca5bccd2d984589ad0f5abdebb215bc1f6059eae Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 6 Apr 2010 13:58:56 +0100 Subject: Only abort if user is not in staff group Rationale: We aren't sure if the suggested command works on 10.5 and this is an edge case. --- install_homebrew.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 66c78d154..572b315c4 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -1,5 +1,10 @@ #!/usr/bin/ruby # +# Download and execute this script in one-line with no temporary files: +# +# 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. @@ -75,10 +80,14 @@ end ####################################################################### script abort "/usr/local/.git already exists!" if File.directory? "/usr/local/.git" 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 +sucks for you then you can install Homebrew in your home directory or however +you please; please refer to the website. If you still want to use this script +the following command should work: -unless `groups`.split.include?("staff") - ohai "The user #{`whoami`.strip} will be added to the staff group." -end + dscl /Local/Default -append /Groups/staff GroupMembership $USER +EOABORT ohai "This script will install:" puts "/usr/local/bin/brew" @@ -103,10 +112,6 @@ puts puts "Press enter to continue" abort unless getc == 13 -unless `groups`.split.include?("staff") - sudo "dscl /Local/Default -append /Groups/staff GroupMembership #{`whoami`.strip}" -end - if File.directory? "/usr/local" sudo "/bin/chmod", "g+w", *chmods unless chmods.empty? # all admin users are in staff -- cgit v1.2.3 From ebbc2e5b3fae09f6497723a2f0cb12c2248c082e Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 12:04:01 +0000 Subject: Use full path to stty --- install_homebrew.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 572b315c4..fa95e381e 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -71,10 +71,10 @@ def sudo *args end def getc # NOTE only tested on OS X - system "stty raw -echo" + system "/bin/stty raw -echo" STDIN.getc ensure - system "stty -raw echo" + system "/bin/stty -raw echo" end ####################################################################### script -- cgit v1.2.3 From 4c0545619d3aaa91f78e00a0d13e662a078a6543 Mon Sep 17 00:00:00 2001 From: mattetti Date: Mon, 17 May 2010 19:10:10 -0700 Subject: Use getbyte and not getc --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index fa95e381e..6edfb4067 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -72,7 +72,7 @@ end def getc # NOTE only tested on OS X system "/bin/stty raw -echo" - STDIN.getc + STDIN.getbyte ensure system "/bin/stty -raw echo" end -- cgit v1.2.3 From 97b5808cac7940f35eaaa5f9a66fcb5a6795e1d4 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 28 May 2010 00:54:53 +0100 Subject: Warn if Xcode is not installed. --- install_homebrew.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 6edfb4067..6dcd4113e 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -131,11 +131,5 @@ end 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" -- cgit v1.2.3 From 7a193f39b75fa97f930545125a9ae24b92a605e7 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 5 Jun 2010 12:29:37 +0100 Subject: Support Ruby < 1.8.7 --- install_homebrew.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 6dcd4113e..7cc91f7b1 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -72,7 +72,11 @@ end 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 -- cgit v1.2.3 From 13e73a2c556d7acf3556290579089c2e0f59684e Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 15 Jun 2010 12:00:51 +0100 Subject: Duplicating installation steps sucks --- install_homebrew.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 7cc91f7b1..508338d38 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -1,16 +1,8 @@ #!/usr/bin/ruby # -# Download and execute this script in one-line with no temporary files: +# This script installs to /usr/local only. To install elsewhere you can 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 @@ end 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!" -- cgit v1.2.3 From f939a2c8b249d6fee560349fd5c7348bd16e47bb Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 16 Jun 2010 08:53:46 +0100 Subject: chmod Library and libexec too --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 508338d38..793186f15 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -90,7 +90,7 @@ puts "/usr/local/bin/brew" 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? } -- cgit v1.2.3 From d9f1be7ef270458b38d9b41d64d0d807dbabd405 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 16 Jun 2010 13:17:54 +0100 Subject: Use original system function for gcc check --- install_homebrew.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 793186f15..ee2042ab0 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -45,11 +45,9 @@ end 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 @@ 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." unless system "/usr/bin/which gcc" +warn "Now install Xcode." unless Kernel.system "/usr/bin/which -s gcc" -- cgit v1.2.3 From dec885bc16a2238e842c447dd10b9db00cd7554a Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 23 Jun 2010 16:25:53 +0100 Subject: Check for tty before trying to grab it --- install_homebrew.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index ee2042ab0..d8c28560c 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -102,9 +102,11 @@ unless chgrps.empty? 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? -- cgit v1.2.3 From 76ad14507ce71126d9446e08b99dbbb056bc296b Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 23 Jun 2010 16:26:02 +0100 Subject: Direct the user to Xcode download --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index d8c28560c..bfd6faac3 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -128,4 +128,4 @@ 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." 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" -- cgit v1.2.3 From 897dd14ae5ab775470264156ddd3645ffb37cfaa Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 11:56:35 +0000 Subject: Amend paths to check for chmods --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index bfd6faac3..a43839ae1 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -88,7 +88,7 @@ puts "/usr/local/bin/brew" 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 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? } -- cgit v1.2.3 From d39364b70a451a0a0bbd5c5abd1bca2371173c72 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 11:57:10 +0000 Subject: Use full path to sudo --- install_homebrew.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index a43839ae1..037d75b45 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -52,9 +52,9 @@ end 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 -- cgit v1.2.3 From bdbb8dc2a4fbbf93c93d680837b91ebc7ac94231 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 11:57:33 +0000 Subject: Check for all manpaths --- install_homebrew.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 037d75b45..b0740572b 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -88,7 +88,10 @@ puts "/usr/local/bin/brew" 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? } -- cgit v1.2.3 From a721e736c595e276d215fd35a2e056010765d081 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Thu, 23 Sep 2010 08:54:43 +0100 Subject: If curl fails propagate its exit status through the pipe --- install_homebrew.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index b0740572b..28a8fa812 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -125,7 +125,8 @@ end 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!" -- cgit v1.2.3 From 2cb0bd2caef31b5f7967478d21f8b6928b9616c6 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 11:57:53 +0000 Subject: Github URLS now are https --- install_homebrew.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 28a8fa812..cddc44a32 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -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: @@ -126,7 +126,7 @@ 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 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!" -- cgit v1.2.3 From 06450d492418c9980f57d307e6edc4e1448b7b0c Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 11:58:57 +0000 Subject: We don't care about var/log Actually not sure about this commit's purpose. It was a gist edit, so no commit message was provided. --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index cddc44a32..39fc1416e 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -88,7 +88,7 @@ puts "/usr/local/bin/brew" 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 ). -- cgit v1.2.3 From 2332a564aa6b266200fb5f924165974b2b296ca3 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 29 Jul 2011 15:17:20 +0100 Subject: Less documentation Changelog documentation, what were we thinking? --- install_homebrew.rb | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 39fc1416e..0db88e754 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -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 -- cgit v1.2.3 From 3c2656c9339738e97480ea5854d0756f2449c929 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 29 Jul 2011 15:17:35 +0100 Subject: Better check for already installed --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 0db88e754..adc7882b9 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -54,7 +54,7 @@ ensure 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 -- cgit v1.2.3 From 1fb3a2e20c04f6c5715283c1c731f5d4f743e860 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 29 Jul 2011 15:20:00 +0100 Subject: Ensure resulting /usr/local is not user writable Because we should do as little modification to the system as possible. Even though /usr/local doesn't exist on a virgin OS X, many tools create it, and some of them expect /usr/local to be root owned for security reasons. This modification fixes Airfoil on systems where it is installed. The result of this is we can no longer create new directories in the HOMEBREW_PREFIX unless we check and prompt for sudo first when required. --- install_homebrew.rb | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index adc7882b9..7c103c0ea 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -70,12 +70,16 @@ puts "/usr/local/bin/brew" 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 @@ unless chgrps.empty? 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 @@ Dir.chdir "/usr/local" do 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" -- cgit v1.2.3 From 4696401e5d62167338bf0e9e15d66e22bb1994ac Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 29 Jul 2011 15:20:32 +0100 Subject: Look for bad dylibs in the installer A common source of compile error, lets tell the user straight away. Removed relevant documentation from the installation instructions as a consequence. --- install_homebrew.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/install_homebrew.rb b/install_homebrew.rb index 7c103c0ea..08299f74b 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -53,6 +53,15 @@ ensure 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 @@ 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" + +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" -- cgit v1.2.3 From ab66113f0bac341b161bdb28c80bb1575093e744 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 6 Aug 2011 11:28:07 +0100 Subject: Ensure that we undo the o+w chmod --- install_homebrew.rb | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 08299f74b..88312d750 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -109,23 +109,24 @@ 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..." - # -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" -- cgit v1.2.3 From c1568ab27746d993ec2d25276c625e42297d7555 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 6 Aug 2011 12:02:55 +0100 Subject: Fix install script for Ruby 1.9.x --- install_homebrew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 88312d750..540c7e0f2 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -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 -- cgit v1.2.3 From 9c5ad5c978cb4cad86e264a739cc35bf1391e317 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 15 Aug 2011 12:28:17 +0100 Subject: Error out with link to help if OS X < 10.5 --- install_homebrew.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install_homebrew.rb b/install_homebrew.rb index 540c7e0f2..c172f058f 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -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" -- cgit v1.2.3 From cb3ffba6351f8874115138bc08f723bb1a3d557c Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 23 Aug 2011 22:01:27 +0100 Subject: Revert "Ensure that we undo the o+w chmod" This reverts commit b3d5ac0c8500006ef4fbd0bf3bd53b22a06869ab. --- install_homebrew.rb | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index c172f058f..f77aa947c 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -114,24 +114,23 @@ end 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" -- cgit v1.2.3 From 283cefa1633dfd1b04c84cd4dc84c5e24e3d0cc9 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 23 Aug 2011 22:01:31 +0100 Subject: Revert "Ensure resulting /usr/local is not user writable" This reverts commit 549e7c1c2046010430849a3e92ecefb64b21a733. --- install_homebrew.rb | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index f77aa947c..3ad1e0515 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -84,16 +84,12 @@ puts "/usr/local/bin/brew" 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 @@ unless chgrps.empty? 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 @@ Dir.chdir "/usr/local" do 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" -- cgit v1.2.3 From 488252ddbf668ba491b48e61fbd217d34b9b5dad Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 23 Aug 2011 22:03:03 +0100 Subject: Tidy ohais --- install_homebrew.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 3ad1e0515..fee829829 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -125,8 +125,6 @@ Dir.chdir "/usr/local" do 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" -- cgit v1.2.3 From d053188da4fa45fbd7864f58f0fa5292fdf6531d Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 23 Aug 2011 22:03:55 +0100 Subject: curl -k --- install_homebrew.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index fee829829..f206444f9 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -122,7 +122,9 @@ 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'" + # 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' -- cgit v1.2.3 From 63d8cb1a6ba5745e9510761399d0799bdc9e5384 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 24 Aug 2011 13:37:54 +0100 Subject: We need the executable permission to create files in directories Fixes Homebrew/homebrew#6512. I also set +r as a bunch of Homebrew will fail without that. --- install_homebrew.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index f206444f9..ea2bd9b19 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -108,12 +108,12 @@ if STDIN.tty? 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 -- cgit v1.2.3 From cadc0506f9e94f17f522fdd5c14cfb8bbf228d9b Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 29 Aug 2011 10:24:12 +0100 Subject: cd KNOWN_DIR before executing any functions or tools It is fucking amazing how much shit breaks if CWD is invalid. Fucking amazing. Also fuck you dumb user who can't figure out what "No such file or directory - getcwd" means so you force me to waste half an hour fixing it for you. --- install_homebrew.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install_homebrew.rb b/install_homebrew.rb index ea2bd9b19..07485e4d3 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -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? -- cgit v1.2.3 From 98ec342ecc597d0bb2806fbd2a5fafb796caf8ed Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 31 Aug 2011 11:24:56 +0100 Subject: Use admin group and not staff Staff is overly permissive, require user to be an Administrator to use Homebrew. --- install_homebrew.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 07485e4d3..f17036a14 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -74,13 +74,11 @@ Dir.chdir "/usr" 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" -This script requires the user #{ENV['USER']} to be in the staff group. If this +abort <<-EOABORT unless `groups`.split.include? "admin" +This script requires the user #{ENV['USER']} to be an Administrator. If this sucks for you then you can install Homebrew in your home directory or however you please; please refer to the website. If you still want to use this script -the following command should work: - - dscl /Local/Default -append /Groups/staff GroupMembership $USER +set your user to be an Administrator in System Preferences or `su'. EOABORT ohai "This script will install:" @@ -101,7 +99,7 @@ unless chmods.empty? puts *chmods end unless chgrps.empty? - ohai "The following directories will have their group set to #{Tty.underline 39}staff#{Tty.reset}:" + ohai "The following directories will have their group set to #{Tty.underline 39}admin#{Tty.reset}:" puts *chgrps end @@ -113,13 +111,12 @@ end if File.directory? "/usr/local" sudo "/bin/chmod", "g+rwx", *chmods unless chmods.empty? - # all admin users are in staff - sudo "/usr/bin/chgrp", "staff", *chgrps unless chgrps.empty? + sudo "/usr/bin/chgrp", "admin", *chgrps unless chgrps.empty? else sudo "/bin/mkdir /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" + sudo "/usr/bin/chgrp admin /usr/local" end Dir.chdir "/usr/local" do -- cgit v1.2.3 From dfa75f9230f75060a693add842fcdc5648398c69 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 11:59:40 +0000 Subject: Allow "Press Enter" to be a \r Some wrapper-tools push \r rather than \n and break the installer. --- install_homebrew.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index f17036a14..df3a017e4 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -106,7 +106,9 @@ end if STDIN.tty? puts puts "Press enter to continue" - abort unless getc == 13 + c = getc + # we test for \r and \n because some stuff does \r instead + abort unless c == 13 or c == 10 end if File.directory? "/usr/local" -- cgit v1.2.3 From f37e22838cb0df651f50dd063135d975f7d30e3f Mon Sep 17 00:00:00 2001 From: Max Howell Date: Thu, 16 Feb 2012 20:20:14 +0000 Subject: Encourage usage of the new CLT4Xcode --- install_homebrew.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index df3a017e4..25510a25b 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -131,7 +131,12 @@ Dir.chdir "/usr/local" do end 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" + +if macos_version < 10.7 + warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc" +else + warn "Install \"Command Line Tools for Xcode\": http://developer.apple.com/downloads" unless File.file? "/usr/bin/xcrun" +end unless badlibs.empty? warn "The following *evil* dylibs exist in /usr/local/lib" -- cgit v1.2.3 From af3e5ad979fe69a2c592d11028821f6894c6206c Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 21 Feb 2012 09:53:03 +0000 Subject: Improve messaging for this 0.01% edge case --- install_homebrew.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 25510a25b..ee58255e8 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -77,8 +77,9 @@ abort "Don't run this as root!" if Process.uid == 0 abort <<-EOABORT unless `groups`.split.include? "admin" This script requires the user #{ENV['USER']} to be an Administrator. If this sucks for you then you can install Homebrew in your home directory or however -you please; please refer to the website. If you still want to use this script -set your user to be an Administrator in System Preferences or `su'. +you please; please refer to our homepage. If you still want to use this script +set your user to be an Administrator in System Preferences or `su' to a +non-root user with Administrator privileges. EOABORT ohai "This script will install:" -- cgit v1.2.3 From a7ac3c539d3a42c0bb6e38bfbf61ee9c5c0c6615 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 12:17:36 +0000 Subject: rm bad-dylibs check, brew doctor does this better --- install_homebrew.rb | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index ee58255e8..13f34ba00 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -53,19 +53,11 @@ ensure 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 - 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" @@ -139,11 +131,5 @@ else warn "Install \"Command Line Tools for Xcode\": http://developer.apple.com/downloads" unless File.file? "/usr/bin/xcrun" end -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" -- cgit v1.2.3 From 6345ceef1fa13830b720dbf425c7408100ce2570 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 9 Mar 2012 12:17:49 +0000 Subject: Update Xcode checks and URLs --- install_homebrew.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_homebrew.rb b/install_homebrew.rb index 13f34ba00..8b26f035b 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -126,9 +126,9 @@ end warn "/usr/local/bin is not in your PATH." unless ENV['PATH'].split(':').include? '/usr/local/bin' if macos_version < 10.7 - warn "Now install Xcode: http://developer.apple.com/technologies/xcode.html" unless Kernel.system "/usr/bin/which -s gcc" + warn "Now install Xcode: https://developer.apple.com/xcode/" unless File.exist? "/usr/bin/cc" else - warn "Install \"Command Line Tools for Xcode\": http://developer.apple.com/downloads" unless File.file? "/usr/bin/xcrun" + warn "Now install the \"Command Line Tools for Xcode\": http://connect.apple.com" unless File.file? "/usr/bin/xcrun" end ohai "Installation successful!" -- cgit v1.2.3