Skip to content

Instantly share code, notes, and snippets.

@skull-squadron
Created April 21, 2023 01:32
Show Gist options
  • Save skull-squadron/ac4e437c87c81cdba3c595960d6ba3c6 to your computer and use it in GitHub Desktop.
Save skull-squadron/ac4e437c87c81cdba3c595960d6ba3c6 to your computer and use it in GitHub Desktop.
gpgme for Mailvelope
diff --git a/Formula/gpgme.rb b/Formula/gpgme.rb
index 45abd0b45ca..cbb56d52864 100644
--- a/Formula/gpgme.rb
+++ b/Formula/gpgme.rb
@@ -49,6 +49,7 @@ class Gpgme < Formula
"\\0 --install-lib=#{site_packages}"
system "./configure", *std_configure_args,
+ "--enable-fixed-path=#{Formula["gnupg"].opt_bin}",
"--disable-silent-rules",
"--enable-static"
system "make"
require 'open-uri'
require 'digest/sha2'
class Gpgme < Formula
def self._ver
@_ver ||= URI.open('https://www.gnupg.org/ftp/gcrypt/gpgme/')
.read
.match(/href=.*?gpgme[._-]v?(\d+(?:\.\d+)+)\.t/i)[1]
end
def self._the_url
"https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-#{_ver}.tar.bz2"
end
def self._hash
::Digest::SHA256.hexdigest(URI.open(_the_url).read)
end
desc "Library access to GnuPG"
homepage "https://www.gnupg.org/related_software/gpgme/"
url _the_url
sha256 _hash
license "LGPL-2.1-or-later"
livecheck do
url "https://gnupg.org/ftp/gcrypt/gpgme/"
regex(/href=.*?gpgme[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
depends_on "python@3.11" => [:build, :test]
depends_on "swig" => :build
depends_on "gnupg"
depends_on "libassuan"
depends_on "libgpg-error"
def python3
"python3.11"
end
def install
ENV["PYTHON"] = python3
# HACK: Stop build from ignoring our PYTHON input. As python versions are
# hardcoded, the Arch Linux patch that changed 3.9 to 3.10 can't detect 3.11
inreplace "configure", /# Reset everything.*\n\s*unset PYTHON$/, ""
# Uses generic lambdas.
# error: 'auto' not allowed in lambda parameter
ENV.append "CXXFLAGS", "-std=c++14"
site_packages = prefix/Language::Python.site_packages(python3)
ENV.append_path "PYTHONPATH", site_packages
# Work around Homebrew's "prefix scheme" patch which causes non-pip installs
# to incorrectly try to write into HOMEBREW_PREFIX/lib since Python 3.10.
inreplace "lang/python/Makefile.in",
/^\s*install\s*\\\n\s*--prefix "\$\(DESTDIR\)\$\(prefix\)"/,
"\\0 --install-lib=#{site_packages}"
system "./configure", *std_configure_args,
"--enable-fixed-path=#{Formula["gnupg"].opt_bin}",
"--disable-silent-rules",
"--enable-static"
system "make"
system "make", "install"
# Rename the `easy-install.pth` file to avoid `brew link` conflicts.
site_packages.install site_packages/"easy-install.pth" => "homebrew-gpgme-#{version}.pth"
# avoid triggering mandatory rebuilds of software that hard-codes this path
inreplace bin/"gpgme-config", prefix, opt_prefix
end
test do
assert_match version.to_s, shell_output("#{bin}/gpgme-tool --lib-version")
system python3, "-c", "import gpg; print(gpg.version.versionstr)"
end
end
@skull-squadron
Copy link
Author

curl -fsSL -o "$(brew --repository)/Library/Taps/homebrew/homebrew-core"/gpgme.rb https://gist.github.com/steakknife/ac4e437c87c81cdba3c595960d6ba3c6/raw/gpgme.rb && brew reinstall gpgme -s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment