<commit_before>require 'formula'

class PkgCurlDownloadStrategy <CurlDownloadStrategy
  def stage
    safe_system '/usr/sbin/pkgutil', '--expand', @tarball_path, File.basename(@url)
    chdir
  end
end

# Remember to update the formula for Cabal when updating this formula
class Ghc <Formula
  homepage 'http://haskell.org/ghc/'
  version '6.12.3'
  url "http://darcs.haskell.org/download/dist/#{version}/GHC-#{version}-i386.pkg"
  md5 '58399e3af68f50a23a847bdfe3de5aca'

  # Avoid stripping the Haskell binaries AND libraries; http://hackage.haskell.org/trac/ghc/ticket/2458
  skip_clean ['bin', 'lib']

  def download_strategy
    # Extract files from .pkg while caching the .pkg
    PkgCurlDownloadStrategy
  end

  def replace_all foo, bar
    # Find all text files containing foo and replace it with bar
    files = `/usr/bin/grep -lsIR #{foo} .`.split
    inreplace files, foo, bar
  end

  def install
    short_version = version.split('.').first(2).join('')

    # Extract files from .pax.gz
    system '/bin/pax -f ghc.pkg/Payload -p p -rz'
    cd "GHC.framework/Versions/#{short_version}/usr"

    # Fix paths
    replace_all "/Library/Frameworks/GHC.framework/Versions/#{short_version}/usr/lib/ghc-#{version}", "#{lib}/ghc"
    replace_all "/Library/Frameworks/GHC.framework/Versions/#{short_version}/usr", prefix
    inreplace "lib/ghc-#{version}/ghc-asm", "#!/opt/local/bin/perl", "#!/usr/bin/env perl"
    mv "lib/ghc-#{version}", 'lib/ghc'

    prefix.install ['bin', 'lib', 'share']

    # Regenerate GHC package cache
    rm "#{lib}/ghc/package.conf.d/package.cache"
    system "#{bin}/ghc-pkg", 'recache', '--package-conf', "#{lib}/ghc/package.conf.d"
  end
end<commit_msg>ghc - remove custom .pkg support<commit_after>require 'formula'

class Ghc <Formula
  homepage 'http://haskell.org/ghc/'
  version '6.12.3'
  url "http://darcs.haskell.org/download/dist/#{version}/GHC-#{version}-i386.pkg"
  md5 '58399e3af68f50a23a847bdfe3de5aca'

  # Avoid stripping the Haskell binaries & libraries.
  # See: http://hackage.haskell.org/trac/ghc/ticket/2458
  skip_clean ['bin', 'lib']

  def replace_all foo, bar
    # Find all text files containing foo and replace it with bar
    files = `/usr/bin/grep -lsIR #{foo} .`.split
    inreplace files, foo, bar
  end

  def install
    short_version = version.split('.').first(2).join('')

    # Extract files from .pax.gz
    system '/bin/pax -f ghc.pkg/Payload -p p -rz'
    cd "GHC.framework/Versions/#{short_version}/usr"

    # Fix paths
    replace_all "/Library/Frameworks/GHC.framework/Versions/#{short_version}/usr/lib/ghc-#{version}", "#{lib}/ghc"
    replace_all "/Library/Frameworks/GHC.framework/Versions/#{short_version}/usr", prefix

    prefix.install ['bin', 'share']

    # Remove version from lib folder
    lib.install "lib/ghc-#{version}" => 'ghc'

    # Fix ghc-asm Perl reference
    inreplace "#{lib}/ghc/ghc-asm", "#!/opt/local/bin/perl", "#!/usr/bin/env perl"

    # Regenerate GHC package cache
    rm "#{lib}/ghc/package.conf.d/package.cache"
    system "#{bin}/ghc-pkg", 'recache', '--package-conf', "#{lib}/ghc/package.conf.d"
  end
end
{'fraction_non_alphanumeric': 0.15924383210509452, 'fraction_numerical': 0.019224607497596923, 'mean_word_length': 3.4985590778097984, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3895361', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1114, 'n_words': 245}