class Unrar < Formula desc "Extract, view, and test RAR archives" homepage "http://www.rarlab.com" url "http://www.rarlab.com/rar/unrarsrc-5.5.6.tar.gz" sha256 "68a9d8f40c709b883bb15b21a9811907e56a07411d90aeaa992622ed9cf128c0" bottle do cellar :any sha256 "337a556156e559105fcba2738900cbb6ec05a2fadc80e8e23386eb2837887137" => :sierra sha256 "7a79c8ac82a02bdf922aad7733546f038549fbc51f6e3fc22cd6222ca2783784" => :el_capitan sha256 "10ce3dd75d23b2e33ea1b3055627b16ecbfb5529b56f0701696a13ac80d1b9c8" => :yosemite 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