File 389-ds.spec of Package 389-ds

#
# spec file for package 389-ds
#
# Copyright (c) 2015 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 http://bugs.opensuse.org/
#


Name:           389-ds
Summary:        389 Directory Server
License:        GPL-2.0
Group:          Productivity/Networking/LDAP/Servers
Version:        1.3.4.4
Release:        0
Url:            http://port389.org/

#DL-URL:          http://port389.org/wiki/Source
#Git-Clone:       git://git.fedorahosted.org/389/ds
Source:         http://www.port389.org/binaries/%name-base-%version.tar.bz2
Source9:        %name-rpmlintrc
# PATCH-FIX-SLES -- Make init scripts LSB conform
Patch1:         389-ds-base-1.3.2.11_init_fhs.patch
BuildRequires:  cyrus-sasl-devel
BuildRequires:  db-devel >= 4.5
BuildRequires:  gcc-c++
BuildRequires:  krb5-devel
# net-snmp-devel is needed to build the snmp ldap-agent
BuildRequires:  net-snmp-devel >= 5.1.2
BuildRequires:  openldap2-devel
# pam-devel is required by the pam passthru auth plug-in
BuildRequires:  pam-devel
%if 0%{?suse_version} < 1220
BuildRequires:  libicu-devel >= 3.4
BuildRequires:  mozilla-nspr-devel >= 4.6.4
BuildRequires:  mozilla-nss-devel >= 3.11.4
BuildRequires:  pcre-devel
BuildRequires:  svrcore-devel >= 4.0.3
%else
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(icu-i18n)
BuildRequires:  pkgconfig(icu-uc)
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(nspr)
BuildRequires:  pkgconfig(nss)
BuildRequires:  pkgconfig(svrcore)
BuildRequires:  pkgconfig(systemd)
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       cyrus-sasl-digestmd5
Requires:       cyrus-sasl-gssapi
Requires:       mozilla-nss-tools
Requires:       openldap2-client
Requires:       perl(Mozilla::LDAP::API)
Requires:       perl(Mozilla::LDAP::Conn)
Requires:       perl(Mozilla::LDAP::Entry)
Requires:       perl(Mozilla::LDAP::LDIF)
Requires:       perl(Mozilla::LDAP::Utils)
Requires:       perl(NetAddr::IP)
Requires:       perl(Socket6)

%if 0%{?suse_version} < 1220
%define __without_systemd 0
%endif

%bcond_without systemd

%if 0%{?suse_version} >= 1230
Requires:       %_sbindir/service
%else
Requires:       /sbin/service
%endif
Requires(post):   fillup
%if %{with systemd}
%{?systemd_requires}
%else
Requires(post):   insserv
Requires(post):   /sbin/chkconfig
Requires(preun):  /sbin/chkconfig
%endif

Obsoletes:      389-ds-base < %version-%release
Provides:       389-ds-base = %version-%release

%description
389 Directory Server is a full-featured LDAPv3 compliant server. In
addition to the standard LDAPv3 operations, it supports multi-master
replication, fully online configuration and administration, chaining,
virtual attributes, access control directives in the data, Virtual
List View, server-side sorting, SASL, TLS/SSL, and many other
features. (The server started out as Netscape Directory Server.)

%package devel
Summary:        Development files for the 389 Directory Server
Group:          Development/Libraries/C and C++
Requires:       %name = %version-%release

%description devel
389 Directory Server is a full-featured LDAPv3 compliant server. In
addition to the standard LDAPv3 operations, it supports multi-master
replication, fully online configuration and administration, chaining,
virtual attributes, access control directives in the data, Virtual
List View, server-side sorting, SASL, TLS/SSL, and many other
features.

This package contains the development files for 389DS.

%prep
%setup -qn %name-base-%version
%patch -P 1 -p1

%build
# openldap has no pkgconfig file; because of that, 389ds will prefer
# mozldap. Force use of openldap.
%configure \
	--bindir=%_libexecdir/%name/bin \
	--sbindir=%_libexecdir/%name/sbin \
	--enable-autobind \
	--with-openldap \
%if %{with systemd}
	--with-systemdsystemunitdir \
	--with-systemdsystemconfdir \
	--with-systemdgroupname=dirsrv.target \
%else
	--with-initddir="%_initddir" \
%endif
	.

make %{?_smp_mflags}

%install
b="%buildroot"
make install DESTDIR="$b"

install -d "$b/%_sbindir"
ln -s "%_libexecdir/%name/sbin/setup-ds.pl" "$b/%_sbindir/setup-ds.pl"

%if %{with systemd}
install -d "$b/%_unitdir/dirsrv.target.wants"
%if 0%{?suse_version} >= 1230
ln -s service "$b/%_sbindir/rcdirsrv"
ln -s service "$b/%_sbindir/rcdirsrv-snmp"
%else
ln -s /sbin/service "$b/%_sbindir/rcdirsrv"
ln -s /sbin/service "$b/%_sbindir/rcdirsrv-snmp"
%endif
%else
ln -s "%_initddir/dirsrv" "$b/%_sbindir/rcdirsrv"
ln -s "%_initddir/dirsrv-snmp" "$b/%_sbindir/rcdirsrv-snmp"
%endif

install -d "$b/%_localstatedir/adm/fillup-templates"
for i in "$b/%_sysconfdir/sysconfig"/*; do
	mv "$i" "$b/%_localstatedir/adm/fillup-templates/sysconfig.${i##*/}"
done
find "$b/%_libdir" -type f -name "*.la" -delete

# make sure perl scripts have a proper shebang 
sed -i -e 's|#{{PERL-EXEC}}|#!%_bindir/perl|' "$b/%_datadir/dirsrv/script-templates"/template-*.pl

%if %{with systemd}
%pre
%service_add_pre dirsrv@*.service dirsrv-snmp.service dirsrv.target
%endif

%post
/sbin/ldconfig
%if %{with systemd}
%fillup_only -n dirsrv
%fillup_only -n dirsrv.systemd
%service_add_post dirsrv@*.service dirsrv-snmp.service dirsrv.target
%else
%fillup_and_insserv dirsrv
%fillup_and_insserv dirsrv-snmp
%endif

%preun
%if %{with systemd}
%service_del_preun dirsrv@*.service dirsrv-snmp.service dirsrv.target
%else
%stop_on_removal dirsrv
%stop_on_removal dirsrv-snmp
%endif

%postun
/sbin/ldconfig
%if %{with systemd}
%service_del_postun dirsrv@*.service dirsrv-snmp.service dirsrv.target
%else
%restart_on_update dirsrv
%restart_on_update dirsrv-snmp
%insserv_cleanup
%endif

%files
%defattr(-,root,root)
%doc LICENSE README
%dir %_sysconfdir/dirsrv
%dir %_sysconfdir/dirsrv/schema
%config(noreplace) %_sysconfdir/dirsrv/schema/*.ldif
%dir %_sysconfdir/dirsrv/config
%config(noreplace) %_sysconfdir/dirsrv/config/slapd-collations.conf
%config(noreplace) %_sysconfdir/dirsrv/config/certmap.conf
%config(noreplace) %_sysconfdir/dirsrv/config/ldap-agent.conf
%config(noreplace) %_sysconfdir/dirsrv/config/template-initconfig
%_datadir/dirsrv
%if %{with systemd}
%_unitdir/dirsrv*
%else
%_initddir/dirsrv*
%endif
%_libexecdir/%name/
%_sbindir/*
%dir %_libdir/dirsrv
%_libdir/dirsrv/*.so.*
%dir %_libdir/dirsrv/perl
%_libdir/dirsrv/perl/*.pm
%dir %_libdir/dirsrv/plugins
%_libdir/dirsrv/plugins/*.so
%dir %_libdir/dirsrv/python
%_libdir/dirsrv/python/*.py
%_localstatedir/adm/fillup-templates/sysconfig.*
%_mandir/man1/*
%_mandir/man8/*

%files devel
%defattr(-,root,root)
%doc LICENSE README
%_includedir/dirsrv
%_libdir/dirsrv/*.so
%_libdir/pkgconfig/dirsrv.pc

%changelog
openSUSE Build Service is sponsored by