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) 2014 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/

%global cyrus_user	cyrus
%global cyrus_group	mail
%global cyrus_uid	96

%if 0%{?suse_version} >= 1220
# Systemd support not fully integrated, yet
#%%global with_systemd 1
%global with_systemd 0

%if 0%{?with_systemd}
%global _servicename	cyrus-imapd
%global _servicename	cyrus

Name:           cyrus-imapd
Version:        2.4.17
Release:        0
Summary:        The Cyrus IMAP and POP Mail Server
License:        BSD-3-Clause
Group:          Productivity/Networking/Email/Servers

Url:            http://www.cyrusimap.org

# Upstream sources
Source0:        http://cyrusimap.org/releases/%{name}-%{version}.tar.gz
Source1:        http://ftp.andrew.cmu.edu/pub/mibs/cmu/cmu.mib

# Distribution specific sources
Source10:       cyrus-imapd-rc-2.tar.gz

# PATCH-FEATURE-UPSTREAM -- Add support for Dynamic Relay Authorization Control
Patch0:         cyrus-imapd-2.4.17_drac_auth.patch
# PATCH-FEATURE-UPSTREAM -- Autocreate INBOX folders // included in 2.5
Patch1:         cyrus-imapd-2.4.17_autocreate-0.10-0.patch
# PATCH-FEATURE-UPSTREAM -- Add support to define a catchall mailbox
Patch4:         cyrus-imapd-2.4.17_lmtp_catchall_mailbox.patch
# PATCH-FIX-OPENSUSE -- Use the right syslog facility in docs
Patch7:         cyrus-imapd-2.3.16_syslog-facility-doc.patch
# PATCH-FEATURE-UPSTREAM -- Add support for OpenSLP
Patch10:        cyrus-imapd-2.4.17_openslp.patch
# PATCH-FIX-UPSTREAM -- Fix compiling with -fPIE
Patch12:        cyrus-imapd-2.4.17_pie.patch
# PATCH-FIX-UPSTREAM -- Support db-6.0
Patch25:        cyrus-imapd-2.4.17_db6.patch
# PATCH-FIX-UPSTREAM -- Fix TLS session leak // included in 2.4next
Patch26:        cyrus-imapd-2.4.17_tls-session-leak.patch
# PATCH-FEATURE-UPSTREAM -- Allow a result attribute to be specified with ptclient/ldap.c // included in 2.5
Patch27:        cyrus-imapd-2.4.17_ptloader-ldap_user_attribute.patch

BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  cyrus-sasl-devel
BuildRequires:  db-devel
BuildRequires:  drac
BuildRequires:  ed
BuildRequires:  flex
BuildRequires:  krb5-devel
BuildRequires:  net-snmp-devel
BuildRequires:  openldap2-devel
BuildRequires:  openslp-devel
BuildRequires:  openssl-devel
BuildRequires:  opie
BuildRequires:  perl-Digest-SHA1
BuildRequires:  pwdutils
%if 0%{?with_systemd}
BuildRequires:  systemd
BuildRequires:  tcpd-devel
BuildRequires:  zlib
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?with_systemd}
Requires(pre):  %{insserv_prereq}
Requires(pre):  /usr/sbin/useradd /usr/sbin/usermod %{fillup_prereq} /bin/sed
Requires(pre):  /bin/awk /bin/grep /bin/cat /usr/bin/find /usr/bin/db_verify sh-utils
Requires(pre):  aaa_base fileutils cyrus-sasl netcfg /usr/bin/strings pwdutils

Requires:       perl-Cyrus-IMAP = %{version}
Requires:       perl-Cyrus-SIEVE-managesieve = %{version}

Recommends:     cron
Recommends:     cyradm
Recommends:     perl-TermReadLine-Gnu

Conflicts:      cyrus-imapd-kolab
Conflicts:      imap courier-imap

%package snmp
Summary:        SNMP support for the Cyrus IMAP and POP Mail Server
Group:          Productivity/Networking/Email/Utilities
Requires:       %{name} = %{version}
Requires:       %{name}-snmp-mibs = %{version}
Requires:       net-snmp >= 5.0

%package snmp-mibs
Summary:        MIBs for the Cyrus IMAP and POP Mail Server
Group:          Productivity/Networking/Email/Utilities

%package utils
Summary:        Test tools for mail servers
Group:          Productivity/Networking/Email/Utilities
Requires:       cyrus-sasl-plain
Conflicts:      cyrus-imapd <= 2.3.18

%package -n perl-Cyrus-IMAP
Summary:        Cyrus IMAP Perl Module
Group:          Development/Libraries/Perl
%if 0%{?suse_version} < 1140
Requires:       perl = %{perl_version}
Conflicts:      perl-Cyrus-IMAP-kolab

%package -n cyradm
Summary:        Administration tool for the Cyrus IMAP server
Group:          Productivity/Networking/Email/Utilities
Requires:       perl(Cyrus::IMAP::Shell)
Conflicts:      cyrus-imapd <= 2.3.18

%package -n perl-Cyrus-SIEVE-managesieve
Summary:        Cyrus SIEVE Perl Module
Group:          Development/Libraries/Perl
%if 0%{?suse_version} < 1140
Requires:       perl = %{perl_version}
Recommends:     perl-TermReadLine-Gnu
Conflicts:      perl-Cyrus-SIEVE-managesieve-kolab
Conflicts:      python-managesieve

%package devel
Summary:        Libraries and Includes for %{name}
Group:          Development/Libraries/C and C++
Conflicts:      cyrus-imapd-kolab-devel

The %{name} package contains the core of the Cyrus IMAP server.
It is a scaleable enterprise mail system designed for use from
small to large enterprise environments using standards-based
internet mail technologies.

A full Cyrus IMAP implementation allows a seamless mail and bulletin
board environment to be set up across multiple servers. It differs from
other IMAP server implementations in that it is run on "sealed"
servers, where users are not normally permitted to log in and have no
system account on the server. The mailbox database is stored in parts
of the filesystem that are private to the Cyrus IMAP server. All user
access to mail is through software using the IMAP, POP3 or KPOP
protocols. It also includes support for virtual domains, NNTP,
mailbox annotations, and much more. The private mailbox database design
gives the server large advantages in efficiency, scalability and
administratability. Multiple concurrent read/write connections to the
same mailbox are permitted. The server supports access control lists on
mailboxes and storage quotas on mailbox hierarchies.

The Cyrus IMAP server supports the IMAP4rev1 protocol described
in RFC 3501. IMAP4rev1 has been approved as a proposed standard.
It supports any authentication mechanism available from the SASL
library, imaps/pop3s/nntps (IMAP/POP3/NNTP encrypted using SSL and
TLSv1) can be used for security. The server supports single instance
store where possible when an email message is addressed to multiple
recipients, SIEVE provides server side email filtering.

%description snmp
The %{name} package contains the core of the Cyrus IMAP server.
It is a scaleable enterprise mail system designed for use from
small to large enterprise environments using standards-based
internet mail technologies.

This package pulls in dependencies to enable SNMP support for %{name}.

%description snmp-mibs
This package contains MIBs for the Cyrus IMAP server. They are required to use %{name} with SNMP.

%description utils
This package contains test tools for mail protocols (not only %{name} specific).

%description -n cyradm
This package contains an administration tool for the Cyrus IMAP server.

%description -n perl-Cyrus-IMAP
This package contains a Perl module for the Cyrus IMAP server.

%description -n perl-Cyrus-SIEVE-managesieve
This package contains a Perl module for Cyrus SIEVE.

%description devel
The %{name}-devel package contains header files and libraries
necessary for developing applications which use the imclient library.

%setup -q -a 10
%patch0 -p1
%patch1 -p1
%patch4 -p1
%patch7 -p1
%patch10 -p1
%patch12 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1

# remove executable bit from docs
find doc -type f -name '*.html' -exec %{__chmod} -x {} \;

# remove cruft
find doc -type f -a -name '.cvsignore' -exec %{__rm} -f {} \;

%{__rm} -fr aclocal.m4 configure config.h.in autom4te.cache
sh SMakefile

export CFLAGS="%{?optflags}"

%{configure} --localstatedir=%{_var}/lib \
             --enable-idled \
             --enable-murder \
             --enable-netscapehack \
             --enable-nntp \
             --enable-replication \
             --enable-gssapi \
             --with-bdb \
             --with-com_err \
             --with-cyrus-user=%{cyrus_user} \
             --with-cyrus-group=%{cyrus_group} \
             --with-cyrus-prefix=%{_prefix}/lib/cyrus \
             --with-drac \
             --with-gss_impl=auto \
             --with-ldap \
             --with-libwrap \
             --with-lock=fcntl \
             --with-openslp \
             --with-openssl \
             --with-perl=%{__perl} \
             --with-sasl \
             --with-snmp \
             --with-syslogfacility=DAEMON \

%{__make} depend %{?_smp_mflags}
%{__make} %{?_smp_mflags}

# Cyrus IMAP
%{__make} install DESTDIR=%{buildroot}

# 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 %{buildroot}%{perl_sitelib}
%{__rm} -rf %{buildroot}%{perl_sitearch}

# Cyrus IMAP Perl modules
cd perl/imap
%perl_process_packlist -n perl-Cyrus-IMAP
cd -

# Cyrus SIEVE managesieve Perl modules
cd perl/sieve/managesieve
%perl_process_packlist -n perl-Cyrus-SIEVE-managesieve
cd -

# after make install we can remove stuff we don't want in our packages
%{__rm} -f doc/Makefile.dist*
%{__rm} -rf doc/man
%{__rm} -f doc/text/htmlstrip.c
%{__rm} -f doc/text/Makefile
%{__rm} -f tools/config2*

# remove Perl bootstrap files
find %{buildroot}%{perl_vendorarch}/ -name '*.bs' -type f -exec %{__rm} {} \;

# create /var/* directories
%{__install} -d -m 750 %{buildroot}%{_var}/lib/imap/{db,log,msg,proc,quota,socket,user}
%{__install} -d -m 700 %{buildroot}%{_var}/lib/imap/ptclient
%{__install} -d -m 750 %{buildroot}%{_var}/lib/sieve
%{__install} -d -m 750 %{buildroot}%{_var}/spool/imap
%{__install} -d -m 750 %{buildroot}%{_var}/adm/backup/imap
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 %{buildroot}%{_var}/lib/imap/user/$i
    %{__install} -d -m 755 %{buildroot}%{_var}/lib/imap/quota/$i
    %{__install} -d -m 750 %{buildroot}%{_var}/lib/sieve/$i

# sysconfig
%{__install} -d %{buildroot}%{_var}/adm/fillup-templates
%{__install} -m 644 SUSE/sysconfig.cyrus-imapd %{buildroot}%{_var}/adm/fillup-templates/sysconfig.%{_servicename}

%if 0%{?with_systemd}
# systemd
%{__install} -d %{buildroot}{%{_unitdir},%{_sbindir},%{_sysconfdir}/profile.d}
%{__install} -m 644 SUSE/cyrus-imapd.service %{buildroot}%{_unitdir}/%{_servicename}.service
%if 0%{?suse_version} >= 1310
%{__ln_s} %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{_servicename}
%{__ln_s} /sbin/service %{buildroot}%{_sbindir}/rc%{_servicename}
echo 'alias rccyrus >/dev/null 2>&1 || alias rccyrus=%{_sbindir}/rc%{_servicename}' > %{buildroot}%{_sysconfdir}/profile.d/%{name}.alias.sh
# sysvinit
%{__install} -d %{buildroot}{%{_sysconfdir}/init.d,%{_sbindir}}
%{__install} -m 755 SUSE/rc.cyrus %{buildroot}%{_initrddir}/%{_servicename}
%{__ln_s} %{_initrddir}/%{_servicename} %{buildroot}%{_sbindir}/rc%{_servicename}

# cron
%{__install} -d %{buildroot}%{_sysconfdir}/cron.daily
%{__install} -m 755 SUSE/cron.daily.cyrus %{buildroot}%{_sysconfdir}/cron.daily/suse.de-%{name}

# pam
%{__install} -d %{buildroot}%{_sysconfdir}/pam.d
%{__install} -m 644 SUSE/imap %{buildroot}%{_sysconfdir}/pam.d/imap
%{__install} -m 644 SUSE/pop %{buildroot}%{_sysconfdir}/pam.d/pop
%{__install} -m 644 SUSE/sieve %{buildroot}%{_sysconfdir}/pam.d/sieve

# SuSEfirewall2
%{__install} -d %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/
%{__install} -m 644 SUSE/SuSEfirewall2.%{name} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}

# default config
%{__install} -m 644 SUSE/imapd.conf %{buildroot}%{_sysconfdir}/imapd.conf
%{__install} -m 644 SUSE/imapd.annotations.conf %{buildroot}%{_sysconfdir}/imapd.annotations.conf
%{__install} -m 644 SUSE/cyrus.conf %{buildroot}%{_sysconfdir}/cyrus.conf

%{__install} -m 644 SUSE/DB_CONFIG %{buildroot}%{_var}/lib/imap/db

# tools
%{__install} -d %{buildroot}%{_prefix}/lib/cyrus/tools
%{__install} -m 755 tools/* %{buildroot}%{_prefix}/lib/cyrus/tools/

# snmp
%{__install} -d %{buildroot}%{_datadir}/snmp/mibs/
%{__install} -m 644 %{SOURCE1} %{buildroot}%{_datadir}/snmp/mibs/CMU.mib
%{__install} -m 644 master/CYRUS-MASTER.mib %{buildroot}%{_datadir}/snmp/mibs/CYRUS-MASTER.mib

# rename manual to avoid conflicts
%{__mv} %{buildroot}%{_mandir}/man8/master.8 %{buildroot}%{_mandir}/man8/cyrus_master.8
%{__mv} %{buildroot}%{_mandir}/man8/idled.8 %{buildroot}%{_mandir}/man8/cyrus_idled.8
%{__mv} %{buildroot}%{_mandir}/man8/fetchnews.8 %{buildroot}%{_mandir}/man8/cyrus_fetchnews.8

getent group %{cyrus_group} >/dev/null || groupadd -r %{cyrus_group}
getent passwd %{cyrus_user} >/dev/null || useradd -r -o -g %{cyrus_group} -u %{cyrus_uid} -d /var/lib/imap -s /sbin/nologin -c "user for %{name}" %{cyrus_user}
usermod -d /var/lib/imap %{cyrus_user} || :
exit 0
%if 0%{?with_systemd}
%{service_add_pre %{_servicename}.service}

%if 0%{?with_systemd}
%{service_del_preun %{_servicename}.service}
%{stop_on_removal %{_servicename}}

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`" && {
test -n "`find var/lib/imap -type f`" && {
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
%if 0%{?with_systemd}
%{fillup_only %{_servicename}}
%{service_add_post %{_servicename}.service}
%{fillup_and_insserv %{_servicename}}

%if 0%{?with_systemd}
%{service_del_postun %{_servicename}.service}
%{restart_on_update %{_servicename}}

%defattr(-, root, root)
%config %{_sysconfdir}/pam.d/*
%config %{_sysconfdir}/cron.daily/suse.de-%{name}
%config(noreplace) %{_sysconfdir}/imapd.conf
%config(noreplace) %{_sysconfdir}/imapd.annotations.conf
%config(noreplace) %{_sysconfdir}/cyrus.conf
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%dir %attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/log
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/msg
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/proc
%attr(0700, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/ptclient
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/quota
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/socket
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/user
%dir %attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/imap/db
%config(noreplace) %{_var}/lib/imap/db/DB_CONFIG
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/lib/sieve
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/spool/imap
%attr(0750, %{cyrus_user}, %{cyrus_group}) %{_var}/adm/backup/imap
%config %{_var}/adm/fillup-templates/sysconfig.%{_servicename}
%if 0%{?with_systemd}
%config %{_sysconfdir}/profile.d/%{name}.alias.sh
%doc %{_mandir}/man3/imclient.3.gz
%doc %{_mandir}/man5/*.gz
%doc %{_mandir}/man8/*.gz
%doc COPYRIGHT README README.andrew doc master/conf

%files snmp
%defattr(-, root, root)

%files snmp-mibs
%defattr(-, root, root)
%dir %{_datadir}/snmp
%dir %{_datadir}/snmp/mibs

%files utils
%defattr(-, root, root)
%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

%files -n cyradm
%defattr(-, root, root)
%doc %{_mandir}/man1/cyradm.1.gz

%files -n perl-Cyrus-IMAP
%defattr(-, root, root)
%dir %{perl_vendorarch}/Cyrus
%dir %{perl_vendorarch}/auto/Cyrus
%if %{suse_version} < 1140
%doc %{_mandir}/man3/Cyrus::IMAP*

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

%files devel
%defattr(-, root, root)
%dir %{_includedir}/cyrus