gpg_requirement: centralise logic in Gpg class
Removes the detection logic from the Requirement in favour of it living inside the Gpg class & us calling it from there. It's a bit nicer & avoids us calling Requirement code from outside of direct requirement handling & fulfillment.
This commit is contained in:
parent
1591633888
commit
e62fc26b9c
@ -1,27 +1,12 @@
|
|||||||
require "requirement"
|
require "requirement"
|
||||||
|
require "gpg"
|
||||||
|
|
||||||
class GPGRequirement < Requirement
|
class GPGRequirement < Requirement
|
||||||
fatal true
|
fatal true
|
||||||
default_formula "gnupg2"
|
default_formula "gnupg2"
|
||||||
|
|
||||||
satisfy(:build_env => false) { gpg2 || gpg }
|
|
||||||
|
|
||||||
# MacGPG2/GPGTools installs GnuPG 2.0.x as a vanilla `gpg` symlink
|
# 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`.
|
# 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.
|
# Temporarily, only support 2.0.x rather than the 2.1.x "modern" series.
|
||||||
def gpg
|
satisfy(:build_env => false) { Gpg.gpg2 || Gpg.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
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user