Class: RightConf::BrewInstaller
- Inherits:
-
Object
- Object
- RightConf::BrewInstaller
- Includes:
- ProgressReporter
- Defined in:
- lib/rconf/support/brew_installer.rb
Class Method Summary collapse
Methods included from ProgressReporter
included, report_to_file, report_to_stdout
Class Method Details
.check_and_install ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rconf/support/brew_installer.rb', line 18 def self.check_and_install return true if File.directory?('/usr/local/.git') report_check('Installing Homebrew') 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? } if File.directory?('/usr/local') Command.sudo('/bin/chmod', 'g+w', *chmods) unless chmods.empty? # all admin users are in staff Command.sudo('/usr/bin/chgrp', 'staff', *chgrps) unless chgrps.empty? else Command.sudo('/bin/mkdir', '/usr/local') Command.sudo('/bin/chmod', 'g+w', '/usr/local') # the group is set to wheel by default for some reason Command.sudo('/usr/bin/chgrp', 'staff', '/usr/local') end Dir.chdir('/usr/local') do # -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 report_success unless chmods.empty? report("The following directories had to be made group writable: #{chmods.join(', ')}") end unless chgrps.empty? report("The following directories had their group set to staff: #{chgrps.join(', ')}") end unless ENV['PATH'].split(':').include? '/usr/local/bin' report('/usr/local/bin is not in your PATH.') end end |