File openldap-ms.spec of Package openldap-ms

#
# spec file for package openldap-ms
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates
%endif

%define _prefix /opt/%{name}
%define _sysconfdir %{_prefix}/etc


%define run_test_suite 0
%define version_main 2.4.59

%define pkg_version %{version_main}

%if %{suse_version} >= 1310 && %{suse_version} != 1315
%define  _rundir /run/slapd
%else
%define  _rundir /var/run/slapd
%endif

Name:           openldap-ms
Summary:        An open source implementation of the Lightweight Directory Access Protocol
License:        OLDAP-2.8
Version:        %{version_main}
Release:        0
Url:            https://www.openldap.org
Source:         https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-%{pkg_version}.tgz
Source99:       openldap-ms-rpmlintrc
Patch1:         0001-ITS-8866-slapo-unique-to-return-filter-used-in-diagn.patch
Patch3:         0003-LDAPI-socket-location.dif
Patch5:         0005-pie-compile.dif
Patch11:        0011-openldap-re24-its7796.patch
Patch12:        0012-openldap-re24-its9608.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  cyrus-sasl-devel
BuildRequires:  groff
BuildRequires:  libopenssl-devel
BuildRequires:  libsodium-devel
BuildRequires:  libtool
BuildRequires:  pkgconfig(krb5)
BuildRequires:  pkgconfig(systemd)
Recommends:     cyrus-sasl
PreReq:         %fillup_prereq /usr/sbin/useradd /usr/sbin/groupadd /usr/bin/grep

%description
OpenLDAP is a client and server reference implementation of the
Lightweight Directory Access Protocol v3 (LDAPv3).

The server provides several database backends and overlays.

%package back-sock
Summary:        OpenLDAP Socket Back-End
Requires:       openldap-ms = %{version_main}

%description back-sock
The OpenLDAP socket back-end allows you to handle LDAP requests and
results with an external process listening on a Unix domain socket.

%package back-meta
Summary:        OpenLDAP Meta Back-End
Requires:       openldap-ms = %{version_main}

%description back-meta
The OpenLDAP Meta back-end is able to perform basic LDAP proxying with
respect to a set of remote LDAP servers. The information contained in
these servers can be presented as belonging to a single Directory
Information Tree (DIT).

%package contrib
Summary:        OpenLDAP Contrib Modules
Requires:       openldap-ms = %{version_main}
Requires:       libsodium23

%description contrib
Various overlays found in contrib/:
allowed       Generates attributes indicating access rights
autogroup
lastbind      writes last bind timestamp to entry
noopsrch      handles no-op search control
pw-argon2     generates/validates Argon2 password hashes
pw-sha2       generates/validates SHA-2 password hashes
pw-pbkdf2     generates/validates PBKDF2 password hashes
smbk5pwd      generates Samba3 password hashes (heimdal krb disabled)
trace         traces overlay invocation

%package doc
Summary:        OpenLDAP Documentation
%if 0%{?suse_version} > 1110
BuildArch:      noarch
%endif

%description doc
The OpenLDAP Admin Guide plus a set of OpenLDAP related IETF internet drafts.

%package devel
Summary:        Libraries, Header Files and Documentation for OpenLDAP
# bug437293
%ifarch ppc64
Obsoletes:      openldap-ms-devel-64bit
%endif
#
Conflicts:      openldap-devel
Recommends:     cyrus-sasl-devel

%description devel
This package provides the OpenLDAP libraries, header files, and
documentation.

%package devel-static
Summary:        Static libraries for the OpenLDAP libraries
Requires:       cyrus-sasl-devel
Requires:       libopenssl-devel
Requires:       openldap-ms-devel = %version

%description devel-static
This package provides the static versions of the OpenLDAP libraries
for development.

%prep
# Unpack and patch OpenLDAP 2.4
%setup -q -n openldap-%{version_main}
%patch1 -p1
%patch3 -p1
%patch5 -p1
%patch11 -p1
%patch12 -p1

%build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
export CFLAGS="%{optflags} -Wno-format-extra-args -fno-strict-aliasing -DNDEBUG -DSLAP_SCHEMA_EXPOSE -DLDAP_COLLECTIVE_ATTRIBUTES"
export STRIP=""
%configure \
        --prefix=%{_prefix} \
        --sysconfdir=%{_sysconfdir} \
        --libdir=%{_libdir} \
        --libexecdir=%{_libdir} \
        --localstatedir=%{_rundir} \
        --enable-wrappers=no \
        --enable-spasswd \
        --enable-modules \
        --enable-shared \
        --enable-dynamic \
        --with-tls=openssl \
        --with-cyrus-sasl \
        --enable-crypt \
        --enable-ipv6=yes \
        --enable-aci \
        --disable-bdb \
        --disable-hdb \
        --enable-rewrite \
        --enable-ldap=mod \
        --enable-meta=mod \
        --enable-monitor=mod \
        --disable-perl \
        --enable-sock=mod \
        --disable-sql \
        --enable-mdb=mod \
        --enable-relay=mod \
        --disable-slp \
        --enable-overlays=mod \
        --enable-syncprov=mod \
        --enable-ppolicy=mod \
        --disable-lmpasswd \
        --with-yielding-select \
  || cat config.log
make depend
# -B required to make every build give the same result - maybe from bad build deps in Makefiles?
make -B %{?_smp_mflags}
# Build selected contrib overlays
for SLAPO_NAME in allowed autogroup lastbind noopsrch passwd/pbkdf2 passwd/sha2 trace
do
  make -B -C contrib/slapd-modules/${SLAPO_NAME} %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}"
done
# slapd-pw-argon2
make -B -C contrib/slapd-modules/passwd/argon2 %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" DEFS="-DSLAPD_ARGON2_USE_SODIUM"
# slapo-smbk5pwd only for Samba password hashes
make -B -C contrib/slapd-modules/smbk5pwd %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" DEFS="-DDO_SAMBA" HEIMDAL_LIB=""

%check
%if %run_test_suite
# calculate the base port to be use in the test-suite
SLAPD_BASEPORT=10000
if [ -f /.buildenv ] ; then
    . /.buildenv
    SLAPD_BASEPORT=$(($SLAPD_BASEPORT + ${BUILD_INCARNATION:-0} * 10))
fi
export SLAPD_BASEPORT
%ifnarch %arm alpha
rm -f tests/scripts/test019-syncreplication-cascade
rm -f tests/scripts/test022-ppolicy
rm -f tests/scripts/test023-refint
rm -f tests/scripts/test033-glue-syncrepl
#rm -f tests/scripts/test036-meta-concurrency
#rm -f tests/scripts/test039-glue-ldap-concurrency
rm -f tests/scripts/test043-delta-syncrepl
#rm -f tests/scripts/test045-syncreplication-proxied
rm -f tests/scripts/test048-syncrepl-multiproxy
rm -f tests/scripts/test050-syncrepl-multimaster
rm -f tests/scripts/test058-syncrepl-asymmetric
make SLAPD_DEBUG=0 test
%endif
%endif

%install
echo "buildroot = %{buildroot}"
echo "_prefix = %{_prefix}"
echo "_sysconfdir = %{_sysconfdir}"
echo "_bindir = %{_bindir}"
echo "_sbindir = %{_sbindir}"
echo "_libdir = %{_libdir}"
echo "_unitdir = %{_unitdir}"
echo "_mandir = %{_mandir}"
mkdir -p %{buildroot}%{_libdir}/openldap
mkdir -p %{buildroot}%{_prefix}/lib/openldap
mkdir -p %{buildroot}%{_prefix}/sbin
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_prefix}/share/licenses/%{name}
make STRIP="" DESTDIR="%{buildroot}" "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" install
# Additional symbolic link to slapd executable
ln -s %{_libdir}/slapd %{buildroot}%{_prefix}/sbin/slapd
# Install selected contrib overlays
for SLAPO_NAME in allowed autogroup lastbind noopsrch passwd/argon2 passwd/pbkdf2 passwd/sha2 trace smbk5pwd
do
  make -C contrib/slapd-modules/${SLAPO_NAME} STRIP="" DESTDIR="%{buildroot}" "mandir=%{_mandir}" "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" install
done
mkdir -p %{buildroot}%{_sysconfdir}/openldap/slapd.d
mkdir -p %{buildroot}%{_sysconfdir}/sasl2
install -m 755 -d %{buildroot}/var/lib/ldap
chmod a+x %{buildroot}%{_libdir}/liblber.so*
chmod a+x %{buildroot}%{_libdir}/libldap_r.so*
rm %{buildroot}%{_mandir}/man5/slapd-perl.*
rm %{buildroot}%{_mandir}/man5/slapd-sql.*

mkdir -p %{buildroot}%{_fillupdir}
# remove unneeded admin guide files
find doc/guide '(' ! -name *.html -a ! -name *.gif -a ! -name *.png -a ! -type d ')' -delete
rm -rf doc/guide/release

%define DOCDIR %{_prefix}/share/doc/%{name}
echo "DOCDIR = %{DOCDIR}"
install -d %{buildroot}%{DOCDIR}/adminguide \
           %{buildroot}%{DOCDIR}/images \
           %{buildroot}%{DOCDIR}/drafts
install -m 644 doc/guide/admin/* %{buildroot}%{DOCDIR}/adminguide
install -m 644 doc/guide/images/*.gif %{buildroot}%{DOCDIR}/images
install -m 644 doc/drafts/* %{buildroot}%{DOCDIR}/drafts
install -m 644 ANNOUNCEMENT \
               COPYRIGHT \
               README \
               CHANGES \
               %{buildroot}%{DOCDIR}
install -m 644 servers/slapd/slapd.ldif \
               %{buildroot}%{DOCDIR}/slapd.ldif.default
rm -f %{buildroot}%{_sysconfdir}/openldap/schema/README
rm -f %{buildroot}%{_sysconfdir}/openldap/slapd.ldif*

rm -f %{buildroot}%{_libdir}/openldap/*.a
rm -f %{buildroot}%{_mandir}/man5/slapd-bdb.5
rm -f %{buildroot}%{_mandir}/man5/slapd-hdb.5
rm -f %{buildroot}%{_mandir}/man5/slapd-dnssrv.5
rm -f %{buildroot}%{_mandir}/man5/slapd-ndb.5
rm -f %{buildroot}%{_mandir}/man5/slapd-null.5
rm -f %{buildroot}%{_mandir}/man5/slapd-passwd.5
rm -f %{buildroot}%{_mandir}/man5/slapd-shell.5
rm -f %{buildroot}%{_mandir}/man5/slapd-tcl.5
# Remove *.la files, libtool does not handle this correct
rm -f  %{buildroot}%{_libdir}/lib*.la

%pre

%post

%preun

%postun

%files
%defattr(-,root,root)
%config %{_sysconfdir}/openldap/schema/*.schema
%config %{_sysconfdir}/openldap/schema/*.ldif
%config(noreplace) %attr(640, root, ldap) %{_sysconfdir}/openldap/slapd.conf
%config %attr(640, root, ldap) %{_sysconfdir}/openldap/slapd.conf.default
%dir %{_prefix}
%dir %{_prefix}/include
%dir %{_prefix}/bin
%dir %{_prefix}/sbin
%dir %{_prefix}/lib
%dir %{_prefix}/share
%dir %{_prefix}/share/licenses
%dir %{_prefix}/share/licenses/%{name}
%dir %{_prefix}/share/doc
%dir %{_libdir}
%dir %{_libdir}/openldap
%dir %{_sysconfdir}
%dir %{_sysconfdir}/openldap
%dir %attr(0770, ldap, ldap) %{_sysconfdir}/openldap/slapd.d
%dir %{_sysconfdir}/openldap/schema
%{_sbindir}/slap*
%{_libdir}/openldap/back_ldap*
%{_libdir}/openldap/back_mdb*
%{_libdir}/openldap/back_monitor*
%{_libdir}/openldap/back_relay*
%{_libdir}/openldap/accesslog*
%{_libdir}/openldap/auditlog*
%{_libdir}/openldap/collect*
%{_libdir}/openldap/constraint*
%{_libdir}/openldap/dds*
%{_libdir}/openldap/deref*
%{_libdir}/openldap/dyngroup*
%{_libdir}/openldap/dynlist*
%{_libdir}/openldap/memberof*
%{_libdir}/openldap/pcache*
%{_libdir}/openldap/ppolicy-2.4.*
%{_libdir}/openldap/ppolicy.*
%{_libdir}/openldap/refint*
%{_libdir}/openldap/retcode*
%{_libdir}/openldap/rwm*
%{_libdir}/openldap/seqmod*
%{_libdir}/openldap/sssvlv*
%{_libdir}/openldap/syncprov*
%{_libdir}/openldap/translucent*
%{_libdir}/openldap/unique*
%{_libdir}/openldap/valsort*
%{_libdir}/slapd
%dir %attr(0750, ldap, ldap) %{_sharedstatedir}/ldap
%ghost %attr(0750, ldap, ldap) %{_rundir}
%dir %{_mandir}
%dir %{_mandir}/man1
%dir %{_mandir}/man3
%dir %{_mandir}/man5
%dir %{_mandir}/man8
%doc %{_mandir}/man8/sl*
%doc %{_mandir}/man5/slapd.*
%doc %{_mandir}/man5/slapd-config.*
%doc %{_mandir}/man5/slapd-ldap.*
%doc %{_mandir}/man5/slapd-ldif.*
%doc %{_mandir}/man5/slapd-mdb.*
%doc %{_mandir}/man5/slapd-monitor.*
%doc %{_mandir}/man5/slapd-relay.*
%doc %{_mandir}/man5/slapo-*
%dir %{DOCDIR}
%doc %{DOCDIR}/ANNOUNCEMENT
%doc %{DOCDIR}/COPYRIGHT
%license LICENSE
%doc %{DOCDIR}/README*
%doc %{DOCDIR}/CHANGES
%doc %{DOCDIR}/slapd.ldif.default
%doc %{_mandir}/man1/ldap*
%doc %{_mandir}/man5/ldif.*
%dir %{_sysconfdir}/openldap
%{_prefix}/bin/ldapadd
%{_prefix}/bin/ldapcompare
%{_prefix}/bin/ldapdelete
%{_prefix}/bin/ldapexop
%{_prefix}/bin/ldapmodify
%{_prefix}/bin/ldapmodrdn
%{_prefix}/bin/ldapsearch
%{_prefix}/bin/ldappasswd
%{_prefix}/bin/ldapurl
%{_prefix}/bin/ldapwhoami
%config(noreplace) %{_sysconfdir}/openldap/ldap.conf
%doc %{_mandir}/man5/ldap.conf*
%{_sysconfdir}/openldap/ldap.conf.default
%{_libdir}/liblber*2.4.so.*
%{_libdir}/libldap*2.4.so.*

%files back-sock
%defattr(-,root,root)
%{_libdir}/openldap/back_sock*
%doc %{_mandir}/man5/slapd-sock.*

%files back-meta
%defattr(-,root,root)
%{_libdir}/openldap/back_meta*
%doc %{_mandir}/man5/slapd-meta.*

%files doc
%defattr(-,root,root)
%dir %{DOCDIR}
%doc %{DOCDIR}/drafts
%doc %{DOCDIR}/adminguide
%doc %{DOCDIR}/images

%files contrib
%defattr(-,root,root)
%{_libdir}/openldap/allowed.*
%{_libdir}/openldap/autogroup.*
%{_libdir}/openldap/lastbind.*
%{_libdir}/openldap/noopsrch.*
%{_libdir}/openldap/pw-argon2.*
%{_libdir}/openldap/pw-sha2.*
%{_libdir}/openldap/pw-pbkdf2.*
%{_libdir}/openldap/smbk5pwd.*
%{_libdir}/openldap/trace.*
%doc %{_mandir}/man5/slapd-pw-argon2.*

%files devel
%defattr(-,root,root)
%doc %{_mandir}/man3/ber*
%doc %{_mandir}/man3/lber*
%doc %{_mandir}/man3/ld_errno*
%doc %{_mandir}/man3/ldap*
%{_includedir}/*.h
%{_libdir}/liblber.so
%{_libdir}/libldap*.so

%files devel-static
%defattr(-,root,root)
%_libdir/liblber.a
%_libdir/libldap*.a

%changelog
openSUSE Build Service is sponsored by