class Openvpn < Formula desc "SSL/TLS VPN implementing OSI layer 2 or 3 secure network extension" homepage "https://openvpn.net/index.php/download/community-downloads.html" url "https://swupdate.openvpn.org/community/releases/openvpn-2.4.4.tar.xz" mirror "https://build.openvpn.net/downloads/releases/openvpn-2.4.4.tar.xz" sha256 "96cd1b8fe1e8cb2920f07c3fd3985faea756e16fdeebd11d3e146d5bd2b04a80" bottle do sha256 "e2d50964da926f31d012647b97031ebd48b032a315f1f02e8c219dd33a381c24" => :high_sierra sha256 "5ed1394dca18113182e4564f001521908a4bdb8f71f6adc5eb713adb4a4e014f" => :sierra sha256 "ba28ad817104b3e953d2743e45a4c5554cea731c1016997bead7233755ff9a4d" => :el_capitan end # Requires tuntap for < 10.10 depends_on :macos => :yosemite depends_on "pkg-config" => :build depends_on "lzo" depends_on "openssl" resource "pkcs11-helper" do url "https://github.com/OpenSC/pkcs11-helper/releases/download/pkcs11-helper-1.22/pkcs11-helper-1.22.tar.bz2" sha256 "fbc15f5ffd5af0200ff2f756cb4388494e0fb00b4f2b186712dce6c48484a942" end def install vendor = buildpath/"brew_vendor" resource("pkcs11-helper").stage do system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{vendor}/pkcs11-helper", "--disable-threading", "--disable-slotevent", "--disable-shared" system "make", "install" end ENV.prepend_path "PKG_CONFIG_PATH", vendor/"pkcs11-helper/lib/pkgconfig" system "./configure", "--disable-debug", "--disable-dependency-tracking", "--disable-silent-rules", "--with-crypto-library=openssl", "--enable-pkcs11", "--prefix=#{prefix}" system "make", "install" inreplace "sample/sample-config-files/openvpn-startup.sh", "/etc/openvpn", "#{etc}/openvpn" (doc/"samples").install Dir["sample/sample-*"] (etc/"openvpn").install doc/"samples/sample-config-files/client.conf" (etc/"openvpn").install doc/"samples/sample-config-files/server.conf" # We don't use mbedtls, so this file is unnecessary & somewhat confusing. rm doc/"README.mbedtls" end def post_install (var/"run/openvpn").mkpath end plist_options :startup => true def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_sbin}/openvpn --config #{etc}/openvpn/openvpn.conf OnDemand RunAtLoad TimeOut 90 WatchPaths #{etc}/openvpn WorkingDirectory #{etc}/openvpn EOS end test do system sbin/"openvpn", "--show-ciphers" end end