class Dovecot < Formula desc "IMAP/POP3 server" homepage "https://dovecot.org/" url "https://dovecot.org/releases/2.3/dovecot-2.3.2.tar.gz" sha256 "6e48f0fa60768427f03035b0a3e93d1ae29b972bb2bd9ca998ccc6a0f6dae393" bottle do sha256 "4b56e6d8ae9d9110e255ddcfe58b7e64fb9962216dc1d82685fda4b31434caf2" => :high_sierra sha256 "cc4da940215029372f2595a544abbf23265449b17bd6b65b34fd76b6067d8014" => :sierra sha256 "d037c1f705e8be7c8d4c11e56f87f26d147f38837855dc042224b4556141d6d1" => :el_capitan end option "with-pam", "Build with PAM support" option "with-pigeonhole", "Add Sieve addon for Dovecot mailserver" option "with-pigeonhole-unfinished-features", "Build unfinished new Sieve addon features/extensions" option "with-stemmer", "Build with libstemmer support" depends_on "openssl" depends_on "clucene" => :optional resource "pigeonhole" do url "https://pigeonhole.dovecot.org/releases/2.3/dovecot-2.3-pigeonhole-0.5.2.tar.gz" sha256 "950e8e15c58e539761255e140dd3678dd2477fa432a5f2b804e53821bdc02535" end resource "stemmer" do url "https://github.com/snowballstem/snowball.git", :revision => "1964ce688cbeca505263c8f77e16ed923296ce7a" end def install args = %W[ --prefix=#{prefix} --disable-dependency-tracking --libexecdir=#{libexec} --sysconfdir=#{etc} --localstatedir=#{var} --with-ssl=openssl --with-sqlite --with-zlib --with-bzlib ] args << "--with-lucene" if build.with? "clucene" args << "--with-pam" if build.with? "pam" if build.with? "stemmer" args << "--with-libstemmer" resource("stemmer").stage do system "make", "dist_libstemmer_c" system "tar", "xzf", "dist/libstemmer_c.tgz", "-C", buildpath end end system "./configure", *args system "make", "install" if build.with? "pigeonhole" resource("pigeonhole").stage do args = %W[ --disable-dependency-tracking --with-dovecot=#{lib}/dovecot --prefix=#{prefix} ] args << "--with-unfinished-features" if build.with? "pigeonhole-unfinished-features" system "./configure", *args system "make" system "make", "install" end end end def caveats; <<~EOS For Dovecot to work, you may need to create a dovecot user and group depending on your configuration file options. EOS end plist_options :startup => true def plist; <<~EOS Label #{plist_name} KeepAlive RunAtLoad ProgramArguments #{opt_sbin}/dovecot -F StandardErrorPath #{var}/log/dovecot/dovecot.log StandardOutPath #{var}/log/dovecot/dovecot.log SoftResourceLimits NumberOfFiles 1000 HardResourceLimits NumberOfFiles 1024 EOS end test do assert_match version.to_s, shell_output("#{sbin}/dovecot --version") end end