Module: Hbc::Caskroom

Defined in:
Library/Homebrew/cask/lib/hbc/caskroom.rb

Class Method Summary collapse

Class Method Details

.ensure_caskroom_existsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'Library/Homebrew/cask/lib/hbc/caskroom.rb', line 5

def ensure_caskroom_exists
  return if Hbc.caskroom.exist?

  ohai "Creating Caskroom at #{Hbc.caskroom}" if $stdout.tty?
  sudo = !Hbc.caskroom.parent.writable?

  ohai "We'll set permissions properly so we won't need sudo in the future" if $stdout.tty? && sudo

  SystemCommand.run("/bin/mkdir", args: ["-p", Hbc.caskroom], sudo: sudo)
  SystemCommand.run("/bin/chmod", args: ["g+rwx", Hbc.caskroom], sudo: sudo)
  SystemCommand.run("/usr/sbin/chown", args: [Utils.current_user, Hbc.caskroom], sudo: sudo)
  SystemCommand.run("/usr/bin/chgrp", args: ["admin", Hbc.caskroom], sudo: sudo)
end