class Libarchive < Formula desc "Multi-format archive and compression library" homepage "https://www.libarchive.org" url "https://www.libarchive.org/downloads/libarchive-3.7.7.tar.xz" sha256 "879acd83c3399c7caaee73fe5f7418e06087ab2aaf40af3e99b9e29beb29faee" license "BSD-2-Clause" livecheck do url :homepage regex(/href=.*?libarchive[._-]v?(\d+(?:\.\d+)+)\.t/i) end keg_only :provided_by_macos depends_on "libb2" depends_on "lz4" depends_on "xz" depends_on "zstd" uses_from_macos "bzip2" uses_from_macos "expat" uses_from_macos "zlib" def install system "./configure", *std_configure_args, "--without-lzo2", # Use lzop binary instead of lzo2 due to GPL "--without-nettle", # xar hashing option but GPLv3 "--without-xml2", # xar hashing option but tricky dependencies "--without-openssl", # mtree hashing now possible without OpenSSL "--with-expat" # best xar hashing option system "make", "install" # Avoid hardcoding Cellar paths in dependents. inreplace lib/"pkgconfig/libarchive.pc", prefix.to_s, opt_prefix.to_s return unless OS.mac? # fixes https://github.com/libarchive/libarchive/issues/1819 inreplace lib/"pkgconfig/libarchive.pc" do |s| s.gsub! "Libs.private: ", "Libs.private: -liconv " s.gsub! "Requires.private: iconv", "" end # Just as apple does it. ln_s bin/"bsdtar", bin/"tar" ln_s bin/"bsdcpio", bin/"cpio" ln_s man1/"bsdtar.1", man1/"tar.1" ln_s man1/"bsdcpio.1", man1/"cpio.1" end test do (testpath/"test").write("test") system bin/"bsdtar", "-czvf", "test.tar.gz", "test" assert_match "test", shell_output("#{bin}/bsdtar -xOzf test.tar.gz") end end