Use full paths to all system utilities
Otherwise you run the risk of not running the exact version / make of the utility you planned. Fixes Homebrew/homebrew#48 Really we need to do this formula too, so I guess a make and cmake function are on the way…
This commit is contained in:
parent
034fc40ae1
commit
44a1fa418e
@ -95,7 +95,7 @@ def info name
|
|||||||
require 'formula'
|
require 'formula'
|
||||||
|
|
||||||
user=''
|
user=''
|
||||||
user=`git config --global github.user`.chomp if system "which git > /dev/null"
|
user=`git config --global github.user`.chomp if system "/usr/bin/which -s git"
|
||||||
user='mxcl' if user.empty?
|
user='mxcl' if user.empty?
|
||||||
# FIXME it would be nice if we didn't assume the default branch is master
|
# FIXME it would be nice if we didn't assume the default branch is master
|
||||||
history="http://github.com/#{user}/homebrew/commits/master/Library/Formula/#{Formula.path(name).basename}"
|
history="http://github.com/#{user}/homebrew/commits/master/Library/Formula/#{Formula.path(name).basename}"
|
||||||
|
|||||||
@ -187,5 +187,5 @@ def inreplace(path, before, after)
|
|||||||
after.gsub! "$", "\\$"
|
after.gsub! "$", "\\$"
|
||||||
|
|
||||||
# FIXME use proper Ruby for teh exceptions!
|
# FIXME use proper Ruby for teh exceptions!
|
||||||
safe_system "perl", "-pi", "-e", "s/#{before}/#{after}/g", path
|
safe_system "/usr/bin/perl", "-pi", "-e", "s/#{before}/#{after}/g", path
|
||||||
end
|
end
|
||||||
|
|||||||
@ -51,11 +51,11 @@ class HttpDownloadStrategy <AbstractDownloadStrategy
|
|||||||
def stage
|
def stage
|
||||||
case `file -b #{@dl}`
|
case `file -b #{@dl}`
|
||||||
when /^Zip archive data/
|
when /^Zip archive data/
|
||||||
safe_system 'unzip', '-qq', @dl
|
safe_system '/usr/bin/unzip', '-qq', @dl
|
||||||
chdir
|
chdir
|
||||||
when /^(gzip|bzip2) compressed data/
|
when /^(gzip|bzip2) compressed data/
|
||||||
# TODO do file -z now to see if it is in fact a tar
|
# TODO do file -z now to see if it is in fact a tar
|
||||||
safe_system 'tar', 'xf', @dl
|
safe_system '/usr/bin/tar', 'xf', @dl
|
||||||
chdir
|
chdir
|
||||||
else
|
else
|
||||||
# we are assuming it is not an archive, use original filename
|
# we are assuming it is not an archive, use original filename
|
||||||
@ -94,7 +94,7 @@ class SubversionDownloadStrategy <AbstractDownloadStrategy
|
|||||||
ohai "Checking out #{@url}"
|
ohai "Checking out #{@url}"
|
||||||
@co=HOMEBREW_CACHE+@unique_token
|
@co=HOMEBREW_CACHE+@unique_token
|
||||||
unless @co.exist?
|
unless @co.exist?
|
||||||
safe_system 'svn', 'checkout', @url, @co
|
safe_system '/usr/bin/svn', 'checkout', @url, @co
|
||||||
else
|
else
|
||||||
# TODO svn up?
|
# TODO svn up?
|
||||||
puts "Repository already checked out"
|
puts "Repository already checked out"
|
||||||
@ -102,7 +102,7 @@ class SubversionDownloadStrategy <AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
def stage
|
def stage
|
||||||
# Force the export, since the target directory will already exist
|
# Force the export, since the target directory will already exist
|
||||||
safe_system 'svn', 'export', '--force', @co, Dir.pwd
|
safe_system '/usr/bin/svn', 'export', '--force', @co, Dir.pwd
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -217,7 +217,7 @@ private
|
|||||||
# I used /tmp rather than mktemp -td because that generates a directory
|
# I used /tmp rather than mktemp -td because that generates a directory
|
||||||
# name with exotic characters like + in it, and these break badly written
|
# name with exotic characters like + in it, and these break badly written
|
||||||
# scripts that don't escape strings before trying to regexp them :(
|
# scripts that don't escape strings before trying to regexp them :(
|
||||||
tmp=Pathname.new `mktemp -d /tmp/homebrew-#{name}-#{version}-XXXX`.strip
|
tmp=Pathname.new `/usr/bin/mktemp -d /tmp/homebrew-#{name}-#{version}-XXXX`.strip
|
||||||
raise "Couldn't create build sandbox" if not tmp.directory? or $? != 0
|
raise "Couldn't create build sandbox" if not tmp.directory? or $? != 0
|
||||||
begin
|
begin
|
||||||
wd=Dir.pwd
|
wd=Dir.pwd
|
||||||
@ -311,12 +311,12 @@ private
|
|||||||
|
|
||||||
patch_list.each do |p|
|
patch_list.each do |p|
|
||||||
case p[:compression]
|
case p[:compression]
|
||||||
when :gzip then safe_system "gunzip", p[:filename]+'.gz'
|
when :gzip then safe_system "/usr/bin/gunzip", p[:filename]+'.gz'
|
||||||
when :bzip2 then safe_system "bunzip2", p[:filename]+'.bz2'
|
when :bzip2 then safe_system "/usr/bin/bunzip2", p[:filename]+'.bz2'
|
||||||
end
|
end
|
||||||
# -f means it doesn't prompt the user if there are errors, if just
|
# -f means it doesn't prompt the user if there are errors, if just
|
||||||
# exits with non-zero status
|
# exits with non-zero status
|
||||||
safe_system 'patch', '-f', *(p[:args])
|
safe_system '/usr/bin/patch', '-f', *(p[:args])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ end
|
|||||||
class TestZip <Formula
|
class TestZip <Formula
|
||||||
def initialize
|
def initialize
|
||||||
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
||||||
Kernel.system 'zip', '-0', zip, ABS__FILE__
|
Kernel.system '/usr/bin/zip', '-0', zip, ABS__FILE__
|
||||||
@url="file://#{zip}"
|
@url="file://#{zip}"
|
||||||
super 'testzip'
|
super 'testzip'
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
# args are additional inputs to puts until a nil arg is encountered
|
# args are additional inputs to puts until a nil arg is encountered
|
||||||
def ohai title, *sput
|
def ohai title, *sput
|
||||||
title = title[0, `tput cols`.strip.to_i-4] unless ARGV.verbose?
|
title = title[0, `/usr/bin/tput cols`.strip.to_i-4] unless ARGV.verbose?
|
||||||
puts "\033[0;34m==>\033[0;0;1m #{title}\033[0;0m"
|
puts "\033[0;34m==>\033[0;0;1m #{title}\033[0;0m"
|
||||||
puts *sput unless sput.empty?
|
puts *sput unless sput.empty?
|
||||||
end
|
end
|
||||||
@ -59,12 +59,12 @@ end
|
|||||||
# Kernel.system but with exceptions
|
# Kernel.system but with exceptions
|
||||||
def safe_system cmd, *args
|
def safe_system cmd, *args
|
||||||
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
||||||
exec_success=Kernel.system cmd, *args
|
exec_success = Kernel.system cmd, *args
|
||||||
# some tools, eg. tar seem to confuse ruby and it doesn't propogate the
|
# some tools, eg. tar seem to confuse ruby and it doesn't propogate the
|
||||||
# CTRL-C interrupt to us too, so execution continues, but the exit code os
|
# CTRL-C interrupt to us too, so execution continues, but the exit code os
|
||||||
# still 2 so we raise our own interrupt
|
# still 2 so we raise our own interrupt
|
||||||
raise Interrupt, cmd if $?.termsig == 2
|
raise Interrupt, cmd if $?.termsig == 2
|
||||||
unless exec_success and $?.success?
|
unless exec_success
|
||||||
puts "Exit code: #{$?}"
|
puts "Exit code: #{$?}"
|
||||||
raise ExecutionError.new(cmd, args)
|
raise ExecutionError.new(cmd, args)
|
||||||
end
|
end
|
||||||
@ -75,23 +75,23 @@ def curl *args
|
|||||||
end
|
end
|
||||||
|
|
||||||
def puts_columns items, cols = 4
|
def puts_columns items, cols = 4
|
||||||
items = items.join("\n") if items.is_a?(Array)
|
|
||||||
items.concat("\n") unless items.empty?
|
|
||||||
if $stdout.tty?
|
if $stdout.tty?
|
||||||
width=`stty size`.chomp.split(" ").last
|
items = items.join("\n") if items.is_a?(Array)
|
||||||
IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
|
items.concat("\n") unless items.empty?
|
||||||
|
width=`/bin/stty size`.chomp.split(" ").last
|
||||||
|
IO.popen("/usr/bin/pr -#{cols} -t", "w"){|io| io.write(items) }
|
||||||
else
|
else
|
||||||
items.each { |i| $stdout.write(i) }
|
puts *items
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def exec_editor *args
|
def exec_editor *args
|
||||||
editor=ENV['EDITOR']
|
editor=ENV['EDITOR']
|
||||||
if editor.nil?
|
if editor.nil?
|
||||||
if system "which -s mate" and $?.success?
|
if system "/usr/bin/which -s mate"
|
||||||
editor='mate'
|
editor='mate'
|
||||||
else
|
else
|
||||||
editor='vim'
|
editor='/usr/bin/vim'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# we split the editor because especially on mac "mate -w" is common
|
# we split the editor because especially on mac "mate -w" is common
|
||||||
@ -103,9 +103,9 @@ end
|
|||||||
# provide an absolute path to a command or this function will search the PATH
|
# provide an absolute path to a command or this function will search the PATH
|
||||||
def arch_for_command cmd
|
def arch_for_command cmd
|
||||||
archs = []
|
archs = []
|
||||||
cmd = `which #{cmd}` if not Pathname.new(cmd).absolute?
|
cmd = `/usr/bin/which #{cmd}` if not Pathname.new(cmd).absolute?
|
||||||
|
|
||||||
IO.popen("file #{cmd}").readlines.each do |line|
|
IO.popen("/usr/bin/file #{cmd}").readlines.each do |line|
|
||||||
case line
|
case line
|
||||||
when /Mach-O executable ppc/
|
when /Mach-O executable ppc/
|
||||||
archs << :ppc7400
|
archs << :ppc7400
|
||||||
|
|||||||
6
bin/brew
6
bin/brew
@ -11,20 +11,20 @@ if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-EOS
|
|||||||
#{HOMEBREW_WWW}
|
#{HOMEBREW_WWW}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
if `sw_vers -productVersion` =~ /10\.(\d)\.(\d+)/ and $1.to_i < 5
|
|
||||||
|
|
||||||
# remove MacPorts and Fink from the PATH, this prevents issues like:
|
# remove MacPorts and Fink from the PATH, this prevents issues like:
|
||||||
# http://github.com/mxcl/homebrew/issues/#issue/13
|
# http://github.com/mxcl/homebrew/issues/#issue/13
|
||||||
# http://github.com/mxcl/homebrew/issues/#issue/48
|
# http://github.com/mxcl/homebrew/issues/#issue/48
|
||||||
fix_PATH
|
fix_PATH
|
||||||
|
|
||||||
|
if `/usr/bin/sw_vers -productVersion` =~ /10\.(\d)\.(\d+)/ and $1.to_i < 5
|
||||||
onoe "Homebrew requires Leopard or higher"
|
onoe "Homebrew requires Leopard or higher"
|
||||||
abort "But thanks for your interest anyway!"
|
abort "But thanks for your interest anyway!"
|
||||||
end
|
end
|
||||||
if Hardware.cpu_type == :ppc or Hardware.cpu_type == :dunno
|
if Hardware.cpu_type == :ppc or Hardware.cpu_type == :dunno
|
||||||
abort "Sorry, Homebrew does not support your computer's CPU architecture."
|
abort "Sorry, Homebrew does not support your computer's CPU architecture."
|
||||||
end
|
end
|
||||||
unless system "which -s gcc-4.2" and $?.success?
|
unless system "/usr/bin/which -s gcc-4.2"
|
||||||
abort "Sorry, Homebrew requires gcc 4.2, which is provided by Xcode 3.1"
|
abort "Sorry, Homebrew requires gcc 4.2, which is provided by Xcode 3.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ begin
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless ARGV.force?
|
unless ARGV.force?
|
||||||
unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success?
|
unless system "/usr/bin/which -s #{ENV.cc}"
|
||||||
raise "We cannot find a c compiler, have you installed the latest Xcode?"
|
raise "We cannot find a c compiler, have you installed the latest Xcode?"
|
||||||
end
|
end
|
||||||
formulae = ARGV.formulae.reject do |f|
|
formulae = ARGV.formulae.reject do |f|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user