Module: InstallRenamed Private
- Defined in:
- install_renamed.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper module for installing default files.
Class Method Summary collapse
- .cp_path_sub(path, pattern, replacement) ⇒ void private
- .destination_for(src, dst) ⇒ Pathname private
Instance Method Summary collapse
- #+(other) ⇒ Pathname private
- #/(other) ⇒ Pathname private
- #cp_path_sub(pattern, replacement, &_block) ⇒ void private
- #install_p(src, new_basename, &_block) ⇒ void private
Class Method Details
.cp_path_sub(path, pattern, replacement) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
26 27 28 29 30 |
# File 'install_renamed.rb', line 26 def self.cp_path_sub(path, pattern, replacement) Utils::Path.cp_path_sub(path, pattern, replacement) do |src, dst| destination_for(src, dst) end end |
.destination_for(src, dst) ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'install_renamed.rb', line 53 def self.destination_for(src, dst) return dst if !dst.file? || FileUtils.identical?(src, dst) # Bottle installs restore config from `<keg>/.bottle/etc` through this # helper. If the live config still matches an older bottled default, replace # it so untouched configs advance on upgrade. Modified configs still receive # the new default as `*.default`. # Resolve via realpath so the ascend walks the Cellar path, not `opt_prefix`. # For symlink sources, resolve only the parent directory so broken symlinks # are still handled without requiring the target to exist. src = if src.symlink? src.dirname.realpath/src.basename else src.realpath end src.ascend do |path| next if path.basename.to_s != ".bottle" || path.parent.parent.parent != HOMEBREW_CELLAR path.parent.parent.subdirs.each do |prefix| next if prefix == path.parent default_file = prefix/".bottle"/src.relative_path_from(path) return dst if default_file.file? && FileUtils.identical?(dst, default_file) end break end Pathname.new("#{dst}.default") end |
Instance Method Details
#+(other) ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
43 44 45 |
# File 'install_renamed.rb', line 43 def +(other) super.extend(InstallRenamed) end |
#/(other) ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
48 49 50 |
# File 'install_renamed.rb', line 48 def /(other) super.extend(InstallRenamed) end |
#cp_path_sub(pattern, replacement, &_block) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
36 37 38 39 40 |
# File 'install_renamed.rb', line 36 def cp_path_sub(pattern, replacement, &_block) super do |src, dst| InstallRenamed.destination_for(src, dst) end end |
#install_p(src, new_basename, &_block) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
12 13 14 15 16 17 18 19 20 21 |
# File 'install_renamed.rb', line 12 def install_p(src, new_basename, &_block) super do |src, dst| if src.directory? dst.install(src.children) next else InstallRenamed.destination_for(src, dst) end end end |