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

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

%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
%define  _rundir /var/run/slapd

Name:           openldap-ms
Summary:        An open source implementation of the Lightweight Directory Access Protocol
License:        OLDAP-2.8
Version:        %{version_main}
Release:        0
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

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
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

%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
Conflicts:      openldap-devel
Recommends:     cyrus-sasl-devel

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

%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.

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

%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
  make -B -C contrib/slapd-modules/${SLAPO_NAME} %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}"
# 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=""

%if %run_test_suite
# calculate the base port to be use in the test-suite
if [ -f /.buildenv ] ; then
    . /.buildenv
%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

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
  make -C contrib/slapd-modules/${SLAPO_NAME} STRIP="" DESTDIR="%{buildroot}" "mandir=%{_mandir}" "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" install
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}/*
chmod a+x %{buildroot}%{_libdir}/*
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 \
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 \
install -m 644 servers/slapd/slapd.ldif \
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





%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
%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}
%license LICENSE
%doc %{DOCDIR}/slapd.ldif.default
%doc %{_mandir}/man1/ldap*
%doc %{_mandir}/man5/ldif.*
%dir %{_sysconfdir}/openldap
%config(noreplace) %{_sysconfdir}/openldap/ldap.conf
%doc %{_mandir}/man5/ldap.conf*

%files back-sock
%doc %{_mandir}/man5/slapd-sock.*

%files back-meta
%doc %{_mandir}/man5/slapd-meta.*

%files doc
%dir %{DOCDIR}
%doc %{DOCDIR}/drafts
%doc %{DOCDIR}/adminguide
%doc %{DOCDIR}/images

%files contrib
%doc %{_mandir}/man5/slapd-pw-argon2.*

%files devel
%doc %{_mandir}/man3/ber*
%doc %{_mandir}/man3/lber*
%doc %{_mandir}/man3/ld_errno*
%doc %{_mandir}/man3/ldap*

%files devel-static

openSUSE Build Service is sponsored by