File openldap-ms.spec of Package openldap-ms

#
# spec file for package openldap-ms
#
# Copyright (c) 2022 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.6.4
%define pkg_version %{version_main}

%define  _rundir /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
URL:            https://www.openldap.org
Source0:        https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-%{pkg_version}.tgz
#Source1:        https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-%{pkg_version}.tgz.asc
Source2:        openldap-ms.keyring
Source99:       openldap-ms-rpmlintrc
Patch3:         0003-LDAPI-socket-location.dif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  argon2-devel
BuildRequires:  cyrus-sasl-devel
BuildRequires:  groff
BuildRequires:  libopenssl-devel
BuildRequires:  libtool
BuildRequires:  pkgconfig(krb5)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  systemd-devel
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}-%{release}

%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}-%{release}

%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 back-asyncmeta
Summary:        OpenLDAP Async Meta Back-End
Group:          Productivity/Networking/LDAP/Servers
Requires:       openldap-ms = %{version}-%{release}

%description back-asyncmeta
The new asynchronous OpenLDAP meta back-end.

%package contrib
Summary:        OpenLDAP Contrib Modules
Requires:       openldap-ms = %{version}-%{release}

%description contrib
Various overlays found in contrib/:
allowed       Generates attributes indicating access rights
autogroup
authzid       implements RFC 3829 support
datamorph     store enumerated values and fixed size integers
denyop        provides a quick'n'easy way to deny selected operations
lastbind      writes last bind timestamp to entry
noopsrch      handles no-op search control
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
variant       allows attributes/values to be shared between several entries
vc            implements the verify credentials extended operation

%package doc
Summary:        OpenLDAP Documentation
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
Requires:       cyrus-sasl-devel
Requires:       libopenssl-devel
Requires:       openldap-ms-devel = %{version}-%{release}

%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}-%{release}

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

%prep
%setup -q -n openldap-%{version_main}
%patch3 -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} \
        --runstatedir=%{_rundir}/slapd \
        --enable-wrappers=no \
        --enable-spasswd \
        --enable-modules \
        --enable-shared \
        --enable-dynamic \
        --with-tls=openssl \
        --with-cyrus-sasl \
        --enable-crypt \
        --enable-ipv6=yes \
        --enable-dynacl \
        --disable-aci \
        --enable-ldap=mod \
        --enable-meta=mod \
        --enable-monitor=mod \
        --enable-asyncmeta=mod \
        --disable-balancer \
        --disable-wt \
        --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-homedir \
        --with-yielding-select \
        --enable-argon2 \
        --with-argon2=libargon2 \
        --with-systemd \
  || 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 lmdb CLI tools
make -B -C libraries/liblmdb %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "bindir=%{_sbindir}" "includedir=%{_includedir}" "libdir=%{_libdir}" "libexecdir=%{_libdir}" "mandir=%{_mandir}"
# Build selected contrib overlays
for SLAPO_NAME in allowed autogroup authzid datamorph denyop lastbind noopsrch passwd/pbkdf2 passwd/sha2 trace variant vc
do
  make -B -C contrib/slapd-modules/${SLAPO_NAME} %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" "mandir=%{_mandir}"
done
# slapo-smbk5pwd only for Samba password hashes
make -B -C contrib/slapd-modules/smbk5pwd %{?_smp_mflags} "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" "mandir=%{_mandir}" 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 test
%endif
%endif

%install
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 lmdb CLI tools
make -B -C libraries/liblmdb %{?_smp_mflags} STRIP="" DESTDIR="%{buildroot}" "bindir=%{_sbindir}" "mandir=%{_mandir}" "sysconfdir=%{_sysconfdir}/openldap" "includedir=%{_includedir}" "libdir=%{_libdir}" "libexecdir=%{_libdir}" "mandir=%{_mandir}" install
# Install selected contrib overlays
for SLAPO_NAME in allowed autogroup authzid datamorph denyop lastbind noopsrch passwd/pbkdf2 passwd/sha2 smbk5pwd trace variant vc
do
  make -C contrib/slapd-modules/${SLAPO_NAME} STRIP="" DESTDIR="%{buildroot}" "mandir=%{_mandir}" "sysconfdir=%{_sysconfdir}/openldap" "libdir=%{_libdir}" "libexecdir=%{_libdir}" "mandir=%{_mandir}" 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.so*
rm %{buildroot}%{_unitdir}/slapd.service
rm %{buildroot}%{_mandir}/man5/slapd-perl.*
rm %{buildroot}%{_mandir}/man5/slapd-sql.*
rm %{buildroot}%{_mandir}/man5/lloadd.conf.*
rm %{buildroot}%{_mandir}/man5/slapd-wt.*
rm %{buildroot}%{_mandir}/man5/slapo-homedir.*
rm %{buildroot}%{_mandir}/man8/lloadd.*

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

# symbolic link for libldap_r
ln -fs libldap.so "%{buildroot}%{_libdir}/libldap_r.so"

%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/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}/mdb_*
%{_sbindir}/slap*
%{_libdir}/openldap/back_ldap*
%{_libdir}/openldap/back_mdb*
%{_libdir}/openldap/back_relay*
%{_libdir}/openldap/accesslog*
%{_libdir}/openldap/argon2*
%{_libdir}/openldap/auditlog*
%{_libdir}/openldap/autoca*
%{_libdir}/openldap/collect*
%{_libdir}/openldap/constraint*
%{_libdir}/openldap/dds*
%{_libdir}/openldap/deref*
%{_libdir}/openldap/dyngroup*
%{_libdir}/openldap/dynlist*
%{_libdir}/openldap/memberof*
%{_libdir}/openldap/otp*
%{_libdir}/openldap/pcache*
%{_libdir}/openldap/ppolicy*
%{_libdir}/openldap/remoteauth*
%{_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-accesslog*
%doc %{_mandir}/man5/slapo-auditlog*
%doc %{_mandir}/man5/slapo-autoca*
%doc %{_mandir}/man5/slapo-chain*
%doc %{_mandir}/man5/slapo-collect*
%doc %{_mandir}/man5/slapo-constraint*
%doc %{_mandir}/man5/slapo-dds*
%doc %{_mandir}/man5/slapo-deref*
%doc %{_mandir}/man5/slapo-dyngroup*
%doc %{_mandir}/man5/slapo-dynlist*
%doc %{_mandir}/man5/slapo-memberof*
%doc %{_mandir}/man5/slapo-otp*
%doc %{_mandir}/man5/slapo-pbind*
%doc %{_mandir}/man5/slapo-pcache*
%doc %{_mandir}/man5/slapo-ppolicy*
%doc %{_mandir}/man5/slapo-refint*
%doc %{_mandir}/man5/slapo-remoteauth*
%doc %{_mandir}/man5/slapo-retcode*
%doc %{_mandir}/man5/slapo-rwm*
%doc %{_mandir}/man5/slapo-sssvlv*
%doc %{_mandir}/man5/slapo-syncprov*
%doc %{_mandir}/man5/slapo-translucent*
%doc %{_mandir}/man5/slapo-unique*
%doc %{_mandir}/man5/slapo-valsort*
%doc %{_mandir}/man5/slappw-argon2*
%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}/man1/mdb_*
%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/ldapvc
%{_prefix}/bin/ldapwhoami
%config(noreplace) %{_sysconfdir}/openldap/ldap.conf
%doc %{_mandir}/man5/ldap.conf*
%{_sysconfdir}/openldap/ldap.conf.default
%{_libdir}/liblber*.so.*
%{_libdir}/libldap*.so.*
%dir %{_libdir}/pkgconfig
%{_libdir}/pkgconfig/lber.pc
%{_libdir}/pkgconfig/ldap.pc

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

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

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

%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/authzid*
%{_libdir}/openldap/autogroup.*
%{_libdir}/openldap/datamorph.*
%{_libdir}/openldap/denyop.*
%{_libdir}/openldap/lastbind.*
%{_libdir}/openldap/noopsrch.*
%{_libdir}/openldap/pw-pbkdf2.*
%{_libdir}/openldap/pw-sha2.*
%{_libdir}/openldap/smbk5pwd.*
%{_libdir}/openldap/trace.*
%{_libdir}/openldap/variant.*
%{_libdir}/openldap/vc.*
%doc %{_mandir}/man5/slapd-pw-pbkdf2*
%doc %{_mandir}/man5/slapd-pw-sha2*
%doc %{_mandir}/man5/slapo-datamorph*
%doc %{_mandir}/man5/slapo-lastbind*
%doc %{_mandir}/man5/slapo-smbk5pwd*
%doc %{_mandir}/man5/slapo-variant*

%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