class Gnutls < Formula desc "GNU Transport Layer Security (TLS) Library" homepage "https://gnutls.org/" url "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.4/gnutls-3.4.11.tar.xz" mirror "https://gnupg.org/ftp/gcrypt/gnutls/v3.4/gnutls-3.4.11.tar.xz" mirror "https://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/gnutls/v3.4/gnutls-3.4.11.tar.xz" sha256 "70ef9c9f95822d363036c6e6b5479750e5b7fc34f50e750c3464a98ec65a9ab8" bottle do cellar :any sha256 "483c5f930fb10d1d00ae303e46d6dc00c89f643709ae96f5c495e1efdd2bd253" => :el_capitan sha256 "bd06d165424d0b62268109113d961607f26b067010a6580416f8dfa33ae55eb7" => :yosemite sha256 "c55fb2dc5c8ccb890ee8c61bd4f240b9cb39eb1b478bc71ab457ada0f06fd78a" => :mavericks end depends_on "pkg-config" => :build depends_on "libtasn1" depends_on "gmp" depends_on "nettle" depends_on "guile" => :optional depends_on "unbound" => :optional fails_with :llvm do build 2326 cause "Undefined symbols when linking" end def install args = %W[ --disable-dependency-tracking --disable-silent-rules --disable-static --prefix=#{prefix} --sysconfdir=#{etc} --with-default-trust-store-file=#{etc}/openssl/cert.pem --disable-heartbeat-support --without-p11-kit ] if build.with? "guile" args << "--enable-guile" args << "--with-guile-site-dir=no" end system "./configure", *args system "make", "install" # certtool shadows the OS X certtool utility mv bin/"certtool", bin/"gnutls-certtool" mv man1/"certtool.1", man1/"gnutls-certtool.1" end def post_install keychains = %w[ /Library/Keychains/System.keychain /System/Library/Keychains/SystemRootCertificates.keychain ] certs_list = `security find-certificate -a -p #{keychains.join(" ")}` certs = certs_list.scan( /-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m ) valid_certs = certs.select do |cert| IO.popen("openssl x509 -inform pem -checkend 0 -noout", "w") do |openssl_io| openssl_io.write(cert) openssl_io.close_write end $?.success? end openssldir = etc/"openssl" openssldir.mkpath (openssldir/"cert.pem").atomic_write(valid_certs.join("\n")) end test do system bin/"gnutls-cli", "--version" end end