[seahorse/wip/nielsdg/gpgme-dep] meson: Use dependency() for gpgme
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/nielsdg/gpgme-dep] meson: Use dependency() for gpgme
- Date: Sun, 2 Feb 2020 16:17:10 +0000 (UTC)
commit f862919765f92640016604e65eb6c535fa9a80a2
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Feb 2 17:13:51 2020 +0100
meson: Use dependency() for gpgme
Since version 0.51, we can rely on Meson to do the correct thing when
calling `dependency('gpgme')`. This makes both the meson.build and the
GPG version checking script quite a bit cleaner.
Fixes https://gitlab.gnome.org/GNOME/seahorse/issues/240
build-aux/gpg_check_version.py | 19 +++++++------------
meson.build | 15 +++------------
pgp/meson.build | 2 +-
3 files changed, 11 insertions(+), 25 deletions(-)
---
diff --git a/build-aux/gpg_check_version.py b/build-aux/gpg_check_version.py
index 6d32046a..60b814cf 100755
--- a/build-aux/gpg_check_version.py
+++ b/build-aux/gpg_check_version.py
@@ -5,18 +5,17 @@ import sys
import subprocess
# Parses the GPG version from the output of the --version flag.
-# Should work on the output for `gpg`, `gpg2` and `gpgme-config`.
+# Should work on the output for `gpg` and `gpg2`
def parse_version(gpg_output):
version_line = gpg_output.splitlines()[0]
return version_line.strip().split(' ')[-1]
# Checks whether the GPG version is compatible with the given version.
-# For GPG, this means that the major and minor version should be equal;
-# for GPGME, this means only the major version should be equal.
-def check_version(gpg_version, accepted_version, is_gpgme = False):
+# This means that the major and minor version should be equal.
+def check_version(gpg_version, accepted_version):
acc_major, acc_minor, acc_micro = accepted_version.split('.', 2)
- # The GPG(ME) version we got still might have to be sanitized
+ # The GPG version we got still might have to be sanitized
# For example, sometimes it adds a "-unknown" suffix
gpg_major_str, gpg_minor_str, gpg_micro_str = gpg_version.split('.', 2)
@@ -27,17 +26,13 @@ def check_version(gpg_version, accepted_version, is_gpgme = False):
_micro_match = re.match(r'^([0-9]+)[^0-9]*', gpg_micro_str)
gpg_micro = int(_micro_match.group(1)) if _micro_match != None else 0
- if is_gpgme:
- return gpg_major == int(acc_major) and gpg_minor >= int(acc_minor) and gpg_micro >= int(acc_micro)
-
return gpg_major == int(acc_major) and gpg_minor == int(acc_minor) and gpg_micro >= int(acc_micro)
-if len(sys.argv) <= 3:
+if len(sys.argv) <= 2:
sys.exit(1)
gpg_path = sys.argv[1]
-is_gpgme = True if sys.argv[2].lower() == 'true' else False
-accepted_versions = sys.argv[3:]
+accepted_versions = sys.argv[2:]
# Parse and print the version
proc = subprocess.Popen([gpg_path, '--version'],
@@ -48,7 +43,7 @@ print(gpg_version, end='')
# Then return whether we're compatible with that version
for accepted_version in accepted_versions:
- if check_version(gpg_version, accepted_version, is_gpgme):
+ if check_version(gpg_version, accepted_version):
sys.exit(0)
sys.exit(1)
diff --git a/meson.build b/meson.build
index 8347f31a..f4b8081a 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
project('seahorse', ['vala', 'c'],
version: '3.35.1',
- meson_version: '>= 0.49',
+ meson_version: '>= 0.51',
license: 'GPL2+',
)
@@ -37,7 +37,6 @@ endif
# Dependencies
min_glib_version = '2.44'
min_gcr_version = '3.11.91'
-min_gpgme_version = '1.7.0'
accepted_gpg_versions = [ '2.0.12', '2.1.4', '2.2.0' ]
gpg_check_version = find_program('build-aux' / 'gpg_check_version.py')
@@ -76,23 +75,15 @@ posix = valac.find_library('posix')
ssh_bin = find_program('ssh')
ssh_keygen = find_program('ssh-keygen')
gpg_bin = find_program('gpg2', 'gpg', required: with_pgp)
-gpgme = cc.find_library('gpgme', required: with_pgp)
-gpgme_config = find_program('gpgme-config', required: with_pgp)
+gpgme_dep = dependency('gpgme', version: '>= 1.7.0', required: with_pgp)
if with_pgp
- gpg_version_check = run_command([gpg_check_version, gpg_bin.path(), 'false', accepted_gpg_versions ])
+ gpg_version_check = run_command([gpg_check_version, gpg_bin.path(), accepted_gpg_versions ])
gpg_version = gpg_version_check.stdout()
message('GnuPG Version: @0@'.format(gpg_version))
if check_compatible_gpg and gpg_version_check.returncode() != 0
error('Incompatible version of GnuPG. Accepted versions are: @0@'.format(accepted_gpg_versions))
endif
-
- gpgme_version_check = run_command([gpg_check_version, gpgme_config.path(), 'true', min_gpgme_version ])
- gpgme_version = gpgme_version_check.stdout()
- message('GPGME version: @0@'.format(gpgme_version))
- if check_compatible_gpg and gpgme_version_check.returncode() != 0
- error('Incompatible version of GPGME. Minimal version required is @0@'.format(min_gpgme_version))
- endif
endif
pkcs11_dep = valac.find_library('pkcs11', required: with_pkcs11)
diff --git a/pgp/meson.build b/pgp/meson.build
index 5793e613..dd3b6279 100644
--- a/pgp/meson.build
+++ b/pgp/meson.build
@@ -39,7 +39,7 @@ pgp_sources = [
pgp_dependencies = [
glib_deps,
gcr,
- gpgme,
+ gpgme_dep,
common_dep,
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]