homebrew-core/Formula/unrar.rb
2018-04-01 08:17:13 +10:00

43 lines
1.5 KiB
Ruby

class Unrar < Formula
desc "Extract, view, and test RAR archives"
homepage "https://www.rarlab.com/"
url "https://www.rarlab.com/rar/unrarsrc-5.6.2.tar.gz"
sha256 "ce048094764b2377dd60802359c74f03528b6d7defd808cd584443c5fd2de948"
bottle do
cellar :any
sha256 "238eb1f1dae26d80f32625de1ce4696e14d00020a323714ef5fb4734d5c27386" => :high_sierra
sha256 "ed92a4f9d02d7e009ea65edd241833b9c7a6f8a83c049780f75e3c0c92ad0224" => :sierra
sha256 "703145f0ada882f2ec3fc832074d00bf13d886e370b40c3a02cb9b68605e5835" => :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