LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File cyrus-imapd.spec of Package cyrus-imapd (Project server:mail)

#
# spec file for package cyrus-imapd
#
# Copyright (c) 2012 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/
#


#
%define prjname cyrus-imapd

# Define and use _name because the macro expansion is not smart enough.  Without
# this construction the name definition of cyrus-imapd-kolab is changed to cyrus-imapd.
%if ! %{defined with_kolab}
%define with_kolab 0
%define _name cyrus-imapd

%else
%define _name cyrus-imapd-kolab

%endif

Name:           %_name

%if %{with_kolab}
%define         pkg_perl_Cyrus_IMAP perl-Cyrus-IMAP-kolab
%define         pkg_perl_Cyrus_SIEVE_managesieve perl-Cyrus-SIEVE-managesieve-kolab
%else
%define         pkg_perl_Cyrus_IMAP perl-Cyrus-IMAP
%define         pkg_perl_Cyrus_SIEVE_managesieve perl-Cyrus-SIEVE-managesieve

%endif

BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  cyrus-sasl-devel
BuildRequires:  db-devel
BuildRequires:  drac
BuildRequires:  ed
BuildRequires:  flex
BuildRequires:  krb5-devel
BuildRequires:  openldap2-devel
BuildRequires:  openslp-devel
BuildRequires:  openssl-devel
BuildRequires:  opie
BuildRequires:  perl-Digest-SHA1
BuildRequires:  pwdutils
BuildRequires:  tcpd-devel
Url:            http://cyrusimap.web.cmu.edu/
Requires:       %pkg_perl_Cyrus_IMAP
Requires:       %pkg_perl_Cyrus_SIEVE_managesieve
Recommends:     perl-TermReadLine-Gnu
Conflicts:      imap courier-imap
%if %{with_kolab}
Conflicts:      cyrus-imapd
%else
Conflicts:      cyrus-imapd-kolab
%endif
Summary:        The Cyrus IMAP and POP Mail Server
License:        BSD-3-Clause
Group:          Productivity/Networking/Email/Servers
Version:        2.3.18
Release:        0
Source:         %{prjname}-%{version}.tar.gz
Source1:        cyrus-imapd-rc.tar.gz
Source2:        DB_CONFIG
# The autocreate Patchset is maintained at:
# http://email.uoa.gr/projects/cyrus/autocreate/
Patch1:         cyrus-imapd-2.3.16-autocreate-0.10-0.drac.diff
Patch4:         luser_relay.patch
Patch5:         user_deny_db-once.patch
Patch7:         syslog-facility-doc.patch
Patch10:        cyrus-imapd-openslp.patch
Patch12:        pie.patch
Patch18:        cyrus-imapd-perl-path.patch
Patch20:        cyrus-imapd-perl-5.14.patch
Patch22:        cyrus-imapd_tls-session-leak.dif
Patch23:        cyrus-imapd_references_header-dos.dif
Patch24:        charset.patch
%if %{with_kolab}
# KOLAB_cyrus-imapd patches are maintained at
# http://kolab.org/cgi-bin/viewcvs-kolab.cgi/server/imapd/patches/
Patch100:       KOLAB_cyrus-imapd-%{version}_Cyradm_Annotations.patch
Patch102:       KOLAB_cyrus-imapd-%{version}_Folder-names.patch
Patch103:       KOLAB_cyrus-imapd-%{version}_Groups2.patch
Patch104:       KOLAB_cyrus-imapd-%{version}_Logging.patch
Patch105:       KOLAB_cyrus-imapd-%{version}_timsieved_starttls-sendcaps.patch
Patch106:       KOLAB_cyrus-imapd-%{version}_UID.patch
Patch107:       KOLAB_cyrus-imapd-%{version}_cross-domain-acls.patch
%endif

Requires(pre):  /usr/sbin/useradd /usr/sbin/usermod %insserv_prereq %fillup_prereq /bin/sed
Requires(pre):  /bin/awk /bin/grep /bin/cat /usr/bin/find /usr/bin/db_verify sh-utils
Requires(pre):  fileutils cyrus-sasl netcfg /usr/bin/strings
Recommends:     cron
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%package -n %pkg_perl_Cyrus_IMAP

%if %{with_kolab}
Conflicts:      perl-Cyrus-IMAP
%else
Conflicts:      perl-Cyrus-IMAP-kolab
%endif
Summary:        Cyrus IMAP Perl Module
Group:          Development/Libraries/Perl
Requires:       perl = %{perl_version}

%package -n %pkg_perl_Cyrus_SIEVE_managesieve

%if %{with_kolab}
Conflicts:      perl-Cyrus-SIEVE-managesieve
%else
Conflicts:      perl-Cyrus-SIEVE-managesieve-kolab
%endif
Summary:        A Perl Module for Cyrus SIEVE
Group:          Development/Libraries/Perl
Requires:       perl = %{perl_version}
Recommends:     perl-TermReadLine-Gnu

%package -n %{name}-devel

%if %{with_kolab}
Conflicts:      cyrus-imapd
%else
Conflicts:      cyrus-imapd-kolab
%endif
Summary:        Libraries and Includes for Cyrus IMAPd
Group:          Development/Libraries/C and C++

%description
Cyrus is a highly scalable enterprise mail system designed for use in
enterprise environments of various sizes using standards based
technologies. Cyrus technologies scale from independent use in email
departments to a system centrally managed in a large enterprise.

%description -n %pkg_perl_Cyrus_IMAP
A Cyrus IMAP Perl module for the Cyrus IMAPD.

%description -n %pkg_perl_Cyrus_SIEVE_managesieve
A Perl module for Cyrus SIEVE.

%description -n %{name}-devel
This package provides the libraries and include files for Cyrus IMAPd.

%define cyrus_uid 96

%prep
%setup -q -a 1 -n %{prjname}-%{version}
patch -s -p0 < contrib/drac_auth.patch
%patch1 -p1
%patch4 -p1
%patch5 -p1
%patch7 -p1
%patch10
%patch12 -p1
%patch18
%patch20 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1

%if %{with_kolab}
%patch100 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p1
%endif

%build
rm -fr aclocal.m4 configure config.h.in autom4te.cache
sh SMakefile

%if %{with_kolab}
  # CONFIGURE_ARGS="--with-ldap=%{_includedir}"
  # For unknow reason the configure argument --with-ldap=%{_includedir} is not
  # picked up by configure, use the line below as a workaround until the
  # configure --with-ldap actually works
  sed -i 's;\(IMAP_LIBS="${LIB_SASL}\) \(.*"\);\1 -lldap -llber \2;g' configure
%endif

export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -I/usr/include/kerberosIV -I%{_libdir}/sasl2/include"
./configure --prefix=/usr \
	    --mandir=%{_mandir} \
	    --libdir=%{_libdir} \
	    --localstatedir=/var/lib \
	    --enable-idled \
	    --enable-murder \
            --enable-netscapehack \
	    --enable-nntp \
            --enable-replication \
	    --with-com_err=yes \
            --with-cyrus-user=cyrus \
            --with-cyrus-group=mail \
            --with-cyrus-prefix=/usr/lib/cyrus \
	    --with-drac=%{_libdir} \
	    --with-gss_impl=auto \
        --with-ldap \
	    --with-libwrap=/usr \
	    --with-lock=fcntl \
	    --with-openslp=%{_libdir} \
            --with-openssl \
	    --with-perl=/usr/bin/perl \
	    --with-syslogfacility=DAEMON \
	    --without-ucdsnmp $CONFIGURE_ARGS
# parallel make is broken in version 2.3.17
make depend # %{?_smp_mflags}
make # %{?_smp_mflags}

%install
mkdir -p $RPM_BUILD_ROOT/etc/init.d
mkdir -p $RPM_BUILD_ROOT/etc/pam.d
install -m 644 SuSE/imap $RPM_BUILD_ROOT/etc/pam.d/imap
install -m 644 SuSE/pop $RPM_BUILD_ROOT/etc/pam.d/pop
install -m 644 SuSE/sieve $RPM_BUILD_ROOT/etc/pam.d/sieve
mkdir -p $RPM_BUILD_ROOT/etc/cron.daily
mkdir -p $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT/var/adm
install -m 755 SuSE/rc.cyrus $RPM_BUILD_ROOT/etc/init.d/cyrus
ln -sf ../etc/init.d/cyrus $RPM_BUILD_ROOT/sbin/rccyrus
install -m 755 SuSE/cron.daily.cyrus $RPM_BUILD_ROOT/etc/cron.daily/suse.de-cyrus-imapd
rm -f tools/config2*
rm -rf tools/CVS
rm -rf contrib
chmod 644 doc/internal/*.html
mkdir -p $RPM_BUILD_ROOT/usr/lib/cyrus/tools/
install -m 755 tools/* $RPM_BUILD_ROOT/usr/lib/cyrus/tools/
#*****************************************************************************
# SuSEfirewall2 Services
#*****************************************************************************
install -d $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services/
install -m 644 SuSE/SuSEfirewall2.cyrus-imapd $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services/cyrus-imapd
export DESTDIR=$RPM_BUILD_ROOT
make install
# make install results in make install within the perl modules subdir, so
# remove the stuff from buildroot to satisfy the picky rpm4, as we don't need
# it and use install_vendor for perl modules below
rm -rf $RPM_BUILD_ROOT/%{perl_sitelib}
rm -rf $RPM_BUILD_ROOT/%{perl_sitearch}
#*****************************************************************************
# perl modules
#*****************************************************************************
# Cyrus IMAP
#*****************************************************************************
cd perl/imap
make DESTDIR=$RPM_BUILD_ROOT install_vendor
%perl_process_packlist -n %pkg_perl_Cyrus_IMAP
cd -
#*****************************************************************************
# Cyrus SIEVE managesieve
#*****************************************************************************
cd perl/sieve/managesieve
make DESTDIR=$RPM_BUILD_ROOT install_vendor
%perl_process_packlist -n %pkg_perl_Cyrus_SIEVE_managesieve
cd -
#*****************************************************************************
install -m 644 SuSE/imapd.conf $RPM_BUILD_ROOT/etc/imapd.conf
install -m 644 SuSE/cyrus.conf $RPM_BUILD_ROOT/etc/cyrus.conf
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/user
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/quota
install -d -m 700 $RPM_BUILD_ROOT/var/lib/imap/ptclient
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/proc
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/log
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/msg
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/db
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/var/lib/imap/db
install -d -m 750 $RPM_BUILD_ROOT/var/lib/imap/socket
install -d -m 750 $RPM_BUILD_ROOT/var/lib/sieve
for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
	install -d -m 755 $RPM_BUILD_ROOT/var/lib/imap/user/$i
	install -d -m 755 $RPM_BUILD_ROOT/var/lib/imap/quota/$i
	install -d -m 750 $RPM_BUILD_ROOT/var/lib/sieve/$i
done
#chown -R cyrus:mail $RPM_BUILD_ROOT/var/lib/imap
#chown -R cyrus:mail $RPM_BUILD_ROOT/var/lib/sieve
install -d -m 750 $RPM_BUILD_ROOT/var/spool/imap
install -d -m 750 $RPM_BUILD_ROOT/var/adm/backup/imap
#chown cyrus:mail $RPM_BUILD_ROOT/var/spool/imap
mv $RPM_BUILD_ROOT/%{_mandir}/man8/master.8 \
	$RPM_BUILD_ROOT/%{_mandir}/man8/cyrus_master.8
mv $RPM_BUILD_ROOT/%{_mandir}/man8/idled.8 \
	$RPM_BUILD_ROOT/%{_mandir}/man8/cyrus_idled.8
mv $RPM_BUILD_ROOT/%{_mandir}/man8/fetchnews.8 \
	$RPM_BUILD_ROOT/%{_mandir}/man8/cyrus_fetchnews.8
find . -type d -a -name CVS | xargs rm -rfv
find . -type f -a -name .cvsignore | xargs rm -rfv

%pre
/usr/sbin/useradd -r -o -g mail -u %{cyrus_uid} -s /bin/bash -c "User for cyrus-imapd" -d /var/lib/imap cyrus 2> /dev/null || :
/usr/sbin/usermod -d /var/lib/imap cyrus || :

%preun
%stop_on_removal cyrus

%post
grep -E "^sieve" etc/services >/dev/null || {
   echo "Adding sieve service to /etc/services"
   CFBAK=services.`date +%Y-%m-%d`
   CFNEW=services.$$
   cat etc/services | awk '
BEGIN                   { OFS="\t"; ORS="\n"; }
/^#/                    { print; next; }
/[[:space:]]+2000\/(tcp|udp)/       { printf "sieve\t\t%s\t# Cyrus SIEVE\n", $2; next; } 
                        { print; next; };' > etc/$CFNEW
   echo "Backing up old services as $CFBAK"
   cp --remove-destination etc/services etc/$CFBAK
   mv etc/$CFNEW etc/services
}
SIEVEUP=
IMAPUP=
test $1 -gt 1 && test -d usr/sieve -a ! -L usr/sieve && SIEVEUP=yes
test $1 -gt 1 && test -d var/imap  -a ! -L var/imap  && IMAPUP=yes
test -n "`find var/lib/sieve -type f`" && {
     SIEVEUP=
}
test -n "`find var/lib/imap -type f`" && {
     IMAPUP=
}
test -n "$SIEVEUP" && {
     echo "Creating compatibility symlink /var/lib/sieve -> /usr/sieve"
     rm -rf var/lib/sieve
     ln -sf ../../usr/sieve var/lib/sieve
}
test -n "$IMAPUP" && {
     echo "Creating compatibility symlink /var/lib/imap -> /var/imap"
     rm -rf var/lib/imap
     ln -sf  ../imap /var/lib/imap
}
%{fillup_and_insserv cyrus}

%postun
%restart_on_update cyrus
%insserv_cleanup

%files
%defattr(-,root,root)
%config /etc/pam.d/*
%config /etc/cron.daily/suse.de-cyrus-imapd
%config(noreplace) /etc/imapd.conf
%config(noreplace) /etc/cyrus.conf
%config /etc/sysconfig/SuSEfirewall2.d/services/cyrus-imapd
%dir %attr(0750, cyrus, mail) /var/lib/imap
%attr(0750, cyrus, mail) /var/lib/imap/log
%attr(0750, cyrus, mail) /var/lib/imap/msg
%attr(0750, cyrus, mail) /var/lib/imap/proc
%attr(0750, cyrus, mail) /var/lib/imap/quota
%attr(0700, cyrus, mail) /var/lib/imap/ptclient
%attr(0750, cyrus, mail) /var/lib/imap/user
%attr(0750, cyrus, mail) /var/lib/imap/socket
%dir %attr(0750, cyrus, mail) /var/lib/imap/db
%config(noreplace) /var/lib/imap/db/DB_CONFIG
%attr(0750, cyrus, mail) /var/lib/sieve
%attr(0750, cyrus, mail) /var/spool/imap
%attr(0750, cyrus, mail) /var/adm/backup/imap
/etc/init.d/cyrus
/sbin/rccyrus
/usr/lib/cyrus
/usr/bin/cyradm
/usr/bin/imtest
/usr/bin/lmtptest
/usr/bin/mupdatetest
/usr/bin/nntptest
/usr/bin/pop3test
/usr/bin/sivtest
/usr/bin/smtptest
/usr/bin/synctest
%doc %{_mandir}/man1/cyradm.1.gz
%doc %{_mandir}/man1/imtest.1.gz
%doc %{_mandir}/man1/lmtptest.1.gz
%doc %{_mandir}/man1/mupdatetest.1.gz
%doc %{_mandir}/man1/nntptest.1.gz
%doc %{_mandir}/man1/pop3test.1.gz
%doc %{_mandir}/man1/sivtest.1.gz
%doc %{_mandir}/man1/smtptest.1.gz
%doc %{_mandir}/man3/imclient.3.gz
%doc %{_mandir}/man5/*.gz
%doc %{_mandir}/man8/*.gz
%doc COPYRIGHT README README.andrew doc
%doc SuSE/README.SuSE

%files -n %{name}-devel
%defattr(-,root,root)
/usr/include/cyrus
%{_libdir}/libcyrus.a
%{_libdir}/libcyrus_min.a

%files -n %pkg_perl_Cyrus_IMAP
%defattr(-,root,root)
%dir %{perl_vendorarch}/Cyrus
%{perl_vendorarch}/Cyrus/IMAP
%{perl_vendorarch}/Cyrus/IMAP.pm
%dir %{perl_vendorarch}/auto/Cyrus
%{perl_vendorarch}/auto/Cyrus/IMAP
%if %{suse_version} < 1140
/var/adm/perl-modules/%pkg_perl_Cyrus_IMAP
%endif
%doc %{_mandir}/man3/Cyrus::IMAP*

%files -n %pkg_perl_Cyrus_SIEVE_managesieve
%defattr(-,root,root)
/usr/bin/installsieve
/usr/bin/sieveshell
%doc %{_mandir}/man1/installsieve.1.gz
%doc %{_mandir}/man1/sieveshell.1.gz
%dir %{perl_vendorarch}/Cyrus
%dir %{perl_vendorarch}/Cyrus/SIEVE
%{perl_vendorarch}/Cyrus/SIEVE/managesieve.pm
%dir %{perl_vendorarch}/auto/Cyrus
%dir %{perl_vendorarch}/auto/Cyrus/SIEVE
%{perl_vendorarch}/auto/Cyrus/SIEVE/managesieve
%if %{suse_version} < 1140
/var/adm/perl-modules/%pkg_perl_Cyrus_SIEVE_managesieve
%endif
%doc %{_mandir}/man3/Cyrus::SIEVE::managesieve.3pm.gz

%changelog