File roundcubemail.spec of Package roundcubemail

#
# spec file for package roundcube
#
# Copyright (c) 2019 SUSE LINUX 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 https://bugs.opensuse.org/
#

# stick to php7 until we find out what happened to php8-imagick and php8-json
%if 0%{?suse_version} >= 1550
%define php_version 7
%else
%define php_version 7
%endif

%define roundcube_confdir    %{_sysconfdir}/%{name}/
%define roundcube_basedir    /srv/www/vhosts/%{name}/
%define roundcube_docroot    /srv/www/vhosts/%{name}/public/
%define roundcube_datadir    /srv/www/vhosts/%{name}/data/
%define roundcube_sessiondir /srv/www/vhosts/%{name}/sessions/
%define roundcube_tmpdir     /srv/www/vhosts/%{name}/tmp/
%define roundcube_logdir     /var/log/%{name}/
%define php_fpm_d      /etc/%{roundcube_php}/fpm/php-fpm.d/
%define ng_vhost_d     /etc/nginx/vhosts.d/
%define user_group_name _roundcubemail

Name:           roundcubemail
Version:        1.5.1
Release:        0
%define pkg_version %{version}
Summary:        The Roundcube Webmail suite
License:        AGPL-3.0
Group:          Productivity/Networking/Web/Utilities
URL:            https://roundcube.net/
Source:         https://github.com/roundcube/roundcubemail/releases/download/%{pkg_version}/roundcubemail-%{pkg_version}-complete.tar.gz
Source3:        roundcubemail-php-fpm.conf
Source4:        roundcubemail-nginx.conf
Source99:       roundcubemail-rpmlintrc
BuildArch:      noarch
BuildRequires:  acl
BuildRequires:  fdupes
BuildRequires:  nginx
BuildRequires:  %{roundcube_php}-bcmath
%requires_eq    %{roundcube_php}-bcmath
BuildRequires:  %{roundcube_php}-ctype
%requires_eq    %{roundcube_php}-ctype
BuildRequires:  %{roundcube_php}-curl
%requires_eq    %{roundcube_php}-curl
BuildRequires:  %{roundcube_php}-dom
%requires_eq    %{roundcube_php}-dom
BuildRequires:  %{roundcube_php}-fileinfo
%requires_eq    %{roundcube_php}-fileinfo
BuildRequires:  %{roundcube_php}-fpm
%requires_eq    %{roundcube_php}-fpm
BuildRequires:  %{roundcube_php}-gd
%requires_eq    %{roundcube_php}-gd
BuildRequires:  %{roundcube_php}-iconv
%requires_eq    %{roundcube_php}-iconv
BuildRequires:  %{roundcube_php}-imagick
%requires_eq    %{roundcube_php}-imagick
BuildRequires:  %{roundcube_php}-intl
%requires_eq    %{roundcube_php}-intl
%if "php7" == "%{roundcube_php}"
BuildRequires:  %{roundcube_php}-json
%requires_eq    %{roundcube_php}-json
%endif
BuildRequires:  %{roundcube_php}-mbstring
%requires_eq    %{roundcube_php}-mbstring
BuildRequires:  %{roundcube_php}-mysql
%requires_eq    %{roundcube_php}-mysql
BuildRequires:  %{roundcube_php}-openssl
%requires_eq    %{roundcube_php}-openssl
BuildRequires:  %{roundcube_php}-pcntl
%requires_eq    %{roundcube_php}-pcntl
BuildRequires:  %{roundcube_php}-pdo
%requires_eq    %{roundcube_php}-pdo
BuildRequires:  %{roundcube_php}-pear
%requires_eq    %{roundcube_php}-pear
BuildRequires:  %{roundcube_php}-phar
%requires_eq    %{roundcube_php}-phar
BuildRequires:  %{roundcube_php}-posix
%requires_eq    %{roundcube_php}-posix
BuildRequires:  %{roundcube_php}-redis
%requires_eq    %{roundcube_php}-redis
BuildRequires:  %{roundcube_php}-tokenizer
%requires_eq    %{roundcube_php}-tokenizer
BuildRequires:  %{roundcube_php}-xmlreader
%requires_eq    %{roundcube_php}-xmlreader
BuildRequires:  %{roundcube_php}-xmlwriter
%requires_eq    %{roundcube_php}-xmlwriter
BuildRequires:  %{roundcube_php}-zip
%requires_eq    %{roundcube_php}-zip
BuildRequires:  %{roundcube_php}-zlib
%requires_eq    %{roundcube_php}-zlib
BuildRequires:  pkgconfig
BuildRequires:  rsync
BuildRequires:  pkgconfig(systemd)
Requires(pre):  coreutils
Requires:       sudo
Requires(post): sudo
Requires:       acl
Recommends:     roundcube-nginx
Recommends:     roundcube-php-fpm
%{?systemd_requires}

%description
A browser-based multilingual IMAP client with an application-like user
interface. It provides full functionality you expect from an email client,
including MIME support, address book, folder manipulation, message searching
and spell checking.

%package php-fpm
Group:          Productivity/Networking/Web/Utilities
%requires_eq    %{roundcube_php}-fpm
Requires:       roundcubemail-apparmor
Requires:       roundcubemail = %{version}
Summary:        Roundcube - PHP FPM configuration
%description php-fpm
A browser-based multilingual IMAP client with an application-like user
interface. It provides full functionality you expect from an email client,
including MIME support, address book, folder manipulation, message searching
and spell checking.

This package holds the php-fpm configuration.

%package nginx
Group:          Productivity/Networking/Web/Utilities
Requires:       roundcubemail-php-fpm = %{version}
Requires:       nginx
Summary:        Roundcube - NGINX configuration
%description nginx
A browser-based multilingual IMAP client with an application-like user
interface. It provides full functionality you expect from an email client,
including MIME support, address book, folder manipulation, message searching
and spell checking.

This package holds the nginx configuration.


%prep
%autosetup -p1 -n %{name}-%{pkg_version}

%build
perl -p -i -e "s|RCUBE_INSTALL_PATH . 'logs/';|'%{roundcube_logdir}';|" \
    config/defaults.inc.php
perl -p -i -e "s|RCUBE_INSTALL_PATH . 'temp/';|'%{roundcube_tmpdir}';|" \
    config/defaults.inc.php

rm -rf logs
rm -rf temp

perl -p -i -e "s|\(INSTALL_PATH . 'config'\)|'%{roundcube_confdir}'|" \
    program/include/iniset.php
cp config/config.inc.php.sample config/config.inc.php
rm config/.htaccess

perl -p -i -e 's|/usr/bin/env php|/usr/bin/php|g' bin/*
chmod a-x                                      \
  vendor/endroid/qr-code/composer.json         \
  vendor/endroid/qr-code/src/Exceptions/*.php  \
  vendor/endroid/qr-code/src/QrCode.php        \
  vendor/endroid/qr-code/tests/QrCodeTest.php  \
  vendor/endroid/qr-code/assets/data/*.dat     \
  vendor/pear/auth_sasl/Auth/SASL.php          \
  vendor/pear/auth_sasl/Auth/SASL/*.php        \
  vendor/pear/auth_sasl/package.xml

chmod -R u=rwX,go=rX .
chmod -R o= config

%install
install -D -d -m 0755 \
  %{buildroot}%{roundcube_basedir}    \
  %{buildroot}%{roundcube_docroot}    \
  %{buildroot}%{php_fpm_d}      \
  %{buildroot}%{ng_vhost_d}     \
  %{buildroot}%{_unitdir}       \
  %{buildroot}%{_sbindir}

install -D -d -m 0770 \
  %{buildroot}%{roundcube_datadir}    \
  %{buildroot}%{roundcube_sessiondir} \
  %{buildroot}%{roundcube_tmpdir}     \
  %{buildroot}%{roundcube_logdir}

rsync -a ${PWD}/ %{buildroot}%{roundcube_docroot}/
rm -rf %{buildroot}%{roundcube_docroot}/config

rsync -a ${PWD}/config/* %{buildroot}%{roundcube_confdir}/

for i in $(find -name config.inc.php.dist -not -path '*help*') ; do
   pluginname="$(basename $(dirname $i))"
   install -m 0640 $i %{buildroot}%{roundcube_confdir}/${pluginname}.config.inc.php
done

install -m 0640 %{SOURCE3} %{buildroot}%{php_fpm_d}/roundcubemail.conf
install -m 0640 %{SOURCE4} %{buildroot}%{ng_vhost_d}/roundcubemail.conf

%pre
/usr/sbin/groupadd -r %{user_group_name} &>/dev/null || :
/usr/sbin/useradd  -g %{user_group_name} -s /bin/false -r -c "roundcube" -d %{roundcube_datadir} %{user_group_name} &>/dev/null || :

if [ ! -d %{roundcube_confdir} -a -d %{roundcube_docroot}/config ]; then
    mv %{roundcube_docroot}/config %{roundcube_confdir}
fi

%files
%doc README.md
%license LICENSE
%dir /srv/www/vhosts
#
%defattr(-,root,%{user_group_name})
%dir %{roundcube_confdir}
%config(noreplace) %{roundcube_confdir}/*config.inc.php
%config %{roundcube_confdir}/config.inc.php.sample
%config %{roundcube_confdir}/defaults.inc.php
%config(noreplace) %{roundcube_confdir}/mimetypes.php

%dir %{roundcube_basedir}
%dir %{roundcube_docroot}
%{roundcube_docroot}/bin
%{roundcube_docroot}/CHANGELOG.md
%{roundcube_docroot}/composer.*
%{roundcube_docroot}/.htaccess
%{roundcube_docroot}/index.php
%{roundcube_docroot}/INSTALL
%{roundcube_docroot}/installer
%{roundcube_docroot}/LICENSE
%{roundcube_docroot}/plugins
%{roundcube_docroot}/program
%{roundcube_docroot}/public_html
%{roundcube_docroot}/README.md
%{roundcube_docroot}/SECURITY.md
%{roundcube_docroot}/skins
%{roundcube_docroot}/SQL
%{roundcube_docroot}/vendor
%{roundcube_docroot}/UPGRADING
%defattr(-,%{user_group_name},%{user_group_name})
%dir %{roundcube_datadir}
%dir %{roundcube_sessiondir}
%dir %{roundcube_tmpdir}
%dir %{roundcube_logdir}

%files php-fpm
%config(noreplace) %{php_fpm_d}/roundcubemail.conf

%files nginx
%config(noreplace) %{ng_vhost_d}/roundcubemail.conf

%changelog
openSUSE Build Service is sponsored by