class Unrar < Formula desc "Extract, view, and test RAR archives" homepage "https://www.rarlab.com/" url "https://www.rarlab.com/rar/unrarsrc-5.7.1.tar.gz" sha256 "d208abcceecfee0084bb8a93e9b756319d906a3ac6380ee5d10285fb0ffc4d65" bottle do cellar :any sha256 "8103113d19288926fcd7152557d3d7a29547526c9247a9bf85efd8a40efe029d" => :mojave sha256 "e9f0ab34996f57f7a9cad50056d9e3fe09d797c3391380fe63242b599ef455c0" => :high_sierra sha256 "09f40ab8c0701c01417a9a15d3de0459a3ab713b8ad1fdb7a8b1cc1b5a8cf499" => :sierra end def install # upstream doesn't particularly care about their unix targets, # so we do the dirty work of renaming their shared objects to # dylibs for them. inreplace "makefile", "libunrar.so", "libunrar.dylib" system "make" # Explicitly clean up for the library build to avoid an issue with an # apparent implicit clean which confuses the dependencies. system "make", "clean" system "make", "lib" bin.install "unrar" lib.install "libunrar.dylib" end test do contentpath = "directory/file.txt" rarpath = testpath/"archive.rar" data = "UmFyIRoHAM+QcwAADQAAAAAAAACaCHQggDIACQAAAAkAAAADtPej1LZwZE" \ "QUMBIApIEAAGRpcmVjdG9yeVxmaWxlLnR4dEhvbWVicmV3CsQ9ewBABwA=" rarpath.write data.unpack("m").first assert_equal contentpath, `#{bin}/unrar lb #{rarpath}`.strip assert_equal 0, $CHILD_STATUS.exitstatus system "#{bin}/unrar", "x", rarpath, testpath assert_equal "Homebrew\n", (testpath/contentpath).read end end