File ldb.spec of Package ldb

#
# spec file for package ldb
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{!?py3_soflags:  %global py3_soflags cpython-%{python3_version_nodots}m}
%{!?py3_soflags_dash:   %global py3_soflags_dash %(echo %{py3_soflags} | sed "s/_/-/g")}

%global with_lmdb 0
%if 0%{?suse_version} > 1320
%ifarch x86_64
%global with_lmdb 1
%endif
%endif

%define lmdb_version 0.9.16
%define talloc_version 2.4.2
%define tdb_version 1.4.10
%define tevent_version 0.16.1

Name:           ldb
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  doxygen
%if 0%{?suse_version} > 1500
%ifnarch ppc
BuildRequires:  libcmocka-devel >= 1.1.3
%endif
%endif
BuildRequires:  libtalloc-devel >= %{talloc_version}
BuildRequires:  libtdb-devel >= %{tdb_version}
BuildRequires:  libtevent-devel >= %{tevent_version}
BuildRequires:  libxslt
BuildRequires:  popt-devel
BuildRequires:  python3-devel
BuildRequires:  python3-talloc >= %{talloc_version}
BuildRequires:  python3-talloc-devel >= %{talloc_version}
BuildRequires:  python3-tdb >= %{tdb_version}
BuildRequires:  python3-tevent >= %{tevent_version}

BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  libgnutls-devel >= 3.4.7
BuildRequires:  lmdb-devel
BuildRequires:  perl-JSON
BuildRequires:  perl-Parse-Yapp

%if 0%{?suse_version} >= 1330
BuildRequires:  libtirpc-devel
%endif
%if %{with_lmdb}
BuildRequires:  lmdb-devel >= %{lmdb_version}
%endif

URL:            https://ldb.samba.org/
Version:        4.21.0+git.355.05b22217ac
Release:        0
Summary:        An LDAP-like embedded database
License:        LGPL-3.0-or-later
Group:          Development/Libraries/C and C++
Source:         samba-%{version}.tar.bz2
Patch0:         ldb-python3.5-fix-soabi_name.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
LDB is an LDAP-like embedded database.

%package -n libldb2
Summary:        An LDAP-like embedded database
Group:          System/Libraries
Obsoletes:      libldb1 < %{version}
Conflicts:      python3-ldb <= %{version}
Conflicts:      python3-ldb-devel <= %{version}

%description -n libldb2
LDB is an LDAP-like

This package includes the ldb2 library.

%package -n libldb-devel
Summary:        Libraries and Header Files to Develop Programs with ldb2 Support
Group:          Development/Libraries/C and C++
Requires:       libldb2 = %{version}
Requires:       pkg-config

%description -n libldb-devel
LDB is an LDAP-like embedded database.

Libraries and Header Files to Develop Programs with ldb2 Support.

%package -n ldb-tools
Summary:        Tools to manipulate LDB files
Group:          Development/Libraries/C and C++

%description -n ldb-tools
Tools to manipulate LDB files.

%prep
%setup -n samba-%{version} -q
%autopatch -p1

%build
%if 0%{?suse_version} > 1110
	export SUSE_ASNEEDED=0
%endif
export CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -DIDMAP_RID_SUPPORT_TRUSTED_DOMAINS"
%define bundled_libs cmocka
%if 0%{?suse_version} > 1500
%ifnarch ppc
	%define bundled_libs NONE
%endif
%endif

export CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -DIDMAP_RID_SUPPORT_TRUSTED_DOMAINS"
CONFIGURE_OPTIONS="\
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--disable-rpath \
	--disable-rpath-install \
	--disable-silent-rules \
	--with-modulesdir=%{_libdir}/ldb2/modules \
	--with-privatelibdir=%{_libdir}/ldb2 \
	--bundled-libraries=%{bundled_libs} \
	--enable-fhs \
	--libexecdir=%{_libdir} \
        --without-ad-dc \
        --without-ads \
        --without-json \
        --without-gpgme \
	--private-libraries='!ldb' \
	--without-ldap \
	--without-libarchive \
	--without-acl-support \
	--without-pam \
	--with-shared-modules='!vfs_recycle,!vfs_audit,!vfs_extd_audit,!vfs_full_audit,!vfs_fake_perms,!vfs_default_quota,!vfs_readonly,!vfs_cap,!vfs_expand_msdfs,!vfs_shadow_copy,!vfs_shadow_copy2,!vfs_readahead,!vfs_xattr_tdb,!vfs_streams_xattr,!vfs_streams_depot,!vfs_acl_xattr,!vfs_acl_tdb,!vfs_preopen,!vfs_catia,!vfs_media_harmony,!vfs_unityed_media,!vfs_fruit,!vfs_shell_snap,!vfs_commit,!vfs_worm,!vfs_crossrename,!vfs_linux_xfs_sgid,!vfs_time_audit,!vfs_offline,!vfs_virusfilter,!vfs_widelinks,!vfs_snapper,!vfs_syncops,!vfs_dirsort,!vfs_fileid,!vfs_aio_fork,!vfs_aio_pthread,!vfs_gpfs,!vfs_btrfs,!vfs_glusterfs_fuse'
%if !%{with_lmdb}
	--without-ldb-lmdb \
%endif
"
./configure ${CONFIGURE_OPTIONS}
make %{?_smp_mflags} \
	all

# remove man page with bogus full build dir in path
#rm -f apidocs/man/man3/_*_ldb-%{version}_include_.3
#rm -f apidocs/man/man3/PyLdb*.3

%check
%if %{with_lmdb}
LD_LIBRARY_PATH="bin/shared:bin/shared/private" \
LDB_MODULES_PATH="bin/modules" \
#make test
%endif

%install
%make_install

# Install API documentation
#cp -a apidocs/man/* %{buildroot}/%{_mandir}
mv %{buildroot}/%{_libdir}/ldb2/modules/ldb %{buildroot}
find '%{buildroot}/%{_libdir}' ! -iname "*ldb*" -type f,l -exec rm {} \;
find '%{buildroot}/%{_includedir}' ! -iname "*ldb*" -type f,l -exec rm {} \;
find '%{buildroot}/%{_bindir}' ! -iname "*ldb*" -type f,l -exec rm {} \;
find '%{buildroot}/%{_sbindir}' ! -iname "*ldb*" -type f,l -exec rm {} \;
find '%{buildroot}/%{_mandir}' ! -iname "*ldb*" -type f,l -exec rm {} \;
mv %{buildroot}/ldb %{buildroot}/%{_libdir}/ldb2/modules

# don't deliver python files an no python package (but needed for test)
rm %{buildroot}/%{_libdir}/ldb2/libpyldb-util.%{py3_soflags_dash}-private-samba.so
rm %{buildroot}/%{python3_sitearch}/_ldb_text.py
%if 0%{?centos_version} > 599 || 0%{?fedora_version} > 11 || 0%{?rhel_version} > 599
rm %{buildroot}/%{python3_sitearch}/__pycache__/_ldb_text.cpython-*.py[co]
%endif
rm %{buildroot}/%{python3_sitearch}/ldb.%{py3_soflags}.so
rm %{buildroot}/%{python3_sitearch}/samba/_ldb.%{py3_soflags}.so
#rm %{buildroot}/%{python3_sitearch}/ldb.%{py3_soflags_dash}.so
#rm %{buildroot}/%{_includedir}/pyldb.h
#rm %{buildroot}/%{_libdir}/ldb2/libpyldb-util.%{py3_soflags}.so
#rm %{buildroot}/%{_libdir}/pkgconfig/pyldb-util.%{py3_soflags}.pc

# do we need these ???
rm %{buildroot}/%{_libdir}/ldb2/modules/ldb/ildap.so
rm %{buildroot}/%{_libdir}/ldb2/modules/ldb/ldbsamba_extensions.so
rm %{buildroot}/%{_libdir}/ldb2/libldbsamba-private-samba.so

%post -n libldb2 -p /sbin/ldconfig

%postun -n libldb2 -p /sbin/ldconfig

%files -n libldb2
%defattr(-,root,root)
%{_libdir}/libldb.so.2*
%dir %{_libdir}/ldb2
%{_libdir}/ldb2/libldb-key-value-private-samba.so
%{_libdir}/ldb2/libldb-tdb-err-map-private-samba.so
%{_libdir}/ldb2/libldb-tdb-int-private-samba.so
%dir %{_libdir}/ldb2/modules
%dir %{_libdir}/ldb2/modules/ldb
%{_libdir}/ldb2/modules/ldb/asq.so
%{_libdir}/ldb2/modules/ldb/paged_searches.so
%{_libdir}/ldb2/modules/ldb/rdn_name.so
%{_libdir}/ldb2/modules/ldb/sample.so
%{_libdir}/ldb2/modules/ldb/server_sort.so
%{_libdir}/ldb2/modules/ldb/skel.so
%{_libdir}/ldb2/modules/ldb/tdb.so
%{_libdir}/ldb2/modules/ldb/ldb.so
%if 0%{?suse_version} <= 1500
%{_libdir}/ldb2/libcmocka-ldb.so
%endif
%ifarch ppc
%{_libdir}/ldb2/libcmocka-ldb.so
%endif
#%if %{with_lmdb}
#%{_libdir}/ldb2/libldb-mdb-int.so
#%{_libdir}/ldb2/modules/ldb/mdb.so
#%endif

%files -n libldb-devel
%defattr(-,root,root)
%dir %{_includedir}/samba-4.0
%{_includedir}/samba-4.0/ldb_wrap.h
%{_includedir}/samba-4.0/util_ldb.h
%{_includedir}/samba-4.0/ldb.h
%{_includedir}/samba-4.0/ldb_errors.h
%{_includedir}/samba-4.0/ldb_handlers.h
%{_includedir}/samba-4.0/ldb_module.h
%{_includedir}/samba-4.0/ldb_version.h
%{_libdir}/libldb.so
%{_libdir}/pkgconfig/ldb.pc
%{_mandir}/man3/ldb*.3.*
#%{_mandir}/man3/ldif*.3.*

%files -n ldb-tools
%defattr(-,root,root)
%{_bindir}/ldbadd
%{_bindir}/ldbdel
%{_bindir}/ldbedit
%{_bindir}/ldbmodify
%{_bindir}/ldbrename
%{_bindir}/ldbsearch
%{_libdir}/ldb2/libldb-cmdline-private-samba.so
%{_mandir}/man1/ldbadd.1.*
%{_mandir}/man1/ldbdel.1.*
%{_mandir}/man1/ldbedit.1.*
%{_mandir}/man1/ldbmodify.1.*
%{_mandir}/man1/ldbrename.1.*
%{_mandir}/man1/ldbsearch.1.*

%changelog
openSUSE Build Service is sponsored by