class Unrar < Formula desc "Extract, view, and test RAR archives" homepage "https://www.rarlab.com/" url "https://www.rarlab.com/rar/unrarsrc-5.6.4.tar.gz" sha256 "9335d2201870f2034007c04be80e00f1dc23932cb88b329d55c76134e6ba49fe" bottle do cellar :any sha256 "aaf3a082bba8c22035c832807d3da878979687298ac343df3893e84e779f9d7e" => :high_sierra sha256 "163e5cd7f6acb4ffa0e11e7bb4faa64b98b469e7b1c73a2c66913d573ac569bc" => :sierra sha256 "b1fc0858b0942b9062816372e51afb694ea7aeef8d59645bdb5d94ed4b99251a" => :el_capitan 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