File kopano.spec of Package kopano

#
# spec file for package kopano
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 Kopano B.V.
#
# 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 version_unconverted 8.3.2

Name:           kopano
Version:        8.3.2
Release:        0
Summary:        Collaboration software for professionals
License:        AGPL-3.0
Group:          Productivity/Networking/Email/Servers
Url:            https://kopano.io/
Source:         kopanocore-%version.tar.xz
Source3:        %name-rpmlintrc
Source4:        build.collax
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  gcc-c++
BuildRequires:  gettext-devel
BuildRequires:  gperftools-devel
BuildRequires:  gsoap-devel >= 2.8.39
BuildRequires:  krb5-devel
BuildRequires:  libcom_err-devel
BuildRequires:  libcurl-devel
BuildRequires:  libical-devel >= 0.42
BuildRequires:  libicu-devel
BuildRequires:  libs3-devel
BuildRequires:  libtool
BuildRequires:  libuuid-devel
BuildRequires:  libvmime-devel >= 0.9.1.999
BuildRequires:  libxml2-devel
BuildRequires:  ncurses-devel
BuildRequires:  openldap2-devel
BuildRequires:  pam-devel
%if 0%{?suse_version} > 1320
BuildRequires:  php7-devel
%else
BuildRequires:  php-devel
%endif
BuildRequires:  pkgconfig
BuildRequires:  python-devel >= 2.4
BuildRequires:  swig
BuildRequires:  xz
BuildRequires:  zlib-devel
%if 0%{?suse_version}
BuildRequires:  fdupes
%endif
%if 0%{?rhel_version} >= 700 || 0%{?centos_version} >= 700
BuildRequires:  elinks
%else
BuildRequires:  w3m
%endif
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
BuildRequires:  mysql-devel >= 4.1
BuildRequires:  openssl-devel
%endif
%if 0%{?fedora_version} && 0%{?fedora_version} >= 16
BuildRequires:  xapian-core-libs
%else
BuildRequires:  python-xapian
%endif
%if 0%{?suse_version}
BuildRequires:  python-xml
%else
BuildRequires:  libxml2-python
%endif
%if 0%{?suse_version}
BuildRequires:  libmysqlclient-devel >= 4.1
BuildRequires:  libopenssl-devel
# Satisfy Requires(pre) for bs_worker's rpmlint run
BuildRequires:  pwdutils
%endif
%if "%_repository" == "RHEL_6" || "%_repository" == "RHEL_6_PHP_56"
BuildRequires:  devtoolset-6-gcc-c++
%endif
%if "%{?_initddir}" == ""
	%define _initddir %_initrddir
	%define old_rpm 1
%endif
%if 0%{?suse_version}
	%define apache_group www
%else
	%define apache_group apache
%endif
%if "%_repository" == "RHEL_6_PHP_56" || "%_repository" == "RHEL_7_PHP_56"
	%define phpconfig /opt/rh/rh-php56/root/usr/bin/php-config
%else
	%define phpconfig php-config
%endif
%define phpextdir	%(%phpconfig --extension-dir)

%description
Kopano provides email storage on the server side and brings its own
Ajax-based mail client called WebAccess. Kopano is designed to
integrate with Kopano WebApp, Push clients and other mail services as an
alternative to Microsoft Exchange and other comparable mail servers.
Personal address book, calendar, notes and tasks, "Public Folders" and shared
calendar functionalities (inviting internal and external users,
resource management) can be handled by the software as well.

%package archiver
Summary:        Hierarchial Storage Management for the Kopano Core platform
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-lang = %version

%description archiver
The Kopano Archiver provides a Hierarchical Storage Management (HSM)
solution for the Kopano Core.

To decrease the database size of your production Kopano server, the
Kopano Archiver copies or moves messages to a secondary Kopano
server. Clients will still be able to open the message from the
secondary Kopano server directly.

%package backup
Summary:        Utility to back up and restore Kopano stores
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common
Requires:       python-kopano

%description backup
kopano-backup is a MAPI-level backup/restore tool. It can sync
complete users/stores to disk using ICS to incrementally sync the
respective MAPI items, and can process stores in parallel.

%package migration-pst
Summary:        Utility to import PST files
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common
Requires:       python-kopano

%description migration-pst
kopano-migration-pst is a utility to import PST files into Kopano. As PST
files are basically MAPI dumps, and Kopano also uses MAPI internally, there
should be practically no data loss, even including calendar data.

%package migration-imap
Summary:        Utility to migrate between IMAP mailboxes
Group:          Productivity/Networking/Email/Servers
BuildArch:      noarch

%description migration-imap
kopano-migration-imap provides a utility based on imapsync to migrate
between IMAP mailboxes (including Kopano).

%package bash-completion
Summary:        bash TAB completion for Kopano Core command-line utilities
Group:          System/Shells
Requires:       bash-completion
BuildArch:      noarch

%description bash-completion
Some kopano commands offer bash completion, but it is an optional
feature.

%package client
Summary:        Kopano MAPI provider library
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common = %version
Requires:       kopano-lang = %version
# Shares /etc/mapi/*.inf
Conflicts:      zarafa-client

%description client
Library which provides the main MAPI service to interface with a
Kopano server. This package is required by all Kopano client
programs.

%package common
Summary:        Shared files for Kopano Core services
Group:          Productivity/Networking/Email/Servers
%if 0%{?suse_version}
Requires:       cron
%else
Requires:       cronie
%endif
Requires:       logrotate
Requires(pre):  %_sbindir/groupadd
Requires(pre):  %_sbindir/useradd
%if 0%{?distro_without_intelligent_package_manager}
Obsoletes:      libkcservice0
Obsoletes:      libkcsoapclient0
Obsoletes:      libkcsoapserver0
%endif

%description common
Common components for services of Kopano Core.

%package compat
Summary:        Old module name support for Kopano
Group:          Development/Languages
Obsoletes:      python-zarafa < 8
Provides:       python-zarafa = %version-%release

%description compat
Provides some files under old module names.

%package contacts
Summary:        MAPI provider adding contact folders in the addressbook
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-client = %version
Requires:       kopano-common = %version
# Shares /etc/mapi files
Conflicts:      zarafa-contacts

%description contacts
An additional MAPI provider which finds all contact folders of a user
and adds the contents transparently into the MAPI addrbook.

%package dagent
Summary:        E-Mail Delivery Agent for the Kopano platform
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common
Requires:       kopano-lang = %version
Requires:       php
Requires:       php-mapi

%description dagent
Delivers incoming e-mail from your SMTP server to stores in the
Kopano server.

%package devel
Summary:        C++ development files for Kopano Core
Group:          Development/Libraries/C and C++
Requires:       kopano-common = %version
Requires:       libkcarchiver0 = %version-%release
Requires:       libkcarchivercore0 = %version-%release
Requires:       libkcfreebusy0 = %version-%release
Requires:       libkcicalmapi0 = %version-%release
Requires:       libkcinetmapi0 = %version-%release
Requires:       libkcmapi0 = %version-%release
Requires:       libkcserver0 = %version-%release
Requires:       libkcsoap0 = %version-%release
Requires:       libkcssl0 = %version-%release
Requires:       libkcsync0 = %version-%release
Requires:       libkcutil0 = %version-%release
Requires:       libmapi1 = %version-%release

%description devel
Development files to create programs for use with Kopano Core.

%package gateway
Summary:        POP3 and IMAP Gateway for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common

%description gateway
The gateway enables other e-mail clients to connect through POP3 or
IMAP to the Kopano server to read their e-mail. With IMAP, it is also
possible to view the contents of other folders and subfolders. The
gateway can be configured to listen for POP3, POP3S, IMAP and/or
IMAPS.

%package ical
Summary:        ICal and CalDAV Gateway for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common

%description ical
The iCal/CalDAV gateway enables users to retrieve their calendar
using iCalendar compliant clients. The iCal/CalDAV gateway can be
configured to listen for HTTP and HTTPS requests.

%package lang
# More or less a copy of /usr/lib/rpm/suse_macros %%lang_package
Summary:        Translations for Kopano Core components
Group:          System/Localization

%description lang
Provides translations to various Kopano Core subpackages.

%package monitor
Summary:        Quota monitor for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common

%description monitor
Regularly checks stores for total usage. If a quota limit has been
exceeded, an e-mail will be internally sent to this account.

%package presence
Summary:        Kopano Core Presence Daemon
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common >= %version
Requires:       python-flask
Requires:       python-kopano
Requires:       python-sleekxmpp

%description presence
A daemon for collecting and exporting user presence information
across multiple protocols in a unified way. Supports XMPP and Spreed.
Clients can both query the daemon with presence information (for
example, the user is 'available' for XMPP and 'away' for Spreed) and
update presence information (for example, make a user 'available' on
Spreed). Queries and updates are performed with simple GET and PUT
requests, respectively, using a simple (and identical) JSON format.

%package search
Summary:        Indexed search engine for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common
Requires:       python-kopano
%if 0%{?fedora_version} == 20 || 0%{?fedora_version} == 21
Requires:       xapian-bindings
%else
Requires:       python-xapian
%endif
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
Requires:       elinks
%endif
Requires:       xapian-core

%description search
kopano-search creates indexes for messages and attachments per user.
When this service is running, search queries on the server will use
this index to quickly find messages and contents of attached
documents, enhancing the search performance of kopano-server.

%package server
Summary:        Server component for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common = %version
# Needed for createstore scripts' functionality
Requires:       kopano-utils

%description server
This package provides the key component of Kopano Core, providing the
server to which Kopano clients connect. The server requires a MySQL
server to use for storage.

%package server-packages
Summary:        Metapackage to install the entire Kopano Core stack
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-backup = %version
Requires:       kopano-dagent = %version
Requires:       kopano-gateway = %version
Requires:       kopano-ical = %version
Requires:       kopano-monitor = %version
Requires:       kopano-presence = %version
Requires:       kopano-search = %version
Requires:       kopano-server = %version
Requires:       kopano-spooler = %version
Requires:       kopano-utils = %version

%description server-packages
This package is merely meant to cause pulling in all the Kopano
server components.

%package spooler
Summary:        E-mail Spooler for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common
Requires:       kopano-lang = %version

%description spooler
The outgoing e-mail spooler. This service makes sure that e-mails
sent by clients are converted to Internet e-mail and forwarded to an
SMTP server.

%package utils
Summary:        Admin command-line utils for Kopano Core
Group:          Productivity/Networking/Email/Servers
Requires:       kopano-common = %version

%description utils
Command-line clients to control and check the Kopano server.

%package -n libkcfreebusy0
Summary:        Implementation of Free/Busy time scheduling
Group:          System/Libraries

%description -n libkcfreebusy0
RFC 5545

%package -n libkchl0
Summary:        RAII-based API for libmapi
Group:          System/Libraries

%description -n libkchl0

%package -n libkcicalmapi0
Summary:        iCal interface for MAPI
Group:          System/Libraries

%description -n libkcicalmapi0
Provides an interface between iCal and MAPI.

%package -n libkcinetmapi0
Summary:        Internet e-mail interface for MAPI
Group:          System/Libraries

%description -n libkcinetmapi0
Provides an interface to convert between RFC 5322 Internet e-mail and
MAPI messages.

%package -n libmapi1
Summary:        Kopano's implementation of the Messaging API
Group:          System/Libraries
Requires:       kopano-client >= %version

%description -n libmapi1
MAPI allows client programs to become (e-mail) messaging-enabled,
-aware, or -based by calling MAPI subsystem routines that interface
with certain messaging servers.

%package -n libkcarchiver0
Summary:        Library with shared Kopano archiver functionality
Group:          System/Libraries

%description -n libkcarchiver0
Library with shared archiver functionality for Kopano Core.

%package -n libkcarchivercore0
Summary:        Library with shared Kopano archiver functionality
Group:          System/Libraries

%description -n libkcarchivercore0
Library with shared archiver functionality for Kopano Core.

%package -n libkcserver0
Summary:        The Kopano Server library
Group:          System/Libraries

%description -n libkcserver0
This library contains the central server code which is responsible
for handling MAPI calls, storing it in the database, etc.

%package -n libkcsoap0
Summary:        Kopano's shared SOAP RPC related function collection library
Group:          System/Libraries

%description -n libkcsoap0
Shared functions used by both the client-side and server-side
contexts for interaction with the SOAP RPC layer.

%package -n libkcsync0
Summary:        Routines for synchronization in Kopano Core
Group:          System/Libraries

%description -n libkcsync0

%package -n libkcmapi0
Summary:        MAPI-related utility functions for Kopano Core
Group:          System/Libraries

%description -n libkcmapi0

%package -n libkcssl0
Summary:        SSL-related utility functions for Kopano Core
Group:          System/Libraries

%description -n libkcssl0

%package -n libkcutil0
Summary:        Miscellaneous utility functions for Kopano Core
Group:          System/Libraries

%description -n libkcutil0

%package -n php-mapi
Summary:        PHP bindings for MAPI
# php-ext is the one thing that can also request the "ZCONTACTS" provider
Group:          Development/Languages/PHP
Requires:       kopano-client = %version
Requires:       kopano-contacts = %version
Obsoletes:      php5-mapi
Provides:       php5-mapi

%description -n php-mapi
Using this module, you can create PHP programs which use MAPI calls
to interact with Kopano.

%package -n python-mapi
Summary:        Python bindings for MAPI
Group:          Development/Languages/Python
Requires:       kopano-client = %version
Obsoletes:      libkcpyconv0
Obsoletes:      libkcpydirector0
%if 0%{?suse_version}
%py_requires
%endif

%description -n python-mapi
Low-level (SWIG-generated) Python bindings for MAPI. Using this
module, you can create Python programs which use MAPI calls to
interact with Kopano.

%package -n python-kopano
Summary:        High-level Python bindings for Kopano
Group:          Development/Languages/Python
Requires:       python-dateutil
Requires:       python-mapi

%description -n python-kopano
Object-Oriented Python bindings for Kopano. Uses python-mapi to do
the low level work. Can be used for many common system administration
tasks.

%prep
%if 0%{?old_rpm}
echo Detected old RPM with broken _initddir
%endif
%setup -qn kopanocore-%version

%build
autoreconf -fi
export CFLAGS="%optflags"
export CXXFLAGS="$CFLAGS"
if [ -x /opt/rh/devtoolset-6/root/usr/bin/gcc ]; then
	export CC="/opt/rh/devtoolset-6/root/usr/bin/gcc"
	export CXX="/opt/rh/devtoolset-6/root/usr/bin/g++"
fi
export LDFLAGS="-Wl,-z -Wl,relro"
%if 0%{?centos_version} == 600
# CO6's ncurses-config is messed up
export LIBS="-ltinfo"
%endif

mkdir obj
pushd obj/
%define _configure ../configure

%configure \
%if 0%{?suse_version}
	--with-distro=suse \
%endif
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
	--with-distro=rhel \
%endif
	--docdir="%_docdir/%name" \
	--with-userscript-prefix="%_sysconfdir/kopano/userscripts" \
	--with-quotatemplate-prefix="%_sysconfdir/kopano/quotamail" \
	--with-php-config="%phpconfig" \
	--enable-epoll --enable-unicode \
	--disable-static --enable-release --enable-icu
echo "%version" >version
# Same as kopano.io
echo "15" >revision
make V=1 %{?_smp_mflags}

%install
b="%buildroot"
make -C obj/ install DESTDIR="$b"

find "$b" -type f -name "*.la" -print -delete
# no headers for these:
rm -Rfv "$b/%_libdir/libkcpyconv.so" "$b/%_libdir/libkcpydirector.so"

mkdir -p "$b/%_defaultdocdir"
%if "%{?_initddir}" != "%_sysconfdir/init.d"
mkdir -p "$b/%_initddir"
mv "$b/%_sysconfdir/init.d"/* "$b/%_initddir/"
%endif

mkdir -p "$b/%_localstatedir/log/kopano"
chmod 750 "$b/%_localstatedir/log/kopano"
%find_lang kopano

%if 0%{?fdupes:1}
%fdupes %buildroot/%_prefix
%endif

%post migration-pst
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :

%post backup
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :

%post   client -p /sbin/ldconfig
%postun client -p /sbin/ldconfig

%pre common
%_bindir/getent group kopano >/dev/null 2>/dev/null || \
	%_sbindir/groupadd -r kopano
%_bindir/getent passwd kopano >/dev/null 2>/dev/null || \
	%_sbindir/useradd -c "Kopano unprivileged account" \
	-g kopano -r kopano

%post common
%if 0%{?suse_version}
%fillup_only
%endif
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
chown kopano:kopano /var/lib/kopano 2>/dev/null || :
if [ -x /usr/bin/systemd-tmpfiles ]; then
	/usr/bin/systemd-tmpfiles --create kopano-tmpfiles.conf || :
fi

%post   contacts -p /sbin/ldconfig
%postun contacts -p /sbin/ldconfig

%pre dagent
%{?_unitdir:%{?suse_version:%service_add_pre kopano-dagent.service}}

%post dagent
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-dagent.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-dagent.service}}

%preun dagent
%{?_unitdir:%{?suse_version:%service_del_preun kopano-dagent.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-dagent.service}}
%{!?_unitdir:%stop_on_removal kopano-dagent}

%postun dagent
%{?_unitdir:%{?suse_version:%service_del_postun kopano-dagent.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-dagent.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-dagent}

%post devel -p /sbin/ldconfig
%postun devel -p /sbin/ldconfig

%pre gateway
%{?_unitdir:%{?suse_version:%service_add_pre kopano-gateway.service}}

%post gateway
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-gateway.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-gateway.service}}

%preun gateway
%{?_unitdir:%{?suse_version:%service_del_preun kopano-gateway.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-gateway.service}}
%{!?_unitdir:%stop_on_removal kopano-gateway}

%postun gateway
%{?_unitdir:%{?suse_version:%service_del_postun kopano-gateway.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-gateway.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-gateway}

%pre ical
%{?_unitdir:%{?suse_version:%service_add_pre kopano-ical.service}}

%post ical
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-ical.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-ical.service}}

%preun ical
%{?_unitdir:%{?suse_version:%service_del_preun kopano-ical.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-ical.service}}
%{!?_unitdir:%stop_on_removal kopano-ical}

%postun ical
%{?_unitdir:%{?suse_version:%service_del_postun kopano-ical.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-ical.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-ical}

%pre monitor
%{?_unitdir:%{?suse_version:%service_add_pre kopano-monitor.service}}

%post monitor
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-monitor.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-monitor.service}}

%preun monitor
%{?_unitdir:%{?suse_version:%service_del_preun kopano-monitor.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-monitor.service}}
%{!?_unitdir:%stop_on_removal kopano-monitor}

%postun monitor
%{?_unitdir:%{?suse_version:%service_del_postun kopano-monitor.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-monitor.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-monitor}

%pre presence
%{?_unitdir:%{?suse_version:%service_add_pre kopano-presence.service}}

%post presence
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-presence.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-presence.service}}

%preun presence
%{?_unitdir:%{?suse_version:%service_del_preun kopano-presence.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-presence.service}}
%{!?_unitdir:%stop_on_removal kopano-presence}

%postun presence
%{?_unitdir:%{?suse_version:%service_del_postun kopano-presence.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-presence.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-presence}

%pre search
%{?_unitdir:%{?suse_version:%service_add_pre kopano-search.service}}

%post search
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-search.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-search.service}}

%preun search
%{?_unitdir:%{?suse_version:%service_del_preun kopano-search.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-search.service}}
%{!?_unitdir:%stop_on_removal kopano-search}

%postun search
%{?_unitdir:%{?suse_version:%service_del_postun kopano-search.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-search.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-search}

%pre server
%{?_unitdir:%{?suse_version:%service_add_pre kopano-server.service}}

%post server
if echo "%_libdir" | grep -q lib64; then
	sed -i 's/^\( *plugin_path.*\)\/lib\/\(.*\)$/\1\/lib64\/\2/g' %_sysconfdir/kopano/server.cfg
fi
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-server.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-server.service}}

%preun server
%{?_unitdir:%{?suse_version:%service_del_preun kopano-server.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-server.service}}
%{!?_unitdir:%stop_on_removal kopano-server}

%postun server
%{?_unitdir:%{?suse_version:%service_del_postun kopano-server.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-server.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-server}

%triggerun server -- kopano-server
if [ "$1" -eq 2 ]; then
	# On update from kopano-server-X to kopano-server-Y…
	# propmap.cfg is now untracked (as desired).
	if [ ! -e "%_sysconfdir/kopano/ldap.propmap.cfg" -a \
	     -e "%_sysconfdir/kopano/ldap.propmap.cfg.rpmsave" ]; \
	then
		# A rename occured because of private modifications.
		# Put it back in its place.
		mv -v "%_sysconfdir/kopano/ldap.propmap.cfg.rpmsave" \
			"%_sysconfdir/kopano/ldap.propmap.cfg"
	elif grep -q ldap.propmap.cfg "%_sysconfdir/kopano/server.cfg"; then
		# No private modifications. Make sure it exists,
		# if loosely referenced.
		ln -Tsv "%_datadir/kopano/ldap.propmap.cfg" \
			"%_sysconfdir/kopano/ldap.propmap.cfg"
	fi
fi

%pre spooler
%{?_unitdir:%{?suse_version:%service_add_pre kopano-spooler.service}}

%post spooler
chown -Rh kopano:kopano /var/log/kopano 2>/dev/null || :
%{?_unitdir:%{?suse_version:%service_add_post kopano-spooler.service}}
%{?_unitdir:%{!?suse_version:%systemd_post kopano-spooler.service}}

%preun spooler
%{?_unitdir:%{?suse_version:%service_del_preun kopano-spooler.service}}
%{?_unitdir:%{!?suse_version:%systemd_preun kopano-spooler.service}}
%{!?_unitdir:%stop_on_removal kopano-spooler}

%postun spooler
%{?_unitdir:%{?suse_version:%service_del_postun kopano-spooler.service}}
%{?_unitdir:%{!?suse_version:%systemd_postun_with_restart kopano-spooler.service}}
%{!?_unitdir:%insserv_cleanup}
%{!?_unitdir:%restart_on_update kopano-spooler}

%post   -n libkcfreebusy0 -p /sbin/ldconfig
%postun -n libkcfreebusy0 -p /sbin/ldconfig
%post   -n libkchl0 -p /sbin/ldconfig
%postun -n libkchl0 -p /sbin/ldconfig
%post   -n libkcicalmapi0 -p /sbin/ldconfig
%postun -n libkcicalmapi0 -p /sbin/ldconfig
%post   -n libkcinetmapi0 -p /sbin/ldconfig
%postun -n libkcinetmapi0 -p /sbin/ldconfig
%post   -n libmapi1 -p /sbin/ldconfig
%postun -n libmapi1 -p /sbin/ldconfig
%post   -n libkcarchiver0 -p /sbin/ldconfig
%postun -n libkcarchiver0 -p /sbin/ldconfig
%post   -n libkcarchivercore0 -p /sbin/ldconfig
%postun -n libkcarchivercore0 -p /sbin/ldconfig
%post   -n libkcserver0 -p /sbin/ldconfig
%postun -n libkcserver0 -p /sbin/ldconfig
%post   -n libkcsoap0 -p /sbin/ldconfig
%postun -n libkcsoap0 -p /sbin/ldconfig
%post   -n libkcsync0 -p /sbin/ldconfig
%postun -n libkcsync0 -p /sbin/ldconfig
%post   -n libkcmapi0 -p /sbin/ldconfig
%postun -n libkcmapi0 -p /sbin/ldconfig
%post   -n libkcssl0 -p /sbin/ldconfig
%postun -n libkcssl0 -p /sbin/ldconfig
%post   -n libkcutil0 -p /sbin/ldconfig
%postun -n libkcutil0 -p /sbin/ldconfig
%post   -n python-mapi -p /sbin/ldconfig
%postun -n python-mapi -p /sbin/ldconfig

%files archiver
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%attr(0640,root,kopano) %config(noreplace) %_sysconfdir/kopano/archiver.cfg
%_sbindir/kopano-archiver
%_mandir/man*/kopano-archiver*
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/archiver.cfg

%files backup
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%attr(0640,root,kopano) %config(noreplace) %_sysconfdir/kopano/backup.cfg
%_sbindir/kopano-backup
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/backup.cfg
%_mandir/man*/kopano-backup.*
%python_sitelib/kopano_backup/
%python_sitelib/kopano_backup-*.egg-info

%files migration-pst
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%attr(0640,root,kopano) %config(noreplace) %_sysconfdir/kopano/migration-pst.cfg
%_sbindir/kopano-migration-pst
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/migration-pst.cfg
%_mandir/man*/kopano-migration-pst.*
%python_sitelib/kopano_migration_pst/
%python_sitelib/kopano_migration_pst-*.egg-info

%files migration-imap
%defattr(-,root,root)
%_bindir/kopano-migration-imap

%files bash-completion
%defattr(-,root,root)
%dir %_sysconfdir/bash_completion.d
%config %_sysconfdir/bash_completion.d/kopano-bash-completion.sh

%files client -f kopano.lang
%defattr(-,root,root)
%dir %_sysconfdir/mapi
%config(noreplace) %_sysconfdir/mapi/kopano.inf
%exclude %_datadir/locale
%dir %_libdir/kopano
%_libdir/kopano/libkcclient.so
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/kopano.inf

%files common
%defattr(-,root,root)
%config(noreplace) %_sysconfdir/cron.daily/kopano*
%config(noreplace) %_sysconfdir/logrotate.d/*
%doc AGPL-3
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
%_sysconfdir/sysconfig/kopano
%endif
%dir %_prefix/lib/systemd/
%dir %_prefix/lib/systemd/system/
%_prefix/lib/sysusers.d/
%_prefix/lib/tmpfiles.d/
%_mandir/man7/kopano.7*
%if 0%{?suse_version}
/var/adm/fillup-templates/sysconfig.kopano
%endif
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/

%files compat
%defattr(-,root,root)
%python_sitelib/zarafa/
%python_sitelib/zarafa-*.egg-info

%files contacts
%defattr(-,root,root)
%dir %_sysconfdir/mapi
%config(noreplace) %_sysconfdir/mapi/zcontacts.inf
%dir %_libdir/kopano
%_libdir/kopano/libkccontacts.so
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/zcontacts.inf

%files dagent
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%verify(not mode) %config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/autorespond
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/dagent.cfg
%_initddir/kopano-dagent
%_sbindir/kopano-autorespond
%_sbindir/kopano-dagent
%_sbindir/kopano-mr-accept
%_sbindir/kopano-mr-process
%_prefix/lib/systemd/system/kopano-dagent.service
%_datadir/kopano-dagent/
%_mandir/man*/kopano-autorespond.*
%_mandir/man*/kopano-mr-accept.*
%_mandir/man*/kopano-mr-process.*
%_mandir/man*/kopano-dagent.*
%attr(0750,kopano,kopano) %dir %_localstatedir/lib/kopano
%attr(0750,kopano,kopano) %_localstatedir/lib/kopano/dagent
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/autorespond
%_docdir/kopano/example-config/dagent.cfg

%files devel
%defattr(-,root,root)
%_includedir/*
%_libdir/libkcfreebusy.so
%_libdir/libkchl.so
%_libdir/libkcicalmapi.so
%_libdir/libkcinetmapi.so
%_libdir/libmapi.so
%_libdir/libkcarchivercore.so
%_libdir/libkcarchiver.so
%_libdir/libkcserver.so
%_libdir/libkcsoap.so
%_libdir/libkcsync.so
%_libdir/libkcmapi.so
%_libdir/libkcssl.so
%_libdir/libkcutil.so
%_libdir/pkgconfig/*
%_datadir/gdb/

%files gateway
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/gateway.cfg
%_initddir/kopano-gateway
%_sbindir/kopano-gateway
%_prefix/lib/systemd/system/kopano-gateway.service
%_mandir/man*/kopano-gateway.*
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/gateway.cfg
%dir %_docdir/kopano-gateway
%_docdir/kopano-gateway/optimize-imap.*

%files ical
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/ical.cfg
%_initddir/kopano-ical
%_sbindir/kopano-ical
%_prefix/lib/systemd/system/kopano-ical.service
%_mandir/man*/kopano-ical.*
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/ical.cfg

%files lang -f kopano.lang
%defattr(-,root,root)

%files monitor
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%config %_sysconfdir/kopano/quotamail
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/monitor.cfg
%_initddir/kopano-monitor
%_sbindir/kopano-monitor
%_prefix/lib/systemd/system/kopano-monitor.service
%_mandir/man*/kopano-monitor.*
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/monitor.cfg

%files presence
%defattr(-,root,root)
%dir %_sysconfdir/kopano/
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/presence.cfg
%_initddir/kopano-presence
%_sbindir/kopano-presence
%dir %_prefix/lib/systemd
%dir %_prefix/lib/systemd/system
%_prefix/lib/systemd/system/kopano-presence.service
%dir %_datadir/kopano
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/presence.cfg
%python_sitelib/kopano_presence/
%python_sitelib/kopano_presence-*.egg-info

%files search
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/search.cfg
%_initddir/kopano-search
%_sbindir/kopano-search
%_sbindir/kopano-search-xapian-compact.py
%_prefix/lib/systemd/system/kopano-search.service
%dir %_sysconfdir/kopano/searchscripts
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/searchscripts/*.db
%config(noreplace) %attr(-,root,kopano) %_sysconfdir/kopano/searchscripts/*.xslt
%config(noreplace) %attr(-,root,kopano) %_sysconfdir/kopano/searchscripts/attachments_parser
%config(noreplace) %attr(-,root,kopano) %_sysconfdir/kopano/searchscripts/zmktemp
%_mandir/man*/kopano-search.*
%attr(0750,kopano,kopano) %dir %_localstatedir/lib/kopano
%attr(0750,kopano,kopano) %dir %_localstatedir/lib/kopano/search
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano/
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/search.cfg
%python_sitelib/kopano_search/
%python_sitelib/kopano_search-*.egg-info

%files server
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%dir %_sysconfdir/kopano/userscripts
%dir %_sysconfdir/kopano/userscripts/createcompany.d
%dir %_sysconfdir/kopano/userscripts/creategroup.d
%dir %_sysconfdir/kopano/userscripts/createuser.d
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/unix.cfg
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/server.cfg
%_sysconfdir/kopano/userscripts/*.sh
%_sysconfdir/kopano/userscripts/create*/*
%_sysconfdir/kopano/userscripts/createcompany
%_sysconfdir/kopano/userscripts/creategroup
%_sysconfdir/kopano/userscripts/createuser
%_sysconfdir/kopano/userscripts/deletecompany
%_sysconfdir/kopano/userscripts/deletegroup
%_sysconfdir/kopano/userscripts/deleteuser
%_initddir/kopano-server
%_sbindir/kopano-server
%_libdir/kopano/dbplugin.so
%_libdir/kopano/unixplugin.so
%_libdir/kopano/ldapplugin.so
%_libdir/kopano/ldapmsplugin.so
%_prefix/lib/systemd/system/kopano-server.service
%_mandir/man*/kopano-server.*
%_mandir/man*/kopano-ldap.cfg.*
%_mandir/man*/kopano-unix.cfg.*
%attr(0750,kopano,kopano) %dir %_localstatedir/lib/kopano
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano
%dir %_datadir/kopano
%_datadir/kopano/ldap.active-directory.cfg
%_datadir/kopano/ldap.openldap.cfg
%_datadir/kopano/ldap.propmap.cfg
%dir %_docdir/kopano
%_docdir/kopano/audit-parse.pl
%_docdir/kopano/createuser.dotforward
%_docdir/kopano/db-calc-storesize
%_docdir/kopano/db-convert-attachments-to-files
%_docdir/kopano/db-remove-orphaned-attachments
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/ldap.cfg
%_docdir/kopano/example-config/server.cfg
%_docdir/kopano/example-config/unix.cfg
%_docdir/kopano/ldap-switch-sendas.pl
%_docdir/kopano/ssl-certificates.sh
%_docdir/kopano/update-resource-recipients
%_docdir/kopano/kopano.ldif
%_docdir/kopano/kopano.schema

%files server-packages
%defattr(-,root,root)
# We want it to be rather empty; but rpmlint does not like it empty.
%dir %_docdir/kopano

%files spooler
%defattr(-,root,root)
%dir %_sysconfdir/kopano
%config(noreplace) %attr(0640,root,kopano) %_sysconfdir/kopano/spooler.cfg
%_initddir/kopano-spooler
%_sbindir/kopano-spooler
%_prefix/lib/systemd/system/kopano-spooler.service
%_mandir/man*/kopano-spooler.*
%_datadir/kopano-spooler
%attr(0750,kopano,kopano) %dir %_localstatedir/lib/kopano
%attr(0750,kopano,kopano) %_localstatedir/lib/kopano/spooler
%attr(0750,kopano,kopano) %dir %_localstatedir/log/kopano
%dir %_docdir/kopano
%dir %_docdir/kopano/example-config
%_docdir/kopano/example-config/spooler.cfg

%files utils
%defattr(-,root,root)
%_bindir/kopano-set-oof
%_sbindir/kopano-admin
%_sbindir/kopano-archiver-aclset
%_sbindir/kopano-archiver-aclsync
%_sbindir/kopano-archiver-restore
%_sbindir/kopano-cachestat
%_sbindir/kopano-mailbox-permissions
%_sbindir/kopano-search-upgrade-findroots.py
%_bindir/kopano-fsck
%_bindir/kopano-passwd
%_bindir/kopano-stats
%_mandir/man*/kopano-admin.*
%_mandir/man*/kopano-cfgchecker.*
%_mandir/man*/kopano-fsck.*
%_mandir/man*/kopano-mailbox-permissions.*
%_mandir/man*/kopano-passwd.*
%_mandir/man*/kopano-set-oof.*
%_mandir/man*/kopano-stats.*
%dir %_libexecdir/kopano
%_libexecdir/kopano/mapitime

%files -n libkcfreebusy0
%defattr(-,root,root)
%_libdir/libkcfreebusy.so.0*

%files -n libkchl0
%defattr(-,root,root)
%_libdir/libkchl.so.0*

%files -n libkcicalmapi0
%defattr(-,root,root)
%_libdir/libkcicalmapi.so.0*

%files -n libkcinetmapi0
%defattr(-,root,root)
%_libdir/libkcinetmapi.so.0*

%files -n libmapi1
%defattr(-,root,root)
%_libdir/libmapi.so.1*

%files -n libkcarchiver0
%defattr(-,root,root)
%_libdir/libkcarchiver.so.0*

%files -n libkcarchivercore0
%defattr(-,root,root)
%_libdir/libkcarchivercore.so.0*

%files -n libkcserver0
%defattr(-,root,root)
%_libdir/libkcserver.so.0*

%files -n libkcsoap0
%defattr(-,root,root)
%_libdir/libkcsoap.so.0*

%files -n libkcsync0
%defattr(-,root,root)
%_libdir/libkcsync.so.0*

%files -n libkcmapi0
%defattr(-,root,root)
%_libdir/libkcmapi.so.0*

%files -n libkcssl0
%defattr(-,root,root)
%_libdir/libkcssl.so.0*

%files -n libkcutil0
%defattr(-,root,root)
%_libdir/libkcutil.so.0*

%files -n php-mapi
%defattr(-,root,root)
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
%if "%_repository" == "RHEL_6_PHP_56" || "%_repository" == "RHEL_7_PHP_56"
%dir /etc/opt/rh/rh-php56/php.d
%config(noreplace) /etc/opt/rh/rh-php56/php.d/mapi.ini
%else
%dir %_sysconfdir/php.d
%config(noreplace) %_sysconfdir/php.d/mapi.ini
%endif
%endif
%if 0%{?suse_version} >= 1330
%dir %_sysconfdir/php7
%dir %_sysconfdir/php7/conf.d
%config(noreplace) %_sysconfdir/php7/conf.d/mapi.ini
%endif
%if 0%{?suse_version} && 0%{?suse_version} < 1330
%if "%_repository" == "SLE_12_PHP7"
%dir %_sysconfdir/php7
%dir %_sysconfdir/php7/conf.d
%config(noreplace) %_sysconfdir/php7/conf.d/mapi.ini
%else
%dir %_sysconfdir/php5
%dir %_sysconfdir/php5/conf.d
%config(noreplace) %_sysconfdir/php5/conf.d/mapi.ini
%endif
%endif
%phpextdir/mapi*
%dir %_datadir/kopano/
%_datadir/kopano/php/
# laters!
#%_docdir/kopano/example-config/php-mapi.cfg
#%config(noreplace) %_sysconfdir/kopano/php-mapi.cfg

%files -n python-mapi
%defattr(-,root,root)
%_libdir/libkcpyconv.so.*
%_libdir/libkcpydirector.so.*
%python_sitelib/MAPI/
%python_sitelib/MAPI-*.egg-info
%python_sitelib/MAPICore.*
%python_sitelib/icalmapi.*
%python_sitelib/inetmapi.*
%python_sitearch/*MAPICore.*
%python_sitearch/*icalmapi.*
%python_sitearch/*inetmapi.*

%files -n python-kopano
%defattr(-,root,root)
%python_sitelib/%name/
%python_sitelib/%name-*.egg-info

%changelog
openSUSE Build Service is sponsored by