<commit_before># Use patchelf to modify the dynamic linker and RPATH of ELF executables

require "formula"

module Homebrew
  def patchelf_formula f
    unless f.installed?
      return ofail "Formula not installed or up-to-date: #{f.full_name}"
    end

    ohai "Fixing up #{f.full_name}..."
    keg = Keg.new(f.prefix)
    keg.lock do
      keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX,
        Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR
    end
  end

  def patchelf
    raise FormulaUnspecifiedError if ARGV.named.empty?

    unless Formula["patchelf"].installed?
      return ofail "patchelf is not installed. Run `brew install patchelf`"
    end

    ARGV.resolved_formulae.each do |f|
      patchelf_formula f
    end
  end
end<commit_msg>cmd/patchelf: Install patchelf if it's not install<commit_after># Use patchelf to modify the dynamic linker and RPATH of ELF executables

require "formula"

module Homebrew
  def self.ensure_patchelf_installed!
    return if Formula["patchelf"].installed?
    require "cmd/install"
    oh1 "Installing patchelf"
    Homebrew.perform_preinstall_checks
    Homebrew.install_formula(Formula["patchelf"])
  end

  def patchelf_formula f
    unless f.installed?
      return ofail "Formula not installed or up-to-date: #{f.full_name}"
    end

    ohai "Fixing up #{f.full_name}..."
    keg = Keg.new(f.prefix)
    keg.lock do
      keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX,
        Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR
    end
  end

  def patchelf
    raise FormulaUnspecifiedError if ARGV.named.empty?

    ensure_patchelf_installed!

    ARGV.resolved_formulae.each do |f|
      patchelf_formula f
    end
  end
end
{'fraction_non_alphanumeric': 0.07589025102159953, 'fraction_numerical': 0.0005837711617046118, 'mean_word_length': 3.4061696658097684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7566391', 'n_tokens_mistral': 629, 'n_tokens_neox': 588, 'n_words': 152}