File kolab-syncroton.spec of Package kolab-syncroton

#
# spec file for package kolab-syncroton
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2021 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2014-2016 Aeneas Jaissle <aj@ajaissle.de>
# Copyright (c) 2012 Kolab Systems AG, Zuerich, Switzerland.
#
# 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 https://bugs.opensuse.org/
#


%define php_name %(php -r "print 'php' . PHP_MAJOR_VERSION;")
%define php_major %(php -r "print PHP_MAJOR_VERSION;")

%global roundcubepath %{apache_datadir}/roundcubemail
%global roundcubeconfigpath %{_sysconfdir}/roundcubemail

Name:           kolab-syncroton
Version:        2.4.2
Release:        0
Summary:        Kolab ActiveSync Server
License:        AGPL-3.0-or-later
Group:          Productivity/Networking/Other
URL:            https://kolab.org/about/syncroton
# was: http://cgit.kolab.org/syncroton/snapshot/syncroton-%%{name}-%%{version}.tar.gz
# 2.4.2 -> https://git.kolab.org/source/syncroton/browse/master/;418dc40be2c61e5e316b87ad8f0dc0f273edd252
Source0:        %{name}-%{version}.tar.gz
Source1:        %{name}-httpd.conf
Source2:        %{name}.logrotate
BuildRequires:  apache-rpm-macros
BuildRequires:  php-devel >= 7.0
# Requiring the plugin 'managesieve' and the configuration from roundcubemail
BuildRequires:  roundcubemail >= 1.5
# Requiring the plugins 'kolab_auth', 'kolab_folders', 'libkolab' from roundcubemail-plugins-kolab
BuildRequires:  roundcubemail-plugins-kolab >= 3.5
Requires:       php%{php_major}-libkolabxml1
Requires:       php%{php_major}-pear-Auth_SASL
Requires:       php%{php_major}-pear-MDB2
Requires:       php%{php_major}-pear-MDB2_Driver_mysqli
Requires:       php%{php_major}-pear-Mail_Mime
Requires:       php%{php_major}-pear-Mail_mimeDecode
Requires:       php%{php_major}-pear-Net_IDNA2
Requires:       php%{php_major}-pear-Net_SMTP
Requires:       php%{php_major}-pear-Net_Socket
Requires:       roundcube_framework >= 1.5
# Requiring the plugin 'managesieve' and the configuration from roundcubemail
Requires:       roundcubemail >= 1.5
# Requiring the plugins 'kolab_auth', 'kolab_folders', 'libkolab' from roundcubemail-plugins-kolab
Requires:       roundcubemail-plugins-kolab >= 3.5
Recommends:     logrotate
BuildArch:      noarch

%description
Kolab is a secure, scalable and reliable groupware server. It is formed by a
number of well-known and proven components and adds intelligent interaction between them.

Kolab Groupware provides ActiveSync for Calendars, Address Books
and Tasks though this package - based on Syncroton technology.

%prep
%setup -q

# remove unused .htaccess file
find . -type f -name ".htaccess" -delete
# remove executable bit from files that should not be executed
chmod -x \
    lib/ext/Syncroton/Backend/IFolder.php \
    lib/ext/Syncroton/Wbxml/Dtd/ActiveSync.php \
    lib/ext/Syncroton/Wbxml/Dtd/Factory.php \
    lib/ext/Syncroton/Wbxml/Dtd/Syncml.php

%build

%install
install -d \
    %{buildroot}%{apache_sysconfdir}/conf.d \
    %{buildroot}%{_sysconfdir}/logrotate.d \
    %{buildroot}%{_sysconfdir}/%{name} \
    %{buildroot}%{apache_datadir}/%{name} \
    %{buildroot}%{apache_datadir}/%{name}/config \
    %{buildroot}%{_localstatedir}/log/%{name}

# apache config
sed -e "s#__KOLAB_SYNCROTON_ROOT__#%{apache_datadir}/%{name}#g" %{SOURCE1} > \
  %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf

cp -a index.php %{buildroot}%{apache_datadir}/%{name}/index.php
cp -a lib %{buildroot}%{apache_datadir}/%{name}/lib

# var links
ln -s %{_localstatedir}/log/%{name} %{buildroot}%{apache_datadir}/%{name}/logs

# logrotate config
install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# roundcube plugins
mkdir -p %{buildroot}%{apache_datadir}/%{name}/lib/plugins/
for plugin in kolab_auth kolab_folders libkolab managesieve; do
    ln -s %{roundcubepath}/plugins/${plugin} %{buildroot}%{apache_datadir}/%{name}/lib/plugins/${plugin}
done

# roundcube configuration
for config in config defaults; do
    ln -s %{roundcubeconfigpath}/${config}.inc.php %{buildroot}%{apache_datadir}/%{name}/config/${config}.inc.php
done

%pre
if [ -L "%{apache_datadir}/%{name}/config" ]; then
    rm -rf "%{apache_datadir}/%{name}/config"
fi
for plugin in kolab_auth kolab_folders libkolab managesieve; do
    if [ -d "%{apache_datadir}/%{name}/lib/plugins/${plugin}" ]; then
        if ! [ -L "%{apache_datadir}/%{name}/lib/plugins/${plugin}" ]; then
            rm -rf "%{apache_datadir}/%{name}/lib/plugins/${plugin}"
        fi
    fi
done

%post
%{apache_datadir}/roundcubemail/bin/updatedb.sh \
    --dir %{_docdir}/%{name}/SQL/ \
    --package syncroton \
    >/dev/null 2>&1 || :
exit 0

%files
%license docs/LICENSE
%doc docs/SQL/ config/config.inc.php.dist
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%dir %{apache_datadir}/%{name}
%{apache_datadir}/%{name}/config/
%{apache_datadir}/%{name}/lib/
%{apache_datadir}/%{name}/index.php
%{apache_datadir}/%{name}/logs
%attr(0770,%{apache_user},%{apache_group}) %{_localstatedir}/log/%{name}

%changelog
openSUSE Build Service is sponsored by