InstallRenamed: don't overwrite etc files; rename.
If an etc file exists on installation instead of overwriting it (or requiring all the manual checks in formula) simply copy it with the extension `.default` appended.
This commit is contained in:
parent
05a2261877
commit
caa2f87728
@ -50,6 +50,8 @@ class Pathname
|
||||
# and also broken symlinks are not the end of the world
|
||||
raise "#{src} does not exist" unless File.symlink? src or File.exist? src
|
||||
|
||||
dst = yield(src, dst) if block_given?
|
||||
|
||||
mkpath
|
||||
if File.symlink? src
|
||||
# we use the BSD mv command because FileUtils copies the target and
|
||||
|
||||
@ -9,7 +9,7 @@ require 'build_environment'
|
||||
require 'build_options'
|
||||
require 'formulary'
|
||||
require 'software_spec'
|
||||
|
||||
require 'install_renamed'
|
||||
|
||||
class Formula
|
||||
include FileUtils
|
||||
@ -165,7 +165,13 @@ class Formula
|
||||
def kext_prefix; prefix+'Library/Extensions' end
|
||||
|
||||
# configuration needs to be preserved past upgrades
|
||||
def etc; HOMEBREW_GIT_ETC ? prefix+'etc' : HOMEBREW_PREFIX+'etc' end
|
||||
def etc
|
||||
etc = HOMEBREW_PREFIX+'etc'
|
||||
etc = prefix+etc if HOMEBREW_GIT_ETC
|
||||
etc.extend(InstallRenamed)
|
||||
etc
|
||||
end
|
||||
|
||||
# generally we don't want var stuff inside the keg
|
||||
def var; HOMEBREW_PREFIX+'var' end
|
||||
|
||||
|
||||
17
Library/Homebrew/install_renamed.rb
Normal file
17
Library/Homebrew/install_renamed.rb
Normal file
@ -0,0 +1,17 @@
|
||||
module InstallRenamed
|
||||
def install_p src, new_basename = nil
|
||||
super do |src, dst|
|
||||
dst += "/#{File.basename(src)}" if File.directory? dst
|
||||
append_default_if_different(src, dst)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def append_default_if_different src, dst
|
||||
if File.file? dst and !FileUtils.identical?(src, dst) and !HOMEBREW_GIT_ETC
|
||||
dst += ".default"
|
||||
end
|
||||
dst
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user