class Gnupg < Formula desc "GNU Pretty Good Privacy (PGP) package" homepage "https://gnupg.org/" url "https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.4.0.tar.bz2" sha256 "1d79158dd01d992431dd2e3facb89fdac97127f89784ea2cb610c600fb0c1483" license "GPL-3.0-or-later" livecheck do url "https://gnupg.org/ftp/gcrypt/gnupg/" regex(/href=.*?gnupg[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 arm64_ventura: "a146c7aafc5be737c1bca197d01797f9bb84c4b82ff6778c75449f9464a10fe8" sha256 arm64_monterey: "f2ea60f92672591998c8b3bbfbfcc69d3917c905be2771e66727187bcfc85f39" sha256 arm64_big_sur: "d237c306bbafc7bca8940352eafba7108874d038e47145237d865b6cfc43d063" sha256 ventura: "371db9f98bcc761e42177f7ad6b1ba08630463192399efc980bb9333fcb0be1f" sha256 monterey: "2baf5392f4ef8e19c7bf06d152da8224b25e8d1c3847de8f6a1052e43b386a42" sha256 big_sur: "126299309b968bebca903810f5e667fa7143335333bbdcc9249f3f85b3b3becd" sha256 x86_64_linux: "eea701c4bb9ea6a3ba0b2c7ed783bd3600fc93a8ad23c2015fdc857d40d6af04" end depends_on "pkg-config" => :build 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" depends_on "readline" uses_from_macos "bzip2" uses_from_macos "sqlite", since: :catalina uses_from_macos "zlib" on_macos do depends_on "gettext" end def install libusb = Formula["libusb"] ENV.append "CPPFLAGS", "-I#{libusb.opt_include}/libusb-#{libusb.version.major_minor}" mkdir "build" do system "../configure", *std_configure_args, "--disable-silent-rules", "--sbindir=#{bin}", "--sysconfdir=#{etc}", "--enable-all-tests", "--with-pinentry-pgm=#{Formula["pinentry"].opt_bin}/pinentry" system "make" system "make", "check" system "make", "install" end # Configure scdaemon as recommended by upstream developers # https://dev.gnupg.org/T5415#145864 if OS.mac? # write to buildpath then install to ensure existing files are not clobbered (buildpath/"scdaemon.conf").write <<~EOS disable-ccid EOS pkgetc.install "scdaemon.conf" end 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