110 lines
4.0 KiB
Ruby
110 lines
4.0 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 3
|
||
|
||
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_ventura: "fda2a2d7d7e478e581e24c51a9ddfb0e5640c6af5c4ee18a0cfb47a40dd35883"
|
||
sha256 cellar: :any, arm64_monterey: "e557c8be8f4c335fac3cfa8f37d984bbd63c5716d98145c0d83ca0423fda4525"
|
||
sha256 cellar: :any, arm64_big_sur: "2cdab667383b932b13aaaf8e9516b104f09afef4b45b1ca16888f9da54612afe"
|
||
sha256 cellar: :any, ventura: "5b8c7e6fb876ba038cc8157635d1cf8b613c36b64042cc06e41975e439ef61f8"
|
||
sha256 cellar: :any, monterey: "9e7b9b9bd1292324bd8fb4e28cd0e4010c29972e508626a0110adbe3908ac8ae"
|
||
sha256 cellar: :any, big_sur: "ba154d92aa07f094933650506c59094cce717db404fe394afc35b8be6e852d73"
|
||
sha256 cellar: :any, catalina: "c02b3f2c2b8a1f874d9a6d3269e4c35ff37fd2cc2c7aefc76c89e68015d20ba5"
|
||
sha256 cellar: :any_skip_relocation, x86_64_linux: "a19506f2dc9e63a3ad1f6e0493c1304b912c1d7e18374ea4662de91abfaaf33d"
|
||
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
|