Class: RightConf::BrewInstaller
- Inherits:
-
Object
- Object
- RightConf::BrewInstaller
- Includes:
- ProgressReporter
- Defined in:
- lib/rconf/support/brew_installer.rb
Class Method Summary collapse
-
.check_and_install ⇒ Object
Check whether brew is already installed and install it if not.
Instance Method Summary collapse
-
#install ⇒ Object
Actually install brew.
Methods included from ProgressReporter
included, report_to_file, report_to_stdout
Class Method Details
.check_and_install ⇒ Object
Check whether brew is already installed and install it if not
Return
- true
-
Always return true
22 23 24 25 26 |
# File 'lib/rconf/support/brew_installer.rb', line 22 def self.check_and_install installed = Command.execute('brew', '--version').success? return true if installed new.install end |
Instance Method Details
#install ⇒ Object
Actually install brew
Return
- true
-
Always return true
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 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rconf/support/brew_installer.rb', line 32 def install 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 |