extend/fileutils: assume Ruby 2.
This commit is contained in:
parent
7dddc4df9f
commit
f32251d461
@ -98,54 +98,6 @@ module FileUtils
|
|||||||
end
|
end
|
||||||
module_function :mkdir
|
module_function :mkdir
|
||||||
|
|
||||||
# The #copy_metadata method in all current versions of Ruby has a
|
|
||||||
# bad bug which causes copying symlinks across filesystems to fail;
|
|
||||||
# see #14710.
|
|
||||||
# This was resolved in Ruby HEAD after the release of 1.9.3p194, but
|
|
||||||
# never backported into the 1.9.3 branch. Fixed in 2.0.0.
|
|
||||||
# The monkey-patched method here is copied directly from upstream fix.
|
|
||||||
if RUBY_VERSION < "2.0.0"
|
|
||||||
# @private
|
|
||||||
class Entry_
|
|
||||||
alias_method :old_copy_metadata, :copy_metadata
|
|
||||||
def copy_metadata(path)
|
|
||||||
st = lstat
|
|
||||||
unless st.symlink?
|
|
||||||
File.utime st.atime, st.mtime, path
|
|
||||||
end
|
|
||||||
begin
|
|
||||||
if st.symlink?
|
|
||||||
begin
|
|
||||||
File.lchown st.uid, st.gid, path
|
|
||||||
rescue NotImplementedError
|
|
||||||
end
|
|
||||||
else
|
|
||||||
File.chown st.uid, st.gid, path
|
|
||||||
end
|
|
||||||
rescue Errno::EPERM
|
|
||||||
# clear setuid/setgid
|
|
||||||
if st.symlink?
|
|
||||||
begin
|
|
||||||
File.lchmod st.mode & 01777, path
|
|
||||||
rescue NotImplementedError
|
|
||||||
end
|
|
||||||
else
|
|
||||||
File.chmod st.mode & 01777, path
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if st.symlink?
|
|
||||||
begin
|
|
||||||
File.lchmod st.mode, path
|
|
||||||
rescue NotImplementedError
|
|
||||||
end
|
|
||||||
else
|
|
||||||
File.chmod st.mode, path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Run `scons` using a Homebrew-installed version rather than whatever is in the `PATH`.
|
# Run `scons` using a Homebrew-installed version rather than whatever is in the `PATH`.
|
||||||
def scons(*args)
|
def scons(*args)
|
||||||
system Formulary.factory("scons").opt_bin/"scons", *args
|
system Formulary.factory("scons").opt_bin/"scons", *args
|
||||||
@ -187,14 +139,3 @@ module FileUtils
|
|||||||
ENV.update(removed)
|
ENV.update(removed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Shim File.write for Ruby 1.8.7, where it's absent
|
|
||||||
unless File.respond_to?(:write)
|
|
||||||
class File
|
|
||||||
def self.write(filename, contents)
|
|
||||||
File.open(filename, "w") do |file|
|
|
||||||
file.write contents
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user