Last active
August 29, 2015 14:00
-
-
Save mimosa/11170645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class Libxslt < Formula | |
homepage 'http://xmlsoft.org/XSLT/' | |
url 'ftp://xmlsoft.org/libxml2/libxslt-1.1.28.tar.gz' | |
mirror 'http://xmlsoft.org/sources/libxslt-1.1.28.tar.gz' | |
sha1 '4df177de629b2653db322bfb891afa3c0d1fa221' | |
keg_only :provided_by_osx | |
depends_on 'https://gist.github.com/steakknife/8968844/raw/libxml2.rb' | |
def patches_repo | |
'https://raw2.github.com/sparklemotion/nokogiri/master/ports/patches/libxslt/' | |
end | |
def patches | |
%w[ | |
0001-Adding-doc-update-related-to-1.1.28.patch | |
0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch | |
0003-Initialize-pseudo-random-number-generator-with-curre.patch | |
0004-EXSLT-function-str-replace-is-broken-as-is.patch | |
0006-Fix-str-padding-to-work-with-UTF-8-strings.patch | |
0007-Separate-function-for-predicate-matching-in-patterns.patch | |
0008-Fix-direct-pattern-matching.patch | |
0009-Fix-certain-patterns-with-predicates.patch | |
0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch | |
0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch | |
0014-Fix-for-bug-436589.patch | |
].map { |x| patches_repo + x } | |
end | |
def libxml2_prefix | |
Formula.factory('libxml2').prefix | |
end | |
def install | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}", | |
"--with-libxml-prefix=#{libxml2_prefix}" | |
system "make" | |
system "make install" | |
end | |
def nokogiri_options | |
'--use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"' | |
end | |
def caveats; <<-EOS.undent | |
To allow the nokogiri gem to link against this libxslt run: | |
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- #{nokogiri_options} | |
For bundler to be permanently configured: | |
bundle config build.nokogiri #{nokogiri_options} | |
For bundler to be configured for the current local project directory only: | |
bundle config --local build.nokogiri #{nokogiri_options} | |
# 1. add to the top of the Gemfile to workaround the nokogiri build bug | |
require './.nokogiri-brew-osx' | |
# 2. add this to .nokogiri-brew-osx.rb | |
#### better nokogiri support | |
if %x(uname).chop == 'Darwin' | |
nokogiri_libxml2 ||= system '"$(brew --prefix libxml2)/bin/xml2-config" --version 2>/dev/null | grep -q 2.8.0' | |
nokogiri_libxslt ||= system 'grep -q "consistent use of xslt processor" "$(brew --prefix libxslt)/NEWS"' | |
nokogiri_libiconv ||= system 'brew info libiconv | grep -qv Not' | |
unless nokogiri_libxml2 && nokogiri_libxslt && nokogiri_libiconv && !ENV.include?('NOKOGIRI_NOTICE_SHOWN') | |
ENV['NOKOGIRI_NOTICE_SHOWN'] = '1' | |
$stderr.puts 'Nokogiri will install faster by reinstalling with :' | |
$stderr.puts | |
$stderr.puts ' brew install https://gist.github.com/steakknife/8968844/raw/libxml2.rb --without-python' unless nokogiri_libxml2 | |
$stderr.puts ' brew install https://gist.github.com/steakknife/8969334/raw/libxslt.rb' unless $nokogiri_libxslt | |
$stderr.puts ' brew install libiconv' unless nokogiri_libiconv | |
$stderr.puts | |
else | |
$stderr.puts 'Configuring Nokogiri for brew-ed dependencies' | |
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = '1' | |
nokogiri_options = "#{nokogiri_options}" | |
system "mkdir -p .bundle; grep -q 'BUNDLE_BUILD__NOKOGIRI' .bundle/config 2>/dev/null || echo 'BUNDLE_BUILD__NOKOGIRI: #{nokogiri_options}' >> .bundle/config" | |
end | |
end | |
#### better nokogiri support | |
EOS | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment