File perdition.spec of Package perdition

#
# spec file for package perdition
#
# Copyright (c) 2011 SUSE LINUX Products 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/
#


# Do we have filesystem >= 2.3.2 (new pki location) ?
%define use_etc_pki %(eval [ $(rpm -q --queryformat '%{VERSION}' filesystem \| sed -e "s/\\.//g") -ge 232 ] && echo 1 || echo 0 )
%if %{use_etc_pki}
%define certs_dir %{_sysconfdir}/pki/tls/certs
%define pki_dir %{_sysconfdir}/pki/%{name}
%else
%define certs_dir %{_datadir}/ssl/certs
%define pki_dir %{_datadir}/ssl/certs
%endif
%define ssl_pem_file %{pki_dir}/%{name}.pem

Name:           perdition
Summary:        Mail Retrieval Proxy
Version:        2.1
Release:        1
License:        GPL-3.0
Group:          Productivity/Networking/Email/Servers
Url:            http://vergenet.net/linux/perdition/
Source0:        http://www.vergenet.net/linux/perdition/download/%{version}/%{name}-%{version}.tar.bz2
Source1:        %{name}.init
Source2:        %{name}.pam
Source3:        %{name}.sysconfig
Source10:       %{name}.rpmlintrc
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch0:         perdition-2.1-conf.patch
# Patches >= 100 are fixed in CVS
#Patch100: perdition-1.17-ldap.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  gcc-c++
BuildRequires:  gdbm-devel
BuildRequires:  libidn-devel
BuildRequires:  libtool
BuildRequires:  mysql-devel
BuildRequires:  openssl-devel
BuildRequires:  pam-devel
BuildRequires:  pkgconfig
BuildRequires:  postgresql-devel
BuildRequires:  unixODBC-devel
BuildRequires:  vanessa_adt-devel >= 0.0.6
BuildRequires:  vanessa_logger-devel >= 0.0.6
BuildRequires:  vanessa_socket-devel >= 0.0.10
BuildRequires:  zlib-devel

%if 0%{?suse_version} > 0
BuildRequires:  db-devel
BuildRequires:  openldap2-devel
BuildRequires:  openldap2
BuildRequires:  popt-devel
%endif
%if 0%{?mandriva_version} > 0
BuildRequires:  db-devel
BuildRequires:  openldap-devel
BuildRequires:  popt-devel
%endif
%if 0%{?fedora_version} > 0
BuildRequires:  db4-devel
BuildRequires:  openldap-devel
BuildRequires:  popt
%endif

%description
Perdition is a fully featured POP3 and IMAP4 proxy server. It is able to
handle both SSL and non-SSL connections and redirect users to a
real-server based on a database lookup. Perdition supports modular based
database access. ODBC, MySQL, PostgreSQL, GDBM, POSIX Regular Expression
and NIS modules ship with the distribution. The API for modules is open
allowing abitary modules to be written to allow access to any data store.

Perdition can be used to: Create large mail systems where a users mailbox
may be stored on one of several hosts.  Integrate different mail systems
together. Migrate between different email infastructure. And in firewall
applications.

%package devel
Summary:        Headers and static libraries for perditiondb library development
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
Requires:       %{name}-bdb = %{version}
Requires:       %{name}-ldap = %{version}
Requires:       %{name}-mysql = %{version}
Requires:       %{name}-pgsql = %{version}
Requires:       %{name}-odbc = %{version}

%description devel
Perdition allows for arbitrary user database access through
shared libraries much in the manner of NSS in glibc. This package
provides headers and libraries that may be useful in the development
of perditiondb libraries.

%package bdb
Summary:        Library to allow perdition to access Berkely DB based pop maps
Group:          Productivity/Networking/Email/Servers
Requires:       %{name} = %{version}

%description bdb
Perdition allows for arbitrary user database access through shared
libraries much in the manner of NSS in glibc. This package allows a user
database to be sourced from a Berkely DB.

%package ldap
Summary:        Library to allow perdition to access LDAP based pop maps
Group:          Productivity/Networking/Email/Servers
Requires:       %{name} = %{version}

%description ldap
Perdition allows for arbitrary user database access through shared
libraries much in the manner of NSS in glibc. This package allows a user
database to be sourced from LDAP.

%package mysql
Summary:        Library to allow perdition to access MySQL based pop maps
Group:          Productivity/Networking/Email/Servers
Requires:       %{name} = %{version}

%description mysql
Perdition allows for arbitrary user database access through shared
libraries much in the manner of NSS in glibc. This package allows a user
database stored in a MySQL database.

%package pgsql
Summary:        Library to allow perdition to access PostgreSQL based pop maps
Group:          Productivity/Networking/Email/Servers
Requires:       %{name} = %{version}

%description pgsql
Perdition allows for arbitrary user database access through shared
libraries much in the manner of NSS in glibc. This package allows a user
database stored in a PostgreSQL database.

%package odbc
Summary:        Library to allow perdition to access pop maps via ODBC
Group:          Productivity/Networking/Email/Servers
Requires:       %{name} = %{version}
Requires:       unixODBC

%description odbc
Perdition allows for arbitrary user database access through shared
libraries much in the manner of NSS in glibc. This package allows a user
access databases via ODBC.

%prep
%setup -q
%patch0 -p1 -b .conf
#patch100 -p1 -b .ldap

%build
export CFLAGS="%{optflags} -fPIC"
if pkg-config openssl; then
  CPPFLAGS="$(pkg-config --cflags-only-I openssl) $CPPFLAGS"; export CPPFLAGS
  CFLAGS="$(pkg-config --cflags openssl) $CFLAGS"; export CFLAGS
  LDFLAGS="$(pkg-config --libs-only-L openssl) $LDFLAGS"; export LDFLAGS
fi

%configure \
 --disable-static --disable-silent-rules \
 --disable-cdb \
 %if ! %{with gdbm}
 --disable-gdbm \
 %endif
 --with-mysql-libraries=%{_libdir}/mysql
make %{?_smp_mflags}

%install
make DESTDIR=%{buildroot} install

#install -d %{buildroot}%{pki_dir}
install -D -m0755 %{S:1} %{buildroot}%{_initrddir}/%{name}
install -D -m0644 %{S:2} %{buildroot}%{_sysconfdir}/pam.d/%{name}
install -D -m0644 %{S:3} \
 %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
#install -D -m0644 %{name}/db/ldap/%{name}.schema \
#  %{buildroot}%{_sysconfdir}/openldap/schema/%{name}.schema

## create the ghost pem file
#touch %{buildroot}%{ssl_pem_file}
#%if %{use_etc_pki}
## change config file so ssl certificates are under /etc rather than /usr/share
#perl -pi -e \
#'s@/usr/share/ssl/certs/%{name}.pem@%{ssl_pem_file}@g; \
# s@/usr/share/ssl/certs/ca-bundle.crt@/etc/pki/tls/certs/ca-bundle.crt@' \
# %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
#perl -pi -e \
#'s@/usr/share/ssl/certs/@%{certs_dir}/@g' \
# %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
#%endif

# rpmlint: found trace of $RPM_BUILD_ROOT or $RPM_BUILD_DIR
# fix libperditiondb_daemon.la file
%{__sed} -i -e "s,-L%{_builddir}/%{name}-%{version}/%{name}/db/daemon/lib ,," %{buildroot}%{_libdir}/libperditiondb_daemon.la

%preun
%stop_on_removal %{name}
#if [ $1 = 0 ]; then
#  /sbin/service %{name} stop >/dev/null 2>&1 || :
#  /sbin/chkconfig --del %{name}
#  make -q -C /etc/perdition/ clean
#  true
#fi

%post
/sbin/ldconfig
%fillup_and_insserv %{name}
#/sbin/chkconfig --add %{name}
#make -q -C /etc/perdition/
#true

## Create SSL certificates
#exec > /dev/null 2> /dev/null
#%if %{use_etc_pki}
## if the certificate is only in the old location, move it to the new location
#if [ -f %{_datadir}/ssl/certs/%{name}.pem -a ! -f %{ssl_pem_file} ]; then
#mv %{_datadir}/ssl/certs/%{name}.pem %{ssl_pem_file}
#fi
#%endif
#if [ ! -f %{ssl_pem_file} ]; then
#pushd %{certs_dir}
#umask 077
#cat << EOF | make %{name}.pem
#--
#SomeState
#SomeCity
#SomeOrganization
#SomeOrganizationalUnit
#localhost.localdomain
#root@localhost.localdomain
#EOF
#chown root.nobody %{name}.pem
#chmod 640 %{name}.pem
#%if %{use_etc_pki}
#mv %{name}.pem %{ssl_pem_file}
#%endif
#popd
#fi

#%if %{use_etc_pki}
## change existing config so ssl certificates are under /etc rather than /usr/share
#perl -pi -e \
#'s@/usr/share/ssl/certs/%{name}.pem@%{ssl_pem_file}@g; \
# s@/usr/share/ssl/certs/ca-bundle.crt@/etc/pki/tls/certs/ca-bundle.crt@' \
# %{_sysconfdir}/%{name}/%{name}.conf
#perl -pi -e \
#'s@/usr/share/ssl/certs/@%{certs_dir}/@g' \
# %{_sysconfdir}/%{name}/%{name}.conf
#%endif

%postun
/sbin/ldconfig
%restart_on_update %{name}
%insserv_cleanup
#if [ "$1" -ge "1" ]; then
#  /sbin/service %{name} condrestart >/dev/null 2>&1 || :
#fi

%post bdb -p /sbin/ldconfig
%postun bdb -p /sbin/ldconfig
%post ldap -p /sbin/ldconfig
%postun ldap -p /sbin/ldconfig
%post mysql -p /sbin/ldconfig
%postun mysql -p /sbin/ldconfig
%post pgsql -p /sbin/ldconfig
%postun pgsql -p /sbin/ldconfig
%post odbc -p /sbin/ldconfig
%postun odbc -p /sbin/ldconfig

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING README TODO
%{_sbindir}/perdition
%{_sbindir}/perdition.pop3
%{_sbindir}/perdition.pop3s
%{_sbindir}/perdition.imap4
%{_sbindir}/perdition.imap4s
%{_sbindir}/perdition.imaps
%{_sbindir}/perdition.managesieve
%config %{_sysconfdir}/pam.d/%{name}
%{_initrddir}/%{name}
%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%{_mandir}/man8/perdition.*
%{_mandir}/man5/perditiondb.*
#%if %{use_etc_pki}
#%dir %{pki_dir}
#%endif
#%attr(0640,root,nobody) %ghost %config(missingok,noreplace) %verify(not md5 size mtime) %{ssl_pem_file}

# daemon map
%{_libdir}/libperditiondb_daemon.so.*

# daemon_base map
%{_libdir}/libperditiondb_daemon_base.so.*

%if %{with gdbm}
# gdbm map
%{_libdir}/libperditiondb_gdbm.so.*
%{_bindir}/makegdbm
%{_mandir}/man1/makegdbm.*
%endif
%{_sysconfdir}/%{name}/Makefile
%config %{_sysconfdir}/%{name}/Makefile.popmap
%config(noreplace) %{_sysconfdir}/%{name}/popmap

# nis map
%{_libdir}/libperditiondb_nis.so.*

# posix_regex map
%{_libdir}/libperditiondb_posix_regex.so.*
%config(noreplace) %{_sysconfdir}/%{name}/popmap.re

%files bdb
%defattr(-,root,root)
%{_libdir}/libperditiondb_bdb.la
%{_libdir}/libperditiondb_bdb.so.*
%{_bindir}/makebdb
%{_mandir}/man1/makebdb.*

%files ldap
%defattr(-,root,root)
%{_libdir}/libperditiondb_ldap.la
%{_libdir}/libperditiondb_ldap.so.*
%{_sbindir}/perditiondb_ldap_makedb
%{_mandir}/man8/perditiondb_ldap_makedb.*
%config %{_sysconfdir}/openldap/schema/%{name}.schema

%files mysql
%defattr(-,root,root)
%{_libdir}/libperditiondb_mysql.la
%{_libdir}/libperditiondb_mysql.so.*
%{_sbindir}/perditiondb_mysql_makedb
%{_mandir}/man8/perditiondb_mysql_makedb.*

%files pgsql
%defattr(-,root,root)
%{_libdir}/libperditiondb_postgresql.la
%{_libdir}/libperditiondb_postgresql.so.*
%{_sbindir}/perditiondb_postgresql_makedb
%{_mandir}/man8/perditiondb_postgresql_makedb.*

%files odbc
%defattr(-,root,root)
%{_libdir}/libperditiondb_odbc.la
%{_libdir}/libperditiondb_odbc.so.*
%{_sbindir}/perditiondb_odbc_makedb
%{_mandir}/man8/perditiondb_odbc_makedb.*

%files devel
%defattr(-,root,root)
%{_libdir}/libperditiondb_daemon_base.la
%{_libdir}/libperditiondb_daemon_base.so
%{_libdir}/libperditiondb_daemon.la
%{_libdir}/libperditiondb_daemon.so
%if %{with gdbm}
%{_libdir}/libperditiondb_gdbm.la
%{_libdir}/libperditiondb_gdbm.so
%endif
%{_libdir}/libperditiondb_nis.la
%{_libdir}/libperditiondb_nis.so
%{_libdir}/libperditiondb_posix_regex.la
%{_libdir}/libperditiondb_posix_regex.so
#
%{_libdir}/libperditiondb_bdb.so
%{_libdir}/libperditiondb_ldap.so
%{_libdir}/libperditiondb_mysql.so
%{_libdir}/libperditiondb_postgresql.so
%{_libdir}/libperditiondb_odbc.so

%changelog
openSUSE Build Service is sponsored by