aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorDominyk Tiller2016-08-10 04:42:34 +0100
committerDominyk Tiller2016-08-13 03:33:33 +0100
commit15916338888e48e70edc4ade7f0aff94e3607e76 (patch)
tree64d989148a49842fe64084b7294c90fba8b4d34b /Library
parent9515e95ae7b6841a2bc7d87f11068e4dff59ad17 (diff)
downloadbrew-15916338888e48e70edc4ade7f0aff94e3607e76.tar.bz2
gpg_requirement: add standalone requirement
GPG 1.x has stopped receiving new features, some of which we may well want to take advantage of sooner or later in Homebrew. Upstream has also been attempting to work out for a while how well used it still is which suggests it may "go away" at some point in the future. Debian is also in the process of migrating GnuPG 1.x to a `gpg1` executable whilst GnuPG 2.1.x assumes the `gpg` executable. There's a detailed video discussion of this from DebConf 2015 at: http://meetings-archive.debian.net/pub/debian-meetings/2015/debconf15/GnuPG_in_Debian_report.webm It's unsafe to assume every `gpg` executable is going to forever equal 1.x and every `gpg2` executable is going to forever equal 2.x. MacGPG2 has been symlinking 2.x as a vanilla `gpg` for a while, for example, and we will be soon as well. You'll still be able to plonk the `libexec/bin` path of `gpg` in your PATH to access a vanilla `gpg` 1.x executable if you want to, but we're not going to actively keep adding gpg1 support to formulae going forwards. There's really no reason why 99.9% of projects should not or cannot use `gpg2` these days. This uses detection methods to determine regardless of what the executable is called we're always hitting a 2.0 GnuPG or nothing.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/requirements.rb1
-rw-r--r--Library/Homebrew/requirements/gpg_requirement.rb27
2 files changed, 28 insertions, 0 deletions
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index 2764583fb..8ba83b0c5 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -1,6 +1,7 @@
require "requirement"
require "requirements/apr_requirement"
require "requirements/fortran_requirement"
+require "requirements/gpg_requirement"
require "requirements/language_module_requirement"
require "requirements/minimum_macos_requirement"
require "requirements/maximum_macos_requirement"
diff --git a/Library/Homebrew/requirements/gpg_requirement.rb b/Library/Homebrew/requirements/gpg_requirement.rb
new file mode 100644
index 000000000..ef33a4fc5
--- /dev/null
+++ b/Library/Homebrew/requirements/gpg_requirement.rb
@@ -0,0 +1,27 @@
+require "requirement"
+
+class GPGRequirement < Requirement
+ fatal true
+ default_formula "gnupg2"
+
+ satisfy(:build_env => false) { gpg2 || gpg }
+
+ # MacGPG2/GPGTools installs GnuPG 2.0.x as a vanilla `gpg` symlink
+ # pointing to `gpg2`, as do we. Ensure we're actually using a 2.0 `gpg`.
+ # Temporarily, only support 2.0.x rather than the 2.1.x "modern" series.
+ def gpg
+ which_all("gpg").detect do |gpg|
+ gpg_short_version = Utils.popen_read(gpg, "--version")[/\d\.\d/, 0]
+ next unless gpg_short_version
+ Version.create(gpg_short_version.to_s) == Version.create("2.0")
+ end
+ end
+
+ def gpg2
+ which_all("gpg2").detect do |gpg2|
+ gpg2_short_version = Utils.popen_read(gpg2, "--version")[/\d\.\d/, 0]
+ next unless gpg2_short_version
+ Version.create(gpg2_short_version.to_s) == Version.create("2.0")
+ end
+ end
+end