diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/caskroom.rb | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb index 583cac34a..6375345ee 100644 --- a/Library/Homebrew/cask/lib/hbc/caskroom.rb +++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb @@ -13,7 +13,7 @@ module Hbc FileUtils.mv repo_caskroom, Hbc.caskroom else opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom." - system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s + sudo "/bin/mv", repo_caskroom.to_s, Hbc.caskroom.parent.to_s end end @@ -21,24 +21,17 @@ module Hbc return if Hbc.caskroom.exist? ohai "Creating Caskroom at #{Hbc.caskroom}" - if Hbc.caskroom.parent.writable? - Hbc.caskroom.mkpath - else - ohai "We'll set permissions properly so we won't need sudo in the future" - toplevel_dir = Hbc.caskroom - toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root? - unless toplevel_dir.directory? - # If a toplevel dir such as '/opt' must be created, enforce standard permissions. - # sudo in system is rude. - system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir - system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir - end - # sudo in system is rude. - system "/usr/bin/sudo", "--", "/bin/mkdir", "-p", "--", Hbc.caskroom - unless Hbc.caskroom.parent == toplevel_dir - system "/usr/bin/sudo", "--", "/usr/sbin/chown", "-R", "--", "#{Utils.current_user}:staff", Hbc.caskroom.parent.to_s - end - end + ohai "We'll set permissions properly so we won't need sudo in the future" + + sudo "/bin/mkdir", "-p", Hbc.caskroom + sudo "/bin/chmod", "g+rwx", Hbc.caskroom + sudo "/usr/sbin/chown", Utils.current_user, Hbc.caskroom + sudo "/usr/bin/chgrp", "admin", Hbc.caskroom + end + + def sudo(*args) + ohai "/usr/bin/sudo #{args.join(" ")}" + system "/usr/bin/sudo", *args end end end |
