diff --git a/.gitignore b/.gitignore
index 34df9ff..c6672af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-SOURCES/ldb-2.1.3.tar.gz
+SOURCES/ldb-2.2.0.tar.gz
+SOURCES/ldb.keyring
diff --git a/.libldb.metadata b/.libldb.metadata
index d0974dd..b564ab1 100644
--- a/.libldb.metadata
+++ b/.libldb.metadata
@@ -1 +1,2 @@
-06d1c8457e56b2df26cec16253a62acc789aa6fb SOURCES/ldb-2.1.3.tar.gz
+7c6d0827a20195636fcd84d713eea278d39064d4 SOURCES/ldb-2.2.0.tar.gz
+8ac6d09878c4218fb8e365fcf5a877a621dd40f9 SOURCES/ldb.keyring
diff --git a/SOURCES/0001-PATCH-wafsamba-Fix-few-SyntaxWarnings-caused-by-regu.patch b/SOURCES/0001-PATCH-wafsamba-Fix-few-SyntaxWarnings-caused-by-regu.patch
new file mode 100644
index 0000000..3b81899
--- /dev/null
+++ b/SOURCES/0001-PATCH-wafsamba-Fix-few-SyntaxWarnings-caused-by-regu.patch
@@ -0,0 +1,195 @@
+From d4e0a07a24c16b38de58c14a38b418c63106ad09 Mon Sep 17 00:00:00 2001
+From: Lukas Slebodnik <lslebodn@fedoraproject.org>
+Date: Sat, 24 Aug 2019 16:46:30 +0200
+Subject: [PATCH] [PATCH] wafsamba: Fix few SyntaxWarnings caused by regular 
+ expressions
+
+./buildtools/wafsamba/samba_utils.py:258: SyntaxWarning: invalid escape sequence \$
+  lst = re.split('(\$\{\w+\})', string)
+./buildtools/wafsamba/samba_utils.py:261: SyntaxWarning: invalid escape sequence \$
+  if re.match('\$\{\w+\}', v):
+./buildtools/wafsamba/samba_cross.py:80: SyntaxWarning: invalid escape sequence \(
+  m = re.match('\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans)
+./buildtools/wafsamba/samba_conftests.py:400: SyntaxWarning: invalid escape sequence \s
+  m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
+./buildtools/wafsamba/samba_abi.py:24: SyntaxWarning: invalid escape sequence \$
+  sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig)
+./buildtools/wafsamba/samba_abi.py:25: SyntaxWarning: invalid escape sequence \$
+  sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig)
+./buildtools/wafsamba/samba_abi.py:26: SyntaxWarning: invalid escape sequence \$
+  sig = re.sub('^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig)
+./buildtools/wafsamba/samba_abi.py:33: SyntaxWarning: invalid escape sequence \*
+  m = m.replace('*', '\*')
+./buildtools/wafsamba/samba_abi.py:44: SyntaxWarning: invalid escape sequence \s
+  sig = re.sub(',\s\.\.\.', '', sig)
+./buildtools/wafsamba/samba_headers.py:22: SyntaxWarning: invalid escape sequence \s
+  re_header = re.compile('^\s*#\s*include[ \t]*"([^"]+)"', re.I | re.M)
+./buildtools/wafsamba/symbols.py:122: SyntaxWarning: invalid escape sequence \[
+  re_sharedlib = re.compile(b'Shared library: \[(.*)\]')
+./buildtools/wafsamba/symbols.py:124: SyntaxWarning: invalid escape sequence \[
+  re_rpath     = re.compile(b'Library (rpath|runpath): \[(.*)\]')
+./buildtools/wafsamba/pkgconfig.py:12: SyntaxWarning: invalid escape sequence \w
+  a = re.split('(@\w+@)', s)
+./buildtools/wafsamba/pkgconfig.py:17: SyntaxWarning: invalid escape sequence \w
+  if re.match('@\w+@', v):
+./buildtools/wafsamba/configure_file.py:16: SyntaxWarning: invalid escape sequence \w
+  a = re.split('(@\w+@)', s)
+./buildtools/wafsamba/configure_file.py:19: SyntaxWarning: invalid escape sequence \w
+  if re.match('@\w+@', v):
+---
+ buildtools/wafsamba/configure_file.py  |  4 ++--
+ buildtools/wafsamba/pkgconfig.py       |  4 ++--
+ buildtools/wafsamba/samba_abi.py       | 12 ++++++------
+ buildtools/wafsamba/samba_conftests.py |  2 +-
+ buildtools/wafsamba/samba_cross.py     |  2 +-
+ buildtools/wafsamba/samba_headers.py   |  2 +-
+ buildtools/wafsamba/samba_utils.py     |  4 ++--
+ buildtools/wafsamba/symbols.py         |  4 ++--
+ 8 files changed, 17 insertions(+), 17 deletions(-)
+
+diff --git a/buildtools/wafsamba/configure_file.py b/buildtools/wafsamba/configure_file.py
+index 6ad43546249fba7b4c0a037035e8574e7a9d2753..98a58a4604513e3633317e73299c1c9280c250d2 100644
+--- a/buildtools/wafsamba/configure_file.py
++++ b/buildtools/wafsamba/configure_file.py
+@@ -13,10 +13,10 @@ def subst_at_vars(task):
+     s = task.inputs[0].read()
+ 
+     # split on the vars
+-    a = re.split('(@\w+@)', s)
++    a = re.split(r'(@\w+@)', s)
+     out = []
+     for v in a:
+-        if re.match('@\w+@', v):
++        if re.match(r'@\w+@', v):
+             vname = v[1:-1]
+             if not vname in task.env and vname.upper() in task.env:
+                 vname = vname.upper()
+diff --git a/buildtools/wafsamba/pkgconfig.py b/buildtools/wafsamba/pkgconfig.py
+index b83d5f382a58352bb3318b594aa2b45fc02d87d5..b77bd618c8903789c7ba9e64a6972a4e080f1821 100644
+--- a/buildtools/wafsamba/pkgconfig.py
++++ b/buildtools/wafsamba/pkgconfig.py
+@@ -9,12 +9,12 @@ def subst_at_vars(task):
+ 
+     s = task.inputs[0].read()
+     # split on the vars
+-    a = re.split('(@\w+@)', s)
++    a = re.split(r'(@\w+@)', s)
+     out = []
+     done_var = {}
+     back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
+     for v in a:
+-        if re.match('@\w+@', v):
++        if re.match(r'@\w+@', v):
+             vname = v[1:-1]
+             if not vname in task.env and vname.upper() in task.env:
+                 vname = vname.upper()
+diff --git a/buildtools/wafsamba/samba_abi.py b/buildtools/wafsamba/samba_abi.py
+index 5e7686da3d68b1ebcd842b8a319a5997fa9cf600..761667fcfe1f3937be22c8261b45dcb3979ae4cd 100644
+--- a/buildtools/wafsamba/samba_abi.py
++++ b/buildtools/wafsamba/samba_abi.py
+@@ -21,16 +21,16 @@ version_key = lambda x: list(map(int, x.split(".")))
+ def normalise_signature(sig):
+     '''normalise a signature from gdb'''
+     sig = sig.strip()
+-    sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig)
+-    sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig)
+-    sig = re.sub('^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig)
+-    sig = re.sub('0x[0-9a-f]+', '0xXXXX', sig)
++    sig = re.sub(r'^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig)
++    sig = re.sub(r'^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig)
++    sig = re.sub(r'^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig)
++    sig = re.sub(r'0x[0-9a-f]+', '0xXXXX', sig)
+     sig = re.sub('", <incomplete sequence (\\\\[a-z0-9]+)>', r'\1"', sig)
+ 
+     for t in abi_type_maps:
+         # we need to cope with non-word characters in mapped types
+         m = t
+-        m = m.replace('*', '\*')
++        m = m.replace('*', r'\*')
+         if m[-1].isalnum() or m[-1] == '_':
+             m += '\\b'
+         if m[0].isalnum() or m[0] == '_':
+@@ -41,7 +41,7 @@ def normalise_signature(sig):
+ 
+ def normalise_varargs(sig):
+     '''cope with older versions of gdb'''
+-    sig = re.sub(',\s\.\.\.', '', sig)
++    sig = re.sub(r',\s\.\.\.', '', sig)
+     return sig
+ 
+ 
+diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
+index ef632ba903369e4211991f17a3b204bcd96c3a2f..63e50567860ff890b00b0ce6c7607c917b7329d1 100644
+--- a/buildtools/wafsamba/samba_conftests.py
++++ b/buildtools/wafsamba/samba_conftests.py
+@@ -397,7 +397,7 @@ WriteMakefile(
+ 
+     if section:
+         man = Utils.readf(os.path.join(bdir,'Makefile'))
+-        m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
++        m = re.search(r'MAN%sEXT\s+=\s+(\w+)' % section, man)
+         if not m:
+             conf.end_msg('not found', color='YELLOW')
+             return
+diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py
+index 8863c2c53e7d7dd9317c9233f0085ffd0eea6b2f..34793902fba884cf2d8358bf4315dc98027266b6 100644
+--- a/buildtools/wafsamba/samba_cross.py
++++ b/buildtools/wafsamba/samba_cross.py
+@@ -77,7 +77,7 @@ def cross_answer(ca_file, msg):
+                 f.close()
+                 return (0, ans.strip("'"))
+             else:
+-                m = re.match('\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans)
++                m = re.match(r'\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans)
+                 if m:
+                     f.close()
+                     return (int(m.group(1)), m.group(2))
+diff --git a/buildtools/wafsamba/samba_headers.py b/buildtools/wafsamba/samba_headers.py
+index a268c011c5d8e406e0d763554c55668cfb5388bc..c8bee19010978a04460b0637fcc8fd484a699ea8 100644
+--- a/buildtools/wafsamba/samba_headers.py
++++ b/buildtools/wafsamba/samba_headers.py
+@@ -19,7 +19,7 @@ def header_install_path(header, header_path):
+     return ''
+ 
+ 
+-re_header = re.compile('^\s*#\s*include[ \t]*"([^"]+)"', re.I | re.M)
++re_header = re.compile(r'^\s*#\s*include[ \t]*"([^"]+)"', re.I | re.M)
+ 
+ # a dictionary mapping source header paths to public header paths
+ header_map = {}
+diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
+index ad97de1859ba24c4afd5106b4f9694b0dc855643..75c9794ec40f327ef8ccf9aa33fafd6ed6181e3b 100644
+--- a/buildtools/wafsamba/samba_utils.py
++++ b/buildtools/wafsamba/samba_utils.py
+@@ -255,10 +255,10 @@ def TO_LIST(str, delimiter=None):
+ 
+ def subst_vars_error(string, env):
+     '''substitute vars, throw an error if a variable is not defined'''
+-    lst = re.split('(\$\{\w+\})', string)
++    lst = re.split(r'(\$\{\w+\})', string)
+     out = []
+     for v in lst:
+-        if re.match('\$\{\w+\}', v):
++        if re.match(r'\$\{\w+\}', v):
+             vname = v[2:-1]
+             if not vname in env:
+                 raise KeyError("Failed to find variable %s in %s in env %s <%s>" % (vname, string, env.__class__, str(env)))
+diff --git a/buildtools/wafsamba/symbols.py b/buildtools/wafsamba/symbols.py
+index 3eca3d46bd71cf0780b3c8e36a26b96bd3aa3b83..73e8ca8ce53ef5d956ac58e14a2403dd49f01109 100644
+--- a/buildtools/wafsamba/symbols.py
++++ b/buildtools/wafsamba/symbols.py
+@@ -119,9 +119,9 @@ def find_ldd_path(bld, libname, binary):
+ 
+ 
+ # some regular expressions for parsing readelf output
+-re_sharedlib = re.compile(b'Shared library: \[(.*)\]')
++re_sharedlib = re.compile(r'Shared library: \[(.*)\]')
+ # output from readelf could be `Library rpath` or `Libray runpath`
+-re_rpath     = re.compile(b'Library (rpath|runpath): \[(.*)\]')
++re_rpath     = re.compile(r'Library (rpath|runpath): \[(.*)\]')
+ 
+ def get_libs(bld, binname):
+     '''find the list of linked libraries for any binary or library
+-- 
+2.23.0.rc2
+
diff --git a/SOURCES/1420.patch b/SOURCES/1420.patch
new file mode 100644
index 0000000..c2199ef
--- /dev/null
+++ b/SOURCES/1420.patch
@@ -0,0 +1,44 @@
+From 0e4fd77c1e03fe6351d129f2161b0b3313f5fa3d Mon Sep 17 00:00:00 2001
+From: Mathieu Parent <math.parent@gmail.com>
+Date: Thu, 25 Jun 2020 09:48:04 +0200
+Subject: [PATCH] Fix FTBFS / Increase the over-estimation for sparse files
+
+BUG: https://bugzilla.samba.org/show_bug.cgi?id=14418
+Signed-off-by: Mathieu Parent <math.parent@gmail.com>
+---
+ tests/ldb_kv_ops_test.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/lib/ldb/tests/ldb_kv_ops_test.c b/lib/ldb/tests/ldb_kv_ops_test.c
+index 30adebf1952..9db2212895f 100644
+--- a/tests/ldb_kv_ops_test.c
++++ b/tests/ldb_kv_ops_test.c
+@@ -1717,8 +1717,11 @@ static void test_get_size(void **state)
+ 	/*
+ 	 * The tdb implementation of get_size over estimates for sparse files
+ 	 * which is perfectly acceptable for it's intended use.
++	 * mipsel, ia64: 9994
++	 * ppc64el, powerpc, ppc64: 13369
++	 * sparc64: 5046
+ 	 */
+-	assert_in_range(size, 2500, 5000);
++	assert_in_range(size, 2500, 15000);
+ #endif
+ 
+ 	/*
+@@ -1746,8 +1749,11 @@ static void test_get_size(void **state)
+ 	/*
+ 	 * The tdb implementation of get_size over estimates for sparse files
+ 	 * which is perfectly acceptable for it's intended use.
++	 * mipsel, ia64: 9994
++	 * ppc64el, powerpc, ppc64: 13369
++	 * sparc64: 5046
+ 	 */
+-	assert_in_range(size, 2500, 5000);
++	assert_in_range(size, 2500, 15000);
+ #endif
+ 	talloc_free(tmp_ctx);
+ }
+-- 
+GitLab
+
diff --git a/SOURCES/CVE-2020-10730.patch b/SOURCES/CVE-2020-10730.patch
deleted file mode 100644
index cd6e8f4..0000000
--- a/SOURCES/CVE-2020-10730.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 3bdc110e167d7e0f20022dea48ec51b1f46369cb Mon Sep 17 00:00:00 2001
-From: Gary Lockyer <gary@catalyst.net.nz>
-Date: Wed, 13 May 2020 10:56:56 +1200
-Subject: [PATCH 10/11] CVE-2020-10730: lib ldb: Check if
- ldb_lock_backend_callback called twice
-
-Prevent use after free issues if ldb_lock_backend_callback is called
-twice, usually due to ldb_module_done being called twice. This can happen if a
-module ignores the return value from function a function that calls
-ldb_module_done as part of it's error handling.
-
-BUG: https://bugzilla.samba.org/show_bug.cgi?id=14364
-
-Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
-Reviewed-by: Andrew Bartlett <abartlet@samba.org>
----
- lib/ldb/common/ldb.c | 9 ++++++++-
- 1 file changed, 8 insertions(+), 1 deletion(-)
-
-diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
-index 44a487ba987..090d41dde69 100644
---- a/lib/ldb/common/ldb.c
-+++ b/lib/ldb/common/ldb.c
-@@ -1009,6 +1009,13 @@ static int ldb_lock_backend_callback(struct ldb_request *req,
- 	struct ldb_db_lock_context *lock_context;
- 	int ret;
- 
-+	if (req->context == NULL) {
-+		/*
-+		 * The usual way to get here is to ignore the return codes
-+		 * and continuing processing after an error.
-+		 */
-+		abort();
-+	}
- 	lock_context = talloc_get_type(req->context,
- 				       struct ldb_db_lock_context);
- 
-@@ -1023,7 +1030,7 @@ static int ldb_lock_backend_callback(struct ldb_request *req,
- 		 * If this is a LDB_REPLY_DONE or an error, unlock the
- 		 * DB by calling the destructor on this context
- 		 */
--		talloc_free(lock_context);
-+		TALLOC_FREE(req->context);
- 		return ret;
- 	}
- 
--- 
-2.17.1
diff --git a/SOURCES/ldb-2.2.0.tar.asc b/SOURCES/ldb-2.2.0.tar.asc
new file mode 100644
index 0000000..d8ff672
--- /dev/null
+++ b/SOURCES/ldb-2.2.0.tar.asc
@@ -0,0 +1,11 @@
+-----BEGIN PGP SIGNATURE-----
+
+iQFJBAABCgAzFiEEkUejOXGVGO6QEby1R5ORYRMIQCUFAl8HCQwVHHNhbWJhLWJ1
+Z3NAc2FtYmEub3JnAAoJEEeTkWETCEAlrwkH/A/MJM5E0Pyz6HNdctHSrA97FB6Q
+JI1MnsyXerZXfDulcUFmyrNPp66gLGeNGG2X9eoxvWrZk3hPnYe9YPE6UiwCKxZu
+1CSp2JuwaVB6EoUxUIuh63DFlF9Th/ZEhPsBrP3tQHvZyGpTDOQq3qhV7FLsrIwO
+RstK5CJIqmgwy84oJmKanWLWfTqdp/HBvVsZw0/kZ0Kr+3DUcM9MaY7hifMpcSOV
+8HTMgIpEoPbKkNOMj2lkDiYcx3tLWtdMYQdN31Cng3X9n5XmLX0GQlfCjfediSkT
+vK2RGlIp/hlEXOSyIG2mJync+u4NCOv7r8EEcVhjHDYOflIvfOiwbITtWMg=
+=/f7o
+-----END PGP SIGNATURE-----
diff --git a/SPECS/libldb.spec b/SPECS/libldb.spec
index 79fb76c..a8e6fc3 100644
--- a/SPECS/libldb.spec
+++ b/SPECS/libldb.spec
@@ -1,49 +1,76 @@
+%if ((0%{?fedora} || 0%{?rhel} > 7 || 0%{?epel} > 6))
+
+# lmdb is not supported on 32 bit architectures
+# also disabled on aarch64 for now, due to #1897082
+%ifarch s390x x86_64
+%bcond_without lmdb
+%else
+%bcond_with lmdb
+#endif arch
+%endif
+
+%else
+%bcond_with lmdb
+#endif fedora || rhel || epel
+%endif
+
+%if 0%{?fedora} || 0%{?rhel} > 7
+%bcond_without python3
+%else
+%bcond_with python3
+%endif
+
 %global talloc_version 2.3.1
 %global tdb_version 1.4.3
 %global tevent_version 0.10.2
 
 Name: libldb
-Version: 2.1.3
-Release: 2%{?dist}
+Version: 2.2.0
+Release: 1%{?dist}
 Summary: A schema-less, ldap like, API and database
 Requires: libtalloc%{?_isa} >= %{talloc_version}
 Requires: libtdb%{?_isa} >= %{tdb_version}
 Requires: libtevent%{?_isa} >= %{tevent_version}
 License: LGPLv3+
 URL: http://ldb.samba.org/
-Source: http://samba.org/ftp/ldb/ldb-%{version}.tar.gz
+Source0: https://www.samba.org/ftp/ldb/ldb-%{version}.tar.gz
+Source1: https://www.samba.org/ftp/ldb/ldb-%{version}.tar.asc
+# gpg2 --no-default-keyring --keyring ./ldb.keyring --recv-keys 9147A339719518EE9011BCB54793916113084025
+Source2: ldb.keyring
+
+# Patches
+Patch0001: 0001-PATCH-wafsamba-Fix-few-SyntaxWarnings-caused-by-regu.patch
+# Fix FTBFS / Increase the over-estimation for sparse files
+Patch0002: 1420.patch
 
 BuildRequires: gcc
 BuildRequires: libtalloc-devel >= %{talloc_version}
 BuildRequires: libtdb-devel >= %{tdb_version}
 BuildRequires: libtevent-devel >= %{tevent_version}
-
-%if ! 0%{?rhel}
+%if %{with lmdb}
 BuildRequires: lmdb-devel >= 0.9.16
 %endif
-
 BuildRequires: popt-devel
 BuildRequires: libxslt
 BuildRequires: docbook-style-xsl
+%if %{with python3}
+BuildRequires: python3-devel
+BuildRequires: python3-tdb
+BuildRequires: python3-talloc-devel
+BuildRequires: python3-tevent
+#endif with python
+%endif
 BuildRequires: doxygen
 BuildRequires: openldap-devel
 BuildRequires: libcmocka-devel
+BuildRequires: gnupg2
 
 Provides: bundled(libreplace)
 
-BuildRequires: python3-devel
-BuildRequires: python3-tdb
-BuildRequires: python3-talloc-devel
-BuildRequires: python3-tevent
-
 Obsoletes: python2-ldb < %{version}-%{release}
 Obsoletes: python2-ldb-devel < %{version}-%{release}
 Obsoletes: python2-ldb-debuginfo < %{version}-%{release}
 
-# Patches
-
-Patch0001: CVE-2020-10730.patch
-
 %description
 An extensible library that implements an LDAP like API to access remote LDAP
 servers, or use local tdb databases.
@@ -66,6 +93,7 @@ Requires: pkgconfig
 %description devel
 Header files needed to develop programs that link against the LDB library.
 
+%if %{with python3}
 %package -n python3-ldb
 Summary: Python bindings for the LDB library
 Requires: libldb%{?_isa} = %{version}-%{release}
@@ -85,41 +113,45 @@ Obsoletes: python-ldb-devel-common < %{version}-%{release}
 
 %description -n python3-ldb-devel
 Development files for the Python bindings for the LDB library
+#endif with python
+%endif
 
 %prep
-%autosetup -n ldb-%{version} -p3
+%autosetup -n ldb-%{version} -p1
 
 %build
+zcat %{SOURCE0} | gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} -
+
+# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1217376
+export python_LDFLAGS=""
+
 %configure --disable-rpath \
            --disable-rpath-install \
            --bundled-libraries=NONE \
            --builtin-libraries=replace \
            --with-modulesdir=%{_libdir}/ldb/modules \
+%if %{without lmdb}
            --without-ldb-lmdb \
+%endif
            --with-privatelibdir=%{_libdir}/ldb
 
-make %{?_smp_mflags} V=1
+%make_build
 doxygen Doxyfile
 
+%if %{with lmdb}
 %check
-# jhrozek 2019-05-03: Looks like ldb test suite does not work
-# when ldb is compiled --without-ldb-lmdb
-# make %{?_smp_mflags} check
+make %{?_smp_mflags} check
+#endif with lmdb
+%endif
 
 %install
-make install DESTDIR=$RPM_BUILD_ROOT
-
-rm -f $RPM_BUILD_ROOT%{_libdir}/libldb.a
-
-# Shared libraries need to be marked executable for
-# rpmbuild to strip them and include them in debuginfo
-find $RPM_BUILD_ROOT -name "*.so*" -exec chmod -c +x {} \;
+%make_install
 
 # Install API docs
 cp -a apidocs/man/* $RPM_BUILD_ROOT/%{_mandir}
 
-# LDB 1.1.8+ bug: remove manpage named after full
-# file path
+# bug: remove manpage named after full file path
+# not needed with el8+ and fc28+
 rm -f $RPM_BUILD_ROOT/%{_mandir}/man3/_*
 
 %ldconfig_scriptlets
@@ -130,8 +162,7 @@ rm -f $RPM_BUILD_ROOT/%{_mandir}/man3/_*
 %{_libdir}/ldb/libldb-key-value.so
 %{_libdir}/ldb/libldb-tdb-err-map.so
 %{_libdir}/ldb/libldb-tdb-int.so
-# lmdb is not supported on 32 bit architectures
-%if 0%{?__isa_bits} == 64 && ! 0%{?rhel}
+%if %{with lmdb}
 %{_libdir}/ldb/libldb-mdb-int.so
 %endif
 %dir %{_libdir}/ldb/modules
@@ -165,9 +196,10 @@ rm -f $RPM_BUILD_ROOT/%{_mandir}/man3/_*
 %{_mandir}/man3/ldb*.gz
 %{_mandir}/man3/ldif*.gz
 
+%if %{with python3}
 %files -n python3-ldb
 %{python3_sitearch}/ldb.cpython-*.so
-%{_libdir}/libpyldb-util.cpython-*.so.*
+%{_libdir}/libpyldb-util.cpython-*.so.2*
 %{python3_sitearch}/_ldb_text.py
 %{python3_sitearch}/__pycache__/_ldb_text.cpython-*.py*
 
@@ -178,8 +210,14 @@ rm -f $RPM_BUILD_ROOT/%{_mandir}/man3/_*
 %{_mandir}/man*/Py*.gz
 
 %ldconfig_scriptlets -n python3-ldb
+#endif with python
+%endif
 
 %changelog
+* Mon Nov 9 2020 Isaac Boukris <iboukris@redhat.com> - 2.2.0-1
+- Resolves: rhbz#1878114 - Rebase libldb to the version required by Samba
+- Resolves: rhbz#1794349 - Build libldb with lmdb support
+
 * Wed Jun 24 2020 Isaac Boukris <iboukris@redhat.com> - 2.1.3-2
 - Resolves: rhbz#1849615 - Fix CVE-2020-10730 use-after-free