class Gnupg < Formula desc "GNU Pretty Good Privacy (PGP) package" homepage "https://gnupg.org/" url "https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.2.21.tar.bz2" sha256 "61e83278fb5fa7336658a8b73ab26f379d41275bb1c7c6e694dd9f9a6e8e76ec" license "GPL-3.0" livecheck do url "https://gnupg.org/ftp/gcrypt/gnupg/" regex(/href=.*?gnupg[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 "a42991eca1ff5cc8bd25bdd700c8104c50f09a207b1599c8552662b67a95e36a" => :catalina sha256 "a6f32a714e777b8949f5197e2f70744352c1f3f6785e5813c390af1f45cb5e1c" => :mojave sha256 "191e614ac845a540c5973f522e2edd7d5d48e2e3f3399cafaf95ef2754a987d3" => :high_sierra end depends_on "pkg-config" => :build depends_on "adns" depends_on "gettext" depends_on "gnutls" depends_on "libassuan" depends_on "libgcrypt" depends_on "libgpg-error" depends_on "libksba" depends_on "libusb" depends_on "npth" depends_on "pinentry" def install system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--sbindir=#{bin}", "--sysconfdir=#{etc}", "--enable-all-tests", "--enable-symcryptrun", "--with-pinentry-pgm=#{Formula["pinentry"].opt_bin}/pinentry" system "make" system "make", "check" system "make", "install" end def post_install (var/"run").mkpath quiet_system "killall", "gpg-agent" end test do (testpath/"batch.gpg").write <<~EOS Key-Type: RSA Key-Length: 2048 Subkey-Type: RSA Subkey-Length: 2048 Name-Real: Testing Name-Email: testing@foo.bar Expire-Date: 1d %no-protection %commit EOS begin system bin/"gpg", "--batch", "--gen-key", "batch.gpg" (testpath/"test.txt").write "Hello World!" system bin/"gpg", "--detach-sign", "test.txt" system bin/"gpg", "--verify", "test.txt.sig" ensure system bin/"gpgconf", "--kill", "gpg-agent" end end end