jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / z / zookeeper.rb
blob3e77b715049773372e2bbe686e47b154bd0beb72
1 class Zookeeper < Formula
2   desc "Centralized server for distributed coordination of services"
3   homepage "https://zookeeper.apache.org/"
4   url "https://www.apache.org/dyn/closer.lua?path=zookeeper/zookeeper-3.9.3/apache-zookeeper-3.9.3.tar.gz"
5   mirror "https://archive.apache.org/dist/zookeeper/zookeeper-3.9.3/apache-zookeeper-3.9.3.tar.gz"
6   sha256 "8bf0b9f872b3c0a6e64f8bc55ffb44cbff6e2712f6467ee5164ca6847466b31b"
7   license "Apache-2.0"
8   head "https://gitbox.apache.org/repos/asf/zookeeper.git", branch: "master"
10   bottle do
11     sha256 cellar: :any,                 arm64_sequoia: "55cdbe85faf89339c7388d17582a1c611acf856dbc61b09386f53a4f94e2250d"
12     sha256 cellar: :any,                 arm64_sonoma:  "877ea34a0512cef5350a11523bffa1ac380306a1bcdfc444a4b09417e56e4b96"
13     sha256 cellar: :any,                 arm64_ventura: "b32a242b6462efee1aeba8315f944328b89b0f027d345c4b19dbb42c7d8e3210"
14     sha256 cellar: :any,                 sonoma:        "43493f6555c4c8028c1f46957092b5b9ee99a1a2beae025d23571bff79a6cf5a"
15     sha256 cellar: :any,                 ventura:       "aca1f280391c77002a8822e6fc1c8434c5680144d7f536aeae5ff17efd52ff00"
16     sha256 cellar: :any_skip_relocation, x86_64_linux:  "44c4a13aefe7898e15aa63cb9dd001c673ad8e520128e6816599a6b50f97acb8"
17   end
19   depends_on "autoconf" => :build
20   depends_on "automake" => :build
21   depends_on "cppunit" => :build
22   depends_on "libtool" => :build
23   depends_on "maven" => :build
24   depends_on "pkgconf" => :build
26   depends_on "openjdk"
27   depends_on "openssl@3"
29   resource "default_logback_xml" do
30     url "https://raw.githubusercontent.com/apache/zookeeper/release-3.9.3/conf/logback.xml"
31     sha256 "2fae7f51e4f92e8e3536e5f9ac193cb0f4237d194b982bb00b5c8644389c901f"
32   end
34   def default_zk_env
35     <<~EOS
36       [ -z "$ZOOCFGDIR" ] && export ZOOCFGDIR="#{etc}/zookeeper"
37     EOS
38   end
40   def install
41     if build.stable? && version != resource("default_logback_xml").version
42       odie "default_logback_xml resource needs to be updated"
43     end
45     system "mvn", "install", "-Pfull-build", "-DskipTests"
47     system "tar", "-xf", "zookeeper-assembly/target/apache-zookeeper-#{version}-bin.tar.gz"
48     binpfx = "apache-zookeeper-#{version}-bin"
49     libexec.install binpfx+"/bin", binpfx+"/lib", "zookeeper-contrib"
50     rm(Dir["build-bin/bin/*.cmd"])
52     system "tar", "-xf", "zookeeper-assembly/target/apache-zookeeper-#{version}-lib.tar.gz"
53     libpfx = "apache-zookeeper-#{version}-lib"
54     include.install Dir[libpfx+"/usr/include/*"]
55     lib.install Dir[libpfx+"/usr/lib/*"]
57     bin.mkpath
58     (etc/"zookeeper").mkpath
59     (var/"log/zookeeper").mkpath
60     (var/"run/zookeeper/data").mkpath
62     Pathname.glob("#{libexec}/bin/*.sh") do |path|
63       next if path == libexec+"bin/zkEnv.sh"
65       script_name = path.basename
66       bin_name    = path.basename ".sh"
67       (bin+bin_name).write <<~EOS
68         #!/bin/bash
69         export JAVA_HOME="${JAVA_HOME:-#{Formula["openjdk"].opt_prefix}}"
70         . "#{etc}/zookeeper/defaults"
71         exec "#{libexec}/bin/#{script_name}" "$@"
72       EOS
73     end
75     cp "conf/zoo_sample.cfg", "conf/zoo.cfg"
76     inreplace "conf/zoo.cfg",
77               /^dataDir=.*/, "dataDir=#{var}/run/zookeeper/data"
78     (etc/"zookeeper").install "conf/zoo.cfg"
80     (pkgshare/"examples").install "conf/logback.xml", "conf/zoo_sample.cfg"
81   end
83   def post_install
84     tmpdir = Pathname.new(Dir.mktmpdir)
85     tmpdir.install resource("default_logback_xml")
87     defaults = etc/"zookeeper/defaults"
88     defaults.write(default_zk_env) unless defaults.exist?
90     logback_xml = etc/"zookeeper/logback.xml"
91     logback_xml.write(tmpdir/"default_logback_xml") unless logback_xml.exist?
92   end
94   service do
95     run [opt_bin/"zkServer", "start-foreground"]
96     environment_variables SERVER_JVMFLAGS: "-Dapple.awt.UIElement=true"
97     keep_alive successful_exit: false
98     working_dir var
99   end
101   test do
102     output = shell_output("#{bin}/zkServer -h 2>&1")
103     assert_match "Using config: #{etc}/zookeeper/zoo.cfg", output
104   end