homebrew-core/Formula/gnupg@2.0.rb
2018-01-01 10:42:18 -08:00

95 lines
3 KiB
Ruby

class GnupgAT20 < Formula
desc "GNU Privacy Guard: a free PGP replacement"
homepage "https://www.gnupg.org/"
url "https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.0.31.tar.bz2"
mirror "https://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/gnupg/gnupg-2.0.31.tar.bz2"
sha256 "095558cfbba52fba582963e97b0c016889570b4712d6b871abeef2cf93e62293"
bottle do
sha256 "4854e648eb7af8d3dce917c05b82f8f3ff87a078aca95761dad7787efc09a798" => :high_sierra
sha256 "d52b7e2fb7951d39f99f17b86ecc69e7e9b98e052ebf4daab67240ffea80eb97" => :sierra
sha256 "d9bd7fce7e528c08a3a10d3440d81b09995434dbe11505dfa9555d947466ffaa" => :el_capitan
end
keg_only :versioned_formula
depends_on "libgpg-error"
depends_on "libgcrypt"
depends_on "libksba"
depends_on "libassuan"
depends_on "pinentry"
depends_on "pth"
depends_on "gpg-agent"
depends_on "curl" if MacOS.version <= :mavericks
depends_on "dirmngr" => :recommended
depends_on "libusb-compat" => :recommended
depends_on "readline" => :optional
def install
# Adjust package name to fit our scheme of packaging both gnupg 1.x and
# 2.x, and gpg-agent separately, and adjust tests to fit this scheme
inreplace "configure" do |s|
s.gsub! "PACKAGE_NAME='gnupg'", "PACKAGE_NAME='gnupg2'"
s.gsub! "PACKAGE_TARNAME='gnupg'", "PACKAGE_TARNAME='gnupg2'"
end
inreplace "tests/openpgp/Makefile.in" do |s|
s.gsub! "required_pgms = ../../g10/gpg2 ../../agent/gpg-agent",
"required_pgms = ../../g10/gpg2"
s.gsub! "../../agent/gpg-agent --quiet --daemon sh",
"gpg-agent --quiet --daemon sh"
end
ENV.append "LDFLAGS", "-lresolv"
ENV["gl_cv_absolute_stdint_h"] = "#{MacOS.sdk_path}/usr/include/stdint.h"
agent = Formula["gpg-agent"].opt_prefix
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--sbindir=#{bin}
--enable-symcryptrun
--disable-agent
--with-agent-pgm=#{agent}/bin/gpg-agent
--with-protect-tool-pgm=#{agent}/libexec/gpg-protect-tool
]
if build.with? "readline"
args << "--with-readline=#{Formula["readline"].opt_prefix}"
end
system "./configure", *args
system "make"
system "make", "check"
system "make", "install"
bin.install "tools/gpg-zip"
# Add symlinks from gpg2 to unversioned executables, replacing gpg 1.x.
bin.install_symlink "gpg2" => "gpg"
bin.install_symlink "gpgv2" => "gpgv"
man1.install_symlink "gpg2.1" => "gpg.1"
man1.install_symlink "gpgv2.1" => "gpgv.1"
end
def post_install
(var/"run").mkpath
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
%commit
EOS
system bin/"gpg", "--batch", "--gen-key", "batch.gpg"
(testpath/"test.txt").write "Hello World!"
system bin/"gpg", "--armor", "--sign", "test.txt"
system bin/"gpg", "--verify", "test.txt.asc"
end
end