-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
/
yaz.rb
110 lines (96 loc) · 4.31 KB
/
yaz.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
class Yaz < Formula
desc "Toolkit for Z39.50/SRW/SRU clients/servers"
homepage "https://www.indexdata.com/resources/software/yaz/"
# TODO: Switch back to homepage if upstream confirms reupload or on next release
# Ref: https://github.com/indexdata/yaz/issues/120
url "http://deb.debian.org/debian/pool/main/y/yaz/yaz_5.34.1.orig.tar.gz"
mirror "https://ftp.indexdata.com/pub/yaz/yaz-5.34.1.tar.gz"
sha256 "c7fd8e0222b3b0d1115ad8e7a2ee67be7a2807624d61d5b71854bf5e167ab7a9"
license "BSD-3-Clause"
# The latest version text is currently omitted from the homepage for this
# software, so we have to check the related directory listing page.
livecheck do
url "https://ftp.indexdata.com/pub/yaz/"
regex(/href=.*?yaz[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_sonoma: "dc45f16c09632a6e73e49ace9bd8d0b4e086a5a9c5503cfe7c066f18a59d8f87"
sha256 cellar: :any, arm64_ventura: "de294f63ae537046de8e38aab6a66964d142a72bbd5039a1e0510d06444b3d56"
sha256 cellar: :any, arm64_monterey: "be73925a730bbc3956497ba501596848f6f80292f7ef23cb72490537fd141948"
sha256 cellar: :any, sonoma: "7bca2535a733fa5d4d59b565d1844ba549275e7e3deb4ea118a35b8aace8d865"
sha256 cellar: :any, ventura: "9df7ada09b950e224f87f15387725a63754d77ea2b5f5f707af654f26a336a47"
sha256 cellar: :any, monterey: "a6b19cb6e6905f85aa590d49c4b10aaa28a8364f60aacd76c85d210fa9e760a4"
sha256 cellar: :any_skip_relocation, x86_64_linux: "019454b127ed23be0ddac5cda1f86e1e011267a6c68ced037c9eeb3843324569"
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"
depends_on "readline" # Possible opportunistic linkage. TODO: Check if this can be removed.
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