aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-03-27 14:17:13 -0500
committerJack Nagel2014-03-27 14:23:49 -0500
commitad7911bb7518574b8faac9d418ab7d5fdcf55c11 (patch)
tree8bcee589a5a7adf89c5dc603f2be91d4631c408f /Library
parent0c99e648519091236a779c032f1702ae76747571 (diff)
downloadbrew-ad7911bb7518574b8faac9d418ab7d5fdcf55c11.tar.bz2
Replace files atomically when relocating, take two
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/keg_fix_install_names.rb18
1 files changed, 8 insertions, 10 deletions
diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb
index d36eb2543..777a5ed00 100644
--- a/Library/Homebrew/keg_fix_install_names.rb
+++ b/Library/Homebrew/keg_fix_install_names.rb
@@ -38,16 +38,14 @@ class Keg
end
end
- (pkgconfig_files | libtool_files | script_files).each do |file|
- file.ensure_writable do
- file.open('rb') do |f|
- s = f.read
- s.gsub!(old_cellar, new_cellar)
- s.gsub!(old_prefix, new_prefix)
- f.reopen(file, 'wb')
- f.write(s)
- end
- end
+ files = pkgconfig_files | libtool_files | script_files
+
+ files.group_by { |f| f.stat.ino }.each_value do |first, *rest|
+ s = first.open("rb", &:read)
+ s.gsub!(old_cellar, new_cellar)
+ s.gsub!(old_prefix, new_prefix)
+ first.atomic_write(s)
+ rest.each { |file| FileUtils.ln(first, file, :force => true) }
end
end