46 lines
1.9 KiB
Ruby
46 lines
1.9 KiB
Ruby
class Mbedtls < Formula
|
|
desc "Cryptographic & SSL/TLS library"
|
|
homepage "https://tls.mbed.org/"
|
|
url "https://tls.mbed.org/download/mbedtls-2.4.0-apache.tgz"
|
|
sha256 "c1c3559ed39f7a1b1550c4cf4ccb918bf239301a3311d98dda92bed8a25b7f0d"
|
|
head "https://github.com/ARMmbed/mbedtls.git", :branch => "development"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "95524591b12e3581f0196522fa2c89853f997af0a2a6c19c132027e7e8042443" => :sierra
|
|
sha256 "18d42d8a25cdae7255ff7feda52db50870bd6107fb365c01206eb86fad4c1715" => :el_capitan
|
|
sha256 "0cf28716564c785ff409dc0d73bbbe77f084b2ac8f341c0f3df222d866eee703" => :yosemite
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
|
|
def install
|
|
inreplace "include/mbedtls/config.h" do |s|
|
|
# disable support for SSL 3.0
|
|
s.gsub! "#define MBEDTLS_SSL_PROTO_SSL3", "//#define MBEDTLS_SSL_PROTO_SSL3"
|
|
# enable pthread mutexes
|
|
s.gsub! "//#define MBEDTLS_THREADING_PTHREAD", "#define MBEDTLS_THREADING_PTHREAD"
|
|
# allow use of mutexes within mbed TLS
|
|
s.gsub! "//#define MBEDTLS_THREADING_C", "#define MBEDTLS_THREADING_C"
|
|
end
|
|
|
|
system "cmake", "-DUSE_SHARED_MBEDTLS_LIBRARY=On", *std_cmake_args
|
|
system "make"
|
|
system "make", "install"
|
|
|
|
# Why does Mbedtls ship with a "Hello World" executable. Let's remove that.
|
|
rm_f bin/"hello"
|
|
# Rename benchmark & selftest, which are awfully generic names.
|
|
mv bin/"benchmark", bin/"mbedtls-benchmark"
|
|
mv bin/"selftest", bin/"mbedtls-selftest"
|
|
# Demonstration files shouldn't be in the main bin
|
|
libexec.install bin/"mpi_demo"
|
|
end
|
|
|
|
test do
|
|
(testpath/"testfile.txt").write("This is a test file")
|
|
# Don't remove the space between the checksum and filename. It will break.
|
|
expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249 testfile.txt"
|
|
assert_equal expected_checksum, shell_output("#{bin}/generic_sum SHA256 testfile.txt").strip
|
|
end
|
|
end
|