homebrew-core/Formula/mbedtls.rb

55 lines
2.2 KiB
Ruby

class Mbedtls < Formula
desc "Cryptographic & SSL/TLS library"
homepage "https://tls.mbed.org/"
url "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.26.0.tar.gz"
sha256 "35d8d87509cd0d002bddbd5508b9d2b931c5e83747d087234cc7ad551d53fe05"
license "Apache-2.0"
head "https://github.com/ARMmbed/mbedtls.git", branch: "development"
livecheck do
url :stable
strategy :github_latest
regex(%r{href=.*?/tag/(?:mbedtls[._-])?v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "6865368e7cb7c1ed400b404df81f1e31741f507217f0b7d0bc59e1d453ec11df"
sha256 cellar: :any, big_sur: "1efb3f239ee33216cb622abfd288a8f2c86e2f41c1257a0285a22c35215a6862"
sha256 cellar: :any, catalina: "ce31fd5b67d25bba62be1796da908badd06701b83c09fe3b62a8201770d71b7c"
sha256 cellar: :any, mojave: "ffd5443cc95bb8a9de99c6d429aa4f3cd6193b4084dee14f25f4377f0f56eee2"
end
depends_on "cmake" => :build
depends_on "python@3.9" => :build
def install
inreplace "include/mbedtls/config.h" do |s|
# 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",
"-DPython3_EXECUTABLE=#{Formula["python@3.9"].opt_bin}/python3",
*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