From 83f20f9e75b2aa1cfef9cc59df79f168800ac58d Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 27 Aug 2024 11:02:58 -0700 Subject: [PATCH] Set PKG_CONFIG_PATH to ensure gpgme builds with local libassuan We had some build failures on macOS with this error: ``` configure: Use gpgrt-config as libassuan-config checking for LIBASSUAN - version >= 2.4.2... yes (3.0.1) checking LIBASSUAN API version... does not match. want=2 got=3. ``` This occurs when: 1. libassuan v3.0 is installed. 2. `PKG_CONFIG_PATH` includes the Homebrew path of `/opt/homebrew/lib/pkgconfig`. https://github.com/gpg/gpgme/blob/5bf3e6d0754a179b316f90a885371af99bc03ea1/m4/libassuan.m4#L32 attempts to run `gpgrt-config libassuan --exists`. This will return the Homebrew version of libassuan if `PKG_CONFIG_PATH` includes it. To avoid this build failure, preface `PKG_CONFIG_PATH` with the local vesions of libassuan and libgpg-error. --- ext/gpgme/extconf.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/gpgme/extconf.rb b/ext/gpgme/extconf.rb index 7dd4dc6..ef13097 100644 --- a/ext/gpgme/extconf.rb +++ b/ext/gpgme/extconf.rb @@ -106,6 +106,16 @@ recipe.activate end + pkg_config_paths = [ + File.join(libgpg_error_recipe.lib_path, 'pkgconfig'), + File.join(libassuan_recipe.lib_path, 'pkgconfig'), + ] + + # Ensure that the locally-built libraries take precedence. gpgme runs + # `gpgrt-config libassuan` and could pull in the system libassuan + # if PKG_CONFIG_PATH is not set properly. + ENV["PKG_CONFIG_PATH"] = [*pkg_config_paths, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR) + gpgme_recipe = MiniPortile.new('gpgme', '1.21.0').tap do |recipe| recipe.target = File.join(ROOT, "ports") recipe.files = [{