superenv: fix formula prefix path to consider revisions

Old logic doesn't include revision. This fixes that, and passes the
whole formula prefix path to avoid duplicating the path-construction
logic.

Closes #80.

Signed-off-by: Andrew Janke <andrew@apjanke.net>
This commit is contained in:
Andrew Janke 2016-04-13 02:53:41 -04:00
parent a8ed06ba74
commit 36b2af2e0f
2 changed files with 4 additions and 11 deletions

View File

@ -15,7 +15,7 @@ require "set"
class Cmd
attr_reader :config, :prefix, :cellar, :opt, :tmpdir, :sysroot, :deps
attr_reader :archflags, :optflags, :keg_regex, :formula, :formula_version
attr_reader :archflags, :optflags, :keg_regex, :formula_prefix
def initialize(arg0, args)
@arg0 = arg0
@ -29,8 +29,7 @@ class Cmd
@archflags = ENV.fetch("HOMEBREW_ARCHFLAGS") { "" }.split(" ")
@optflags = ENV.fetch("HOMEBREW_OPTFLAGS") { "" }.split(" ")
@deps = Set.new(ENV.fetch("HOMEBREW_DEPENDENCIES") { "" }.split(","))
@formula = ENV["HOMEBREW_FORMULA"]
@formula_version = ENV["HOMEBREW_FORMULA_VERSION"]
@formula_prefix = ENV["HOMEBREW_FORMULA_PREFIX"]
# matches opt or cellar prefix and formula name
@keg_regex = %r[(#{Regexp.escape(opt)}|#{Regexp.escape(cellar)})/([\w\-_\+]+)]
end
@ -208,7 +207,7 @@ class Cmd
return keep_orig?(path) unless ENV["HOMEBREW_EXPERIMENTAL_FILTER_FLAGS_ON_DEPS"]
# Allow references to self
if keg_path && path.start_with?(keg_path)
if formula_prefix && path.start_with?("#{formula_prefix}/")
true
# first two paths: reject references to Cellar or opt paths
# for unspecified dependencies
@ -281,11 +280,6 @@ class Cmd
%W[#{sysroot}/usr/lib /usr/local/lib]
end
def keg_path
return nil if formula.nil?
"#{cellar}/#{formula}/#{formula_version}"
end
def configure?
# configure scripts generated with autoconf 2.61 or later export as_nl
ENV.key? "as_nl"

View File

@ -69,8 +69,7 @@ module Superenv
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
unless formula.nil?
self["HOMEBREW_FORMULA"] = formula.name
self["HOMEBREW_FORMULA_VERSION"] = formula.version
self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
end
if MacOS::Xcode.without_clt? || (MacOS::Xcode.installed? && MacOS::Xcode.version.to_i >= 7)