File reopenldap.spec of Package reopenldap

%define realname reopenldap
%define srcext   tar.bz2

%define api_ver  1_2
%define lib_ver  1.2
%define so_ver   13

%define ldap_data_dir %{_localstatedir}/lib/reopenldap-data

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# turn off annotated build
%undefine _annotated_build
%undefine _hardened_build

%if ! %{defined _fillupdir}
%global _fillupdir /var/adm/fillup-templates
%endif

%if ! %{defined _rundir}
%define _rundir /var/run
%endif

# Common info
Name:          %{realname}
Version:       1.1.3
Release:       wiz%{?extraver:0.}1%{?dist}
License:       AGPL-3.0
Group:         Productivity/Networking/LDAP/Servers
URL:           https://gitflic.ru/project/erthink/reopenldap
Summary:       Telco-oriented fork of well-known OpenLDAP project

# Install-time parameters
Conflicts:     openldap2

# Packages needed to define _unitdir
%if 0%{?suse_version} >= 1230
BuildRequires: systemd-rpm-macros
Requires:      systemd
%endif
%if 0%{?rhel} >= 7
BuildRequires: systemd
Requires:      systemd
%endif

# Build-time parameters
BuildRequires: autoconf automake libtool
BuildRequires: pkg-config
BuildRequires: pkgconfig(krb5) pkgconfig(krb5-gssapi)
BuildRequires: pkgconfig(libsodium) >= 1.0.9
BuildRequires: perl(ExtUtils::Embed)
BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(openssl)
BuildRequires: unixODBC-devel
BuildRequires: cyrus-sasl-devel
BuildRequires: groff
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       %{realname}-%{version}%{?extraver}.%{srcext}
Source11:      slapd.service
Source12:      slapd.sysconfig
Source13:      slapd.tmpfiles.conf

%description
ReOpenLDAP, also known as "TelcoLDAP" - is the telco-oriented fork of well-known
OpenLDAP project with a lot of heisenbugs fixing and addition of a few new
features, mostly for highload and multi-master clustering with a hot replication.

# Library
%package -n libreldap-%{api_ver}-%{so_ver}
Group:         Productivity/Networking/LDAP/Clients
Summary:       ReOpenLDAP Client Libraries
Provides:      libreldap%{so_ver} = %{version}-%{release}
Provides:      libreldap = %{version}-%{release}

%description -n libreldap-%{api_ver}-%{so_ver}
ReOpenLDAP, also known as "TelcoLDAP" - is the telco-oriented fork of well-known
OpenLDAP project with a lot of heisenbugs fixing and addition of a few new
features, mostly for highload and multi-master clustering with a hot replication.

This package contains the ReOpenLDAP client libraries.

# SLAPI
%package -n libreslapi-%{api_ver}-%{so_ver}
Group:         Productivity/Networking/LDAP/Clients
Summary:       Plugin API for ReOpenLDAP
Provides:      libreslapi%{so_ver} = %{version}-%{release}
Provides:      libreslapi = %{version}-%{release}

%description -n libreslapi-%{api_ver}-%{so_ver}
ReOpenLDAP, also known as "TelcoLDAP" - is the telco-oriented fork of well-known
OpenLDAP project with a lot of heisenbugs fixing and addition of a few new
features, mostly for highload and multi-master clustering with a hot replication.

This package contains plugin API for the ReOpenLDAP.

# Client
%package client
Group:         Productivity/Networking/LDAP/Clients
Summary:       The ReOpenLDAP commandline client tools
Conflicts:     openldap2-client

%description client
ReOpenLDAP, also known as "TelcoLDAP" - is the telco-oriented fork of well-known
OpenLDAP project with a lot of heisenbugs fixing and addition of a few new
features, mostly for highload and multi-master clustering with a hot replication.

This package contains the ReOpenLDAP client utilities.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      libreldap-%{api_ver}-%{so_ver} = %{version}-%{release}

%description devel
Development files for %{name}

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}
if [ ! -x configure ]; then
  sed -ri '/AC_PREREQ/ s/[0-9.]+/2.69/' configure.ac
  autoreconf -i
fi

%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
%if 0%{?rhel} >= 8
_CFLAGS+=' -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/8/plugin -fplugin=annobin -fplugin-arg-annobin-disable'
%endif
%configure \
 --sysconfdir=%{_sysconfdir}/reopenldap \
 --localstatedir=%{_localstatedir}/lib \
 --disable-maintainer-mode \
 --disable-static \
 \
 --enable-syslog \
 --enable-contrib \
 \
 --enable-dynacl \
 --enable-aci \
 --enable-lmpasswd \
 --enable-spasswd \
 --enable-slapi \
 \
 --enable-mdb=mod \
 --enable-ldap=mod \
 --enable-meta=mod \
 --enable-monitor=mod \
 --enable-perl=mod \
 --enable-relay=mod \
 --enable-sql=mod \
 \
 --enable-overlays=mod \
 \
 CPPFLAGS="-DLDAPI_SOCK=\\\"%{_rundir}/ldapi\\\" -DLDAP_DATADIR=\\\"%{ldap_data_dir}\\\"" \
 CFLAGS="$_CFLAGS" \
 CXXFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS"
%{__make} V=1 %{?_smp_mflags}
# KRB5_CFLAGS="$(/usr/bin/krb5-config --cflags krb5)" \
# KRB5_LIBS="$(/usr/bin/krb5-config --libs krb5)"

%install
# Install
%{__make} install DESTDIR=%{buildroot}
%{__install} -d -m755 %{buildroot}%{_sysconfdir}/reopenldap/slapd.d
%{__install} -d -m755 %{buildroot}%{ldap_data_dir}
%{__mv} %{buildroot}%{_libdir}/reopenldap/lib* %{buildroot}%{_libdir}/
%{__ln_s} -f ldapmodify %{buildroot}%{_bindir}/ldapadd
%if 0%{?_unitdir:1}
%{__install} -D -m644 %{S:11} %{buildroot}%{_unitdir}/slapd.service
%{__install} -D -m644 %{S:13} %{buildroot}%{_tmpfilesdir}/slapd.conf
%else
%{__install} -d -m755 %{buildroot}/var/run/ldapi
%endif
%if 0%{?suse_version}
%{__install} -D -m644 %{S:12} %{buildroot}%{_fillupdir}/sysconfig.slapd
%else
%{__install} -D -m644 %{S:12} %{buildroot}%{_sysconfdir}/sysconfig/slapd
%endif

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc ANNOUNCEMENT.OpenLDAP CHANGES.OpenLDAP README.OpenLDAP
%doc AUTHORS COPYING COPYRIGHT LICENSE NEWS.md README.md
%doc doc/devel/toolargs
%dir %{_sysconfdir}/reopenldap/schema
%dir %attr(0700,ldap,ldap) %{_sysconfdir}/reopenldap/slapd.d
%dir %{_sysconfdir}/reopenldap
%config(noreplace) %{_sysconfdir}/reopenldap/schema/*
%config(noreplace) %{_sysconfdir}/reopenldap/slapd.conf
%config(noreplace) %{_sysconfdir}/reopenldap/slapd.ldif
%config(noreplace) %{_sysconfdir}/reopenldap/check_password.conf
%{_sbindir}/*
%{_bindir}/mdbx_*
%dir %{_libdir}/reopenldap
%{_libdir}/reopenldap/*
%if 0%{?_unitdir:1}
%{_unitdir}/slapd.service
%{_tmpfilesdir}/slapd.conf
%dir %ghost /run/ldapi
%else
%dir %attr(0755,ldap,ldap)/var/run/ldapi
%endif
%if 0%{?suse_version}
%{_fillupdir}/sysconfig.slapd
%else
%{_sysconfdir}/sysconfig/slapd
%endif
%exclude %{_libdir}/reopenldap/*.la
%dir %attr(0700,ldap,ldap) %{ldap_data_dir}
%doc %{_mandir}/man1/mdbx_*
%doc %{_mandir}/man5/slap*
%doc %{_mandir}/man8/*
%doc %{_mandir}/ru/man5/slap*
%doc %{_mandir}/ru/man8/*

# Library
%files -n libreldap-%{api_ver}-%{so_ver}
%defattr(-,root,root)
%doc ANNOUNCEMENT.OpenLDAP CHANGES.OpenLDAP README.OpenLDAP
%doc AUTHORS COPYING COPYRIGHT LICENSE NEWS.md README.md
%{_libdir}/libreldap-%{lib_ver}.so.%{so_ver}*

# SLAPI
%files -n libreslapi-%{api_ver}-%{so_ver}
%defattr(-,root,root)
%doc ANNOUNCEMENT.OpenLDAP CHANGES.OpenLDAP README.OpenLDAP
%doc AUTHORS COPYING COPYRIGHT LICENSE NEWS.md README.md
%{_libdir}/libreslapi-%{lib_ver}.so.%{so_ver}*

# Client
%files client
%defattr(-,root,root)
%doc ANNOUNCEMENT.OpenLDAP CHANGES.OpenLDAP README.OpenLDAP
%doc AUTHORS COPYING COPYRIGHT LICENSE NEWS.md README.md
%doc doc/devel/OIDs doc/devel/args doc/devel/toolargs
%dir %{_sysconfdir}/reopenldap
%config(noreplace) %{_sysconfdir}/reopenldap/ldap.conf
%{_bindir}/ldap*
%doc %{_mandir}/man1/ldap*
%doc %{_mandir}/ru/man1/ldap*
%doc %{_mandir}/man5/ldap.conf.5*
%doc %{_mandir}/man5/ldif.5*
%doc %{_mandir}/ru/man5/ldap.conf.5*
%doc %{_mandir}/ru/man5/ldif.5*

# Development stuff
%files devel
%defattr(-,root,root)
%doc AUTHORS COPYING COPYRIGHT LICENSE NEWS.md README.md
%dir %{_includedir}/%{name}/
%{_includedir}/%{name}/*.h
%{_libdir}/libreldap.so
%{_libdir}/libreslapi.so
%exclude %{_libdir}/libreldap.la
%exclude %{_libdir}/libreslapi.la
%doc %{_mandir}/man3/*

%post   -n libreldap-%{api_ver}-%{so_ver} -p /sbin/ldconfig
%postun -n libreldap-%{api_ver}-%{so_ver} -p /sbin/ldconfig

%post   -n libreslapi-%{api_ver}-%{so_ver} -p /sbin/ldconfig
%postun -n libreslapi-%{api_ver}-%{so_ver} -p /sbin/ldconfig

%pre
/usr/sbin/groupadd -r ldap &>/dev/null || :
/usr/sbin/useradd  -g ldap -s /bin/false -r -c "LDAP service user" -d %{ldap_data_dir} ldap &>/dev/null || :
%if 0%{?suse_version} && 0%{?_unitdir:1}
%{service_add_pre slapd.service}

%post
%{fillup_only -n slapd}
%{service_add_post slapd.service}
%{tmpfiles_create %{_tmpfilesdir}/slapd.conf}

%preun
%{service_del_preun slapd.service}

%postun
%{service_del_postun slapd.service}

%endif

%changelog
openSUSE Build Service is sponsored by