|
| 1 | +class Zlib < Formula |
| 2 | + desc "General-purpose lossless data-compression library" |
| 3 | + homepage "https://zlib.net/" |
| 4 | + url "https://zlib.net/zlib-1.3.1.tar.gz" |
| 5 | + mirror "https://downloads.sourceforge.net/project/libpng/zlib/1.3.1/zlib-1.3.1.tar.gz" |
| 6 | + mirror "http://fresh-center.net/linux/misc/zlib-1.3.1.tar.gz" |
| 7 | + mirror "http://fresh-center.net/linux/misc/legacy/zlib-1.3.1.tar.gz" |
| 8 | + sha256 "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23" |
| 9 | + license "Zlib" |
| 10 | + head "https://github.com/madler/zlib.git", branch: "develop" |
| 11 | + |
| 12 | + livecheck do |
| 13 | + url :homepage |
| 14 | + regex(/href=.*?zlib[._-]v?(\d+(?:\.\d+)+)\.t/i) |
| 15 | + end |
| 16 | + |
| 17 | + bottle do |
| 18 | + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/zlib-1.3.1" |
| 19 | + sha256 cellar: :any_skip_relocation, aarch64_linux: "343b667a2d94c71bcc0d5aaa610c685cdefdb0be7d874f6d3cfbd664f9d35b46" |
| 20 | + end |
| 21 | + |
| 22 | + keg_only :provided_by_macos |
| 23 | + |
| 24 | + # https://zlib.net/zlib_how.html |
| 25 | + resource "test_artifact" do |
| 26 | + url "https://zlib.net/zpipe.c" |
| 27 | + version "20051211" |
| 28 | + sha256 "68140a82582ede938159630bca0fb13a93b4bf1cb2e85b08943c26242cf8f3a6" |
| 29 | + end |
| 30 | + |
| 31 | + def install |
| 32 | + system "./configure", "--prefix=#{prefix}" |
| 33 | + system "make", "install" |
| 34 | + |
| 35 | + # Avoid rebuilds of dependents that hardcode this path. |
| 36 | + inreplace lib/"pkgconfig/zlib.pc", prefix, opt_prefix |
| 37 | + end |
| 38 | + |
| 39 | + test do |
| 40 | + testpath.install resource("test_artifact") |
| 41 | + system ENV.cc, "zpipe.c", "-I#{include}", "-L#{lib}", "-lz", "-o", "zpipe" |
| 42 | + |
| 43 | + text = "Hello, Homebrew!" |
| 44 | + compressed = pipe_output("./zpipe", text) |
| 45 | + assert_equal text, pipe_output("./zpipe -d", compressed) |
| 46 | + end |
| 47 | +end |
0 commit comments