Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualenv relocation fixes #2442

Merged
merged 5 commits into from Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Library/Homebrew/extend/os/mac/keg_relocate.rb
Expand Up @@ -131,6 +131,12 @@ def mach_o_files
mach_o_files
end

def recursive_fgrep_args
# Don't recurse into symlinks; the man page says this is the default, but
# it's wrong. -O is a BSD-grep-only option.
"-lrO"
end

def self.file_linked_libraries(file, string)
# Check dynamic library linkage. Importantly, do not perform for static
# libraries, which will falsely report "linkage" to themselves.
Expand Down
17 changes: 13 additions & 4 deletions Library/Homebrew/keg_relocate.rb
Expand Up @@ -16,9 +16,12 @@ def fix_dynamic_linkage
link = file.readlink
# Don't fix relative symlinks
next unless link.absolute?
if link.to_s.start_with?(HOMEBREW_CELLAR.to_s) || link.to_s.start_with?(HOMEBREW_PREFIX.to_s)
FileUtils.ln_sf(link.relative_path_from(file.parent), file)
end
link_starts_cellar = link.to_s.start_with?(HOMEBREW_CELLAR.to_s)
link_starts_prefix = link.to_s.start_with?(HOMEBREW_PREFIX.to_s)
next if !link_starts_cellar && !link_starts_prefix
new_src = link.relative_path_from(file.parent)
file.unlink
FileUtils.ln_s(new_src, file)
end
end
alias generic_fix_dynamic_linkage fix_dynamic_linkage
Expand Down Expand Up @@ -96,8 +99,14 @@ def detect_cxx_stdlibs(_options = {})
[]
end

def recursive_fgrep_args
# for GNU grep; overridden for BSD grep on OS X
"-lr"
end
alias generic_recursive_fgrep_args recursive_fgrep_args

def each_unique_file_matching(string)
Utils.popen_read("/usr/bin/fgrep", "-lr", string, to_s) do |io|
Utils.popen_read("/usr/bin/fgrep", recursive_fgrep_args, string, to_s) do |io|
hardlinks = Set.new

until io.eof?
Expand Down