parent
bae36f0830
commit
4c9ac19e87
@ -18,10 +18,6 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end unless ARGV.force?
|
end unless ARGV.force?
|
||||||
|
|
||||||
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
|
|
||||||
raise "Cowardly refusing to `sudo brew install'\n#{SUDO_BAD_ERRMSG}"
|
|
||||||
end
|
|
||||||
|
|
||||||
install_formulae ARGV.formulae
|
install_formulae ARGV.formulae
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,6 @@ module Homebrew extend self
|
|||||||
def link
|
def link
|
||||||
raise KegUnspecifiedError if ARGV.named.empty?
|
raise KegUnspecifiedError if ARGV.named.empty?
|
||||||
|
|
||||||
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
|
|
||||||
raise "Cowardly refusing to `sudo brew link'\n#{SUDO_BAD_ERRMSG}"
|
|
||||||
end
|
|
||||||
|
|
||||||
mode = OpenStruct.new
|
mode = OpenStruct.new
|
||||||
|
|
||||||
mode.overwrite = true if ARGV.include? '--overwrite'
|
mode.overwrite = true if ARGV.include? '--overwrite'
|
||||||
|
|||||||
@ -2,9 +2,6 @@ require 'formula'
|
|||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def pin
|
def pin
|
||||||
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
|
|
||||||
abort "Cowardly refusing to `sudo pin'"
|
|
||||||
end
|
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||||
|
|
||||||
ARGV.formulae.each do |f|
|
ARGV.formulae.each do |f|
|
||||||
|
|||||||
@ -2,9 +2,6 @@ require 'formula'
|
|||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def unpin
|
def unpin
|
||||||
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
|
|
||||||
abort "Cowardly refusing to `sudo unpin'"
|
|
||||||
end
|
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||||
|
|
||||||
ARGV.formulae.each do |f|
|
ARGV.formulae.each do |f|
|
||||||
|
|||||||
@ -8,12 +8,6 @@ end
|
|||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def upgrade
|
def upgrade
|
||||||
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
|
|
||||||
# note we only abort if Homebrew is *not* installed as sudo and the user
|
|
||||||
# calls brew as root. The fix is to chown brew to root.
|
|
||||||
abort "Cowardly refusing to `sudo brew upgrade'"
|
|
||||||
end
|
|
||||||
|
|
||||||
Homebrew.perform_preinstall_checks
|
Homebrew.perform_preinstall_checks
|
||||||
|
|
||||||
if ARGV.named.empty?
|
if ARGV.named.empty?
|
||||||
|
|||||||
@ -213,11 +213,3 @@ class ChecksumMismatchError < RuntimeError
|
|||||||
super + advice.to_s
|
super + advice.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Homebrew extend self
|
|
||||||
SUDO_BAD_ERRMSG = <<-EOS.undent
|
|
||||||
You can use brew with sudo, but only if the brew executable is owned by root.
|
|
||||||
However, this is both not recommended and completely unsupported so do so at
|
|
||||||
your own risk.
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|||||||
@ -99,3 +99,9 @@ HOMEBREW_PULL_OR_COMMIT_URL_REGEX = 'https:\/\/github.com\/(\w+)\/homebrew(-\w+)
|
|||||||
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
|
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
|
||||||
|
|
||||||
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
||||||
|
|
||||||
|
SUDO_BAD_ERRMSG = <<-EOS.undent
|
||||||
|
You can use brew with sudo, but only if the brew executable is owned by root.
|
||||||
|
However, this is both not recommended and completely unsupported so do so at
|
||||||
|
your own risk.
|
||||||
|
EOS
|
||||||
|
|||||||
@ -58,17 +58,17 @@ end
|
|||||||
begin
|
begin
|
||||||
trap("INT", std_trap) # restore default CTRL-C handler
|
trap("INT", std_trap) # restore default CTRL-C handler
|
||||||
|
|
||||||
aliases = {'ls' => :list,
|
aliases = {'ls' => 'list',
|
||||||
'homepage' => :home,
|
'homepage' => 'home',
|
||||||
'-S' => :search,
|
'-S' => 'search',
|
||||||
'up' => :update,
|
'up' => 'update',
|
||||||
'ln' => :link,
|
'ln' => 'link',
|
||||||
'instal' => :install, # gem does the same
|
'instal' => 'install', # gem does the same
|
||||||
'rm' => :uninstall,
|
'rm' => 'uninstall',
|
||||||
'remove' => :uninstall,
|
'remove' => 'uninstall',
|
||||||
'configure' => :diy,
|
'configure' => 'diy',
|
||||||
'abv' => :info,
|
'abv' => 'info',
|
||||||
'dr' => :doctor,
|
'dr' => 'doctor',
|
||||||
'--repo' => '--repository',
|
'--repo' => '--repository',
|
||||||
'environment' => '--env' # same as gem
|
'environment' => '--env' # same as gem
|
||||||
}
|
}
|
||||||
@ -76,11 +76,19 @@ begin
|
|||||||
cmd = ARGV.shift
|
cmd = ARGV.shift
|
||||||
cmd = aliases[cmd] if aliases[cmd]
|
cmd = aliases[cmd] if aliases[cmd]
|
||||||
|
|
||||||
if cmd == '-c1'
|
if cmd == '-c1' # Shortcut for one line of configuration
|
||||||
cmd = '--config'
|
cmd = '--config'
|
||||||
ARGV.unshift('-1')
|
ARGV.unshift('-1')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sudo_check = Set.new %w[ install link pin unpin upgrade ]
|
||||||
|
|
||||||
|
if sudo_check.include? cmd
|
||||||
|
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
|
||||||
|
raise "Cowardly refusing to `sudo brew #{cmd}`\n#{SUDO_BAD_ERRMSG}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Add example external commands to PATH before checking.
|
# Add example external commands to PATH before checking.
|
||||||
ENV['PATH'] += ":#{HOMEBREW_REPOSITORY}/Library/Contributions/cmd"
|
ENV['PATH'] += ":#{HOMEBREW_REPOSITORY}/Library/Contributions/cmd"
|
||||||
if require? HOMEBREW_REPOSITORY/"Library/Homebrew/cmd"/cmd
|
if require? HOMEBREW_REPOSITORY/"Library/Homebrew/cmd"/cmd
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user