Skip to content

Instantly share code, notes, and snippets.

@shantanoo
Created February 14, 2017 09:18
Show Gist options
  • Save shantanoo/fd57d0d1d5024ae3e7f2a3e1ed50c0bd to your computer and use it in GitHub Desktop.
Save shantanoo/fd57d0d1d5024ae3e7f2a3e1ed50c0bd to your computer and use it in GitHub Desktop.
class Gnupg21 < Formula
desc "GNU Privacy Guard: a free PGP replacement"
homepage "https://www.gnupg.org/"
url "https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.1.18.tar.bz2"
mirror "https://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/gnupg/gnupg-2.1.18.tar.bz2"
sha256 "d04c6fab7e5562ce4b915b22020e34d4c1a256847690cf149842264fc7cef994"
bottle do
sha256 "54c56057f77131999c28c36b8f1c7634cc49d93547c52e979afcffb18c5e414d" => :sierra
sha256 "3318380b33d6f8b96219885d5e633214160a91e067f4914c17c8755bc1910afb" => :el_capitan
sha256 "aaafb15c59f8d81683a2122ad9d7bbf9df15b38ebf6f4b0ac416d2f06e044d05" => :yosemite
end
option "with-gpgsplit", "Additionally install the gpgsplit utility"
option "without-libusb", "Disable the internal CCID driver"
option "with-test", "Verify the build with `make check`"
deprecated_option "without-libusb-compat" => "without-libusb"
depends_on "pkg-config" => :build
depends_on "sqlite" => :build if MacOS.version == :mavericks
depends_on "npth"
depends_on "gnutls"
depends_on "libgpg-error"
depends_on "libgcrypt"
depends_on "libksba"
depends_on "libassuan"
depends_on "pinentry"
depends_on "gettext"
depends_on "adns"
depends_on "libusb" => :recommended
depends_on "readline" => :optional
depends_on "homebrew/fuse/encfs" => :optional
conflicts_with "gnupg2",
:because => "GPG2.1.x is incompatible with the 2.0.x branch."
conflicts_with "gpg-agent",
:because => "GPG2.1.x ships an internal gpg-agent which it must use."
conflicts_with "dirmngr",
:because => "GPG2.1.x ships an internal dirmngr which it it must use."
conflicts_with "fwknop",
:because => "fwknop expects to use a `gpgme` with Homebrew/Homebrew's gnupg2."
conflicts_with "gpgme",
:because => "gpgme currently requires 1.x.x or 2.0.x."
def install
# Undefined symbols libintl_bind_textdomain_codeset, etc.
# Reported 19 Nov 2016 https://bugs.gnupg.org/gnupg/issue2846
ENV.append "LDFLAGS", "-lintl"
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--sbindir=#{bin}
--sysconfdir=#{etc}
--enable-symcryptrun
--with-pinentry-pgm=#{Formula["pinentry"].opt_bin}/pinentry
]
args << "--disable-ccid-driver" if build.without? "libusb"
args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline"
# Adjust package name to fit our scheme of packaging both gnupg 1.x and
# and 2.1.x and gpg-agent separately.
inreplace "configure" do |s|
s.gsub! "PACKAGE_NAME='gnupg'", "PACKAGE_NAME='gnupg2'"
s.gsub! "PACKAGE_TARNAME='gnupg'", "PACKAGE_TARNAME='gnupg2'"
end
system "./configure", *args
system "make"
# Intermittent "FAIL: gpgtar.scm" and "FAIL: ssh.scm"
# Reported 25 Jul 2016 https://bugs.gnupg.org/gnupg/issue2425
# Starting in 2.1.16, "can't connect to the agent: IPC connect call failed"
# Reported 19 Nov 2016 https://bugs.gnupg.org/gnupg/issue2847
system "make", "check" if build.with? "test"
system "make", "install"
bin.install "tools/gpgsplit" => "gpgsplit2" if build.with? "gpgsplit"
# Move man files that conflict with 1.x.
mv share/"doc/gnupg2/FAQ", share/"doc/gnupg2/FAQ21"
mv share/"doc/gnupg2/examples/gpgconf.conf", share/"doc/gnupg2/examples/gpgconf21.conf"
mv share/"info/gnupg.info", share/"info/gnupg21.info"
mv man7/"gnupg.7", man7/"gnupg21.7"
end
def post_install
(var/"run").mkpath
end
def caveats; <<-EOS.undent
Once you run the new gpg2 binary you will find it incredibly
difficult to go back to using `gnupg2` from Homebrew/Homebrew.
The new 2.1.x moves to a new keychain format that can't be
and won't be understood by the 2.0.x branch or lower.
If you use this `gnupg21` formula for a while and decide
you don't like it, you will lose the keys you've imported since.
For this reason, we strongly advise that you make a backup
of your `~/.gnupg` directory.
For full details of the changes, please visit:
https://www.gnupg.org/faq/whats-new-in-2.1.html
If you are upgrading to gnupg21 from gnupg2 you should execute:
`killall gpg-agent && gpg-agent --daemon`
After install. See:
https://github.com/Homebrew/homebrew-versions/issues/681
EOS
end
test do
system bin/"gpgconf"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment