diff --git a/Formula/simg2img.rb b/Formula/simg2img.rb new file mode 100644 index 0000000000..5a7cc2ae17 --- /dev/null +++ b/Formula/simg2img.rb @@ -0,0 +1,24 @@ +class Simg2img < Formula + desc "Tool to convert Android sparse images to raw images and back" + homepage "https://github.com/anestisb/android-simg2img" + url "https://github.com/anestisb/android-simg2img/archive/1.1.1.tar.gz" + sha256 "d096ca7e02b3ad5b87cbb6467d3766720355f32aa5ae9b9264d7ca7c486b0738" + head "https://github.com/anestisb/android-simg2img.git" + + def install + system "make", "PREFIX=#{prefix}", "install" + end + + test do + system "dd", "if=/dev/zero", "of=512k-zeros.img", "bs=512", "count=1024" + assert_equal 524288, (testpath/"512k-zeros.img").size?, + "Could not create 512k-zeros.img with 512KiB of zeros" + system bin/"img2simg", "512k-zeros.img", "512k-zeros.simg" + assert_equal 44, (testpath/"512k-zeros.simg").size?, + "Converting 512KiB of zeros did not result in a 44 byte simg" + system bin/"simg2img", "512k-zeros.simg", "new-512k-zeros.img" + assert_equal 524288, (testpath/"new-512k-zeros.img").size?, + "Converting a 44 byte simg did not result in 512KiB" + system "diff", "512k-zeros.img", "new-512k-zeros.img" + end +end