108 lines
3.8 KiB
Ruby
108 lines
3.8 KiB
Ruby
class Yaz < Formula
|
||
desc "Toolkit for Z39.50/SRW/SRU clients/servers"
|
||
homepage "https://www.indexdata.com/resources/software/yaz/"
|
||
license "BSD-3-Clause"
|
||
revision 2
|
||
|
||
stable do
|
||
url "https://ftp.indexdata.com/pub/yaz/yaz-5.32.0.tar.gz"
|
||
sha256 "04d08c799d5ee56a2670e6ac0b42398d2ff956bd9bf144bfe9c4c30e557140e0"
|
||
end
|
||
|
||
livecheck do
|
||
url :homepage
|
||
regex(/href=.*?yaz[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
||
end
|
||
|
||
bottle do
|
||
sha256 cellar: :any, arm64_monterey: "f157fba7d75b021eac87c073bd0aee42ee9838a4ebcf1a216ebba8055f0c1489"
|
||
sha256 cellar: :any, arm64_big_sur: "6c534ea2dafa4fbe23f9c9ce458fb705be1ee5cc1dfe9416b16e487e805d39d9"
|
||
sha256 cellar: :any, monterey: "eb67c9eb73efc925f3456b6de76832c6075951f30aa633eedb14f290bc8d5abe"
|
||
sha256 cellar: :any, big_sur: "aab863f69a8ab8be039cd1929d7d86780c6c4260844ac24a5f1891d002d70cc2"
|
||
sha256 cellar: :any, catalina: "4b42397bd3ffed6d39bbfda92b6e1778c2947292c9f475c8e87ac64452448188"
|
||
sha256 cellar: :any_skip_relocation, x86_64_linux: "dc637af22728871a5bbd58d9d91acc89b51d7633876eabe9ba2ce91180abea78"
|
||
end
|
||
|
||
head do
|
||
url "https://github.com/indexdata/yaz.git", branch: "master"
|
||
|
||
depends_on "autoconf" => :build
|
||
depends_on "automake" => :build
|
||
depends_on "docbook-xsl" => :build
|
||
depends_on "libtool" => :build
|
||
|
||
uses_from_macos "bison" => :build
|
||
uses_from_macos "tcl-tk" => :build
|
||
end
|
||
|
||
depends_on "pkg-config" => :build
|
||
depends_on "gnutls"
|
||
depends_on "icu4c"
|
||
|
||
uses_from_macos "libxml2"
|
||
uses_from_macos "libxslt"
|
||
|
||
def install
|
||
if build.head?
|
||
ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
|
||
system "./buildconf.sh"
|
||
end
|
||
system "./configure", *std_configure_args,
|
||
"--with-gnutls",
|
||
"--with-xml2",
|
||
"--with-xslt"
|
||
system "make", "install"
|
||
|
||
# Replace dependencies' cellar paths, which can break build for dependents
|
||
# (like `metaproxy` and `zebra`) after a dependency is version/revision bumped
|
||
inreplace bin/"yaz-config" do |s|
|
||
s.gsub! Formula["gnutls"].prefix.realpath, Formula["gnutls"].opt_prefix
|
||
s.gsub! Formula["icu4c"].prefix.realpath, Formula["icu4c"].opt_prefix
|
||
end
|
||
unless OS.mac?
|
||
inreplace [bin/"yaz-config", lib/"pkgconfig/yaz.pc"] do |s|
|
||
s.gsub! Formula["libxml2"].prefix.realpath, Formula["libxml2"].opt_prefix
|
||
s.gsub! Formula["libxslt"].prefix.realpath, Formula["libxslt"].opt_prefix
|
||
end
|
||
end
|
||
end
|
||
|
||
test do
|
||
# This test converts between MARC8, an obscure mostly-obsolete library
|
||
# text encoding supported by yaz-iconv, and UTF8.
|
||
marc8file = testpath/"marc8.txt"
|
||
marc8file.write "$1!0-!L,i$3i$si$Ki$Ai$O!+=(B"
|
||
result = shell_output("#{bin}/yaz-iconv -f marc8 -t utf8 #{marc8file}")
|
||
result.force_encoding(Encoding::UTF_8) if result.respond_to?(:force_encoding)
|
||
assert_equal "世界こんにちは!", result
|
||
|
||
# Test ICU support by running yaz-icu with the example icu_chain
|
||
# from its man page.
|
||
configfile = testpath/"icu-chain.xml"
|
||
configfile.write <<~EOS
|
||
<?xml version="1.0" encoding="UTF-8"?>
|
||
<icu_chain locale="en">
|
||
<transform rule="[:Control:] Any-Remove"/>
|
||
<tokenize rule="w"/>
|
||
<transform rule="[[:WhiteSpace:][:Punctuation:]] Remove"/>
|
||
<transliterate rule="xy > z;"/>
|
||
<display/>
|
||
<casemap rule="l"/>
|
||
</icu_chain>
|
||
EOS
|
||
|
||
inputfile = testpath/"icu-test.txt"
|
||
inputfile.write "yaz-ICU xy!"
|
||
|
||
expectedresult = <<~EOS
|
||
1 1 'yaz' 'yaz'
|
||
2 1 '' ''
|
||
3 1 'icuz' 'ICUz'
|
||
4 1 '' ''
|
||
EOS
|
||
|
||
result = shell_output("#{bin}/yaz-icu -c #{configfile} #{inputfile}")
|
||
assert_equal expectedresult, result
|
||
end
|
||
end
|