1
0
forked from pool/roundcubemail
roundcubemail/roundcubemail.spec

285 lines
9.7 KiB
RPMSpec

#
# spec file for package roundcubemail
#
# 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/
#
Name: roundcubemail
Version: 0.9.5
Release: 0
Summary: A modern browser-based multilingual IMAP client
License: GPL-3.0+ and GPL-2.0 and BSD-3-Clause
Group: Productivity/Networking/Email/Clients
Url: http://www.roundcube.net/
Source0: %{name}-%{version}-dep.tar.gz
Source1: %{name}-rpmlintrc
Source2: %{name}-httpd.conf
Source4: README.openSUSE
Source5: %{name}.logrotate
# PATCH-FIX-OPENSUSE roundcubemail-0.9.1_config-dir.patch -- use the general config directory /etc
Patch0: %{name}-0.9.1_config-dir.patch
BuildArch: noarch
BuildRequires: apache2-devel
%if 0%{suse_version} >= 1100
BuildRequires: fdupes
%endif
BuildRequires: pcre-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: http_daemon
Requires: mod_php_any
Requires: php-exif
Requires: php-gettext
Requires: php-iconv
Requires: php-mbstring
Requires: php-mcrypt
Requires: php-openssl
Requires: php-session
Requires: php_any_db
## Requires: for upstream dep package
Requires: php-pear-Auth_SASL >= 1.0.6
Requires: php-pear-MDB2_Driver_mysqli
Requires: php-pear-Mail_Mime >= 1.8.1
Requires: php-pear-Mail_mimeDecode >= 1.5.5
Requires: php-pear-Net_IDNA2 >= 0.1.1
Requires: php-pear-Net_LDAP2
Requires: php-pear-Net_SMTP
Requires: php-pear-Net_Socket
%if 0%{?suse_version}
Recommends: logrotate
%endif
Recommends: php-mysql
Recommends: php5-intl
Recommends: php5-fileinfo
Provides: roundcube_framework = %{version}
Conflicts: roundcube-framework
%define apache_serverroot %(/usr/sbin/apxs2 -q DATADIR)
%define apache_sysconfdir %(/usr/sbin/apxs2 -q SYSCONFDIR)
%define roundcubepath %{apache_serverroot}/%{name}
%define roundcubeconfigpath %{_sysconfdir}/%{name}
%description
Roundcube Webmail is a browser-based multilingual IMAP client with an
application-like user interface. It provides full functionality you
expect from an e-mail client, including MIME support, address book,
folder manipulation, message searching and spell checking.
Roundcube Webmail is written in PHP and requires the MySQL database.
The user interface is fully skinnable using XHTML and CSS 2.
%prep
%setup -q -n %{name}-%{version}-dep
%patch0 -p1
cp %{SOURCE4} .
cp %{SOURCE5} .
# remove cruft from source archive
find . -name ".gitignore" -delete
# no need to check .htaccess each time, the apache config takes care of the restrictions
find . -name ".htaccess" -delete
# remove mssql scripts (not needed on openSUSE)
rm -rf \
SQL/mssql/ \
SQL/mssql.*.sql
# remove shebang from chpass-wrapper
sed -i '1d' plugins/password/helpers/chpass-wrapper.py
# remove INSTALL doc
rm INSTALL
%build
%install
# install roundcubemail.logrotate
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/logrotate
mv %{name}.logrotate %{buildroot}%{_sysconfdir}/logrotate/
# extract roundcube-framework
%{__install} -d -m 0755 %{buildroot}%{_datadir}/php5
mv program/lib/Roundcube %{buildroot}%{_datadir}/php5/Roundcube
# install roundcubemail
%{__install} -d -m 0755 %{buildroot}%{roundcubepath}
cp -a * %{buildroot}%{roundcubepath}/
# install config
mkdir -p %{buildroot}%{_sysconfdir}/%{name}
cp config/* %{buildroot}%{roundcubeconfigpath}/
cp %{buildroot}%{roundcubeconfigpath}/main.inc.php.dist %{buildroot}%{roundcubeconfigpath}/main.inc.php
cp %{buildroot}%{roundcubeconfigpath}/db.inc.php.dist %{buildroot}%{roundcubeconfigpath}/db.inc.php
rm -rf %{buildroot}%{roundcubepath}/config
ln -s %{roundcubeconfigpath} %{buildroot}%{roundcubepath}/config
# logs + temp go into /var/
rm -rf %{buildroot}%{roundcubepath}/logs \
%{buildroot}%{roundcubepath}/temp
mkdir -p %{buildroot}%{_localstatedir}/log/%{name} \
%{buildroot}%{_localstatedir}/lib/%{name}
ln -s %{_localstatedir}/log/%{name}/ %{buildroot}%{roundcubepath}/logs
ln -s %{_localstatedir}/lib/%{name}/ %{buildroot}%{roundcubepath}/temp
# move some plugin configs to /etc/roundcubemail
for PLUGIN in acl managesieve password; do
if [[ -f %{buildroot}%{roundcubepath}/plugins/$PLUGIN/config.inc.php.dist ]]; then
mv %{buildroot}%{roundcubepath}/plugins/$PLUGIN/config.inc.php.dist %{buildroot}%{roundcubeconfigpath}/$PLUGIN.inc.php
ln -s %{roundcubeconfigpath}/$PLUGIN.inc.php %{buildroot}%{roundcubepath}/plugins/$PLUGIN/config.inc.php
fi
done
# install httpd.conf file and adapt the configuration
%{__install} -d -m 0755 %{buildroot}%{apache_sysconfdir}/conf.d
sed -e "s#__ROUNDCUBEPATH__#%{roundcubepath}#g" %{SOURCE2} > %{buildroot}%{apache_sysconfdir}/conf.d/roundcubemail.conf
# install docs
%{__install} -d -m 0755 %{buildroot}%{_defaultdocdir}/%{name}
for i in CHANGELOG UPGRADING LICENSE README.md README.openSUSE SQL; do
mv -v %{buildroot}%{roundcubepath}/$i %{buildroot}%{_defaultdocdir}/%{name}/
done
# create a link for SQL
%{__ln_s} %{_defaultdocdir}/%{name}/SQL %{buildroot}%{roundcubepath}/SQL
# fdupes
%if 0%{suse_version} >= 1100
%fdupes %{buildroot}%{roundcubepath}
%endif
%clean
rm -rf %{buildroot}
%pre
# backup logs, temp and config for migration
if [[ ! -h %{roundcubepath}/logs ]]; then
if [[ -d %{roundcubepath}/logs ]]; then
mkdir -p %{roundcubepath}/migration
mv %{roundcubepath}/logs %{roundcubepath}/migration/.
fi
fi
if [[ ! -h %{roundcubepath}/temp ]]; then
if [[ -d %{roundcubepath}/temp ]]; then
mkdir -p %{roundcubepath}/migration
mv %{roundcubepath}/temp %{roundcubepath}/migration/.
fi
fi
for PLUGIN in acl managesieve password; do
if [[ ! -h %{roundcubepath}/plugins/$PLUGIN/config.inc.php ]]; then
if [[ -f %{roundcubepath}/plugins/$PLUGIN/config.inc.php ]]; then
mv %{roundcubepath}/plugins/$PLUGIN/config.inc.php %{roundcubepath}/migration/$PLUGIN.inc.php
fi
fi
done
%post
# replace default des string in config file for better security
function makedesstr () {
chars=(0 1 2 3 4 5 6 7 8 9 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 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)
max=${#chars[*]}
for i in `seq 1 24`; do
let rand=${RANDOM}%%${max}
str="${str}${chars[$rand]}"
done
echo $str
}
sed -i "s/rcmail-\!24ByteDESkey\*Str/`makedesstr`/" /etc/roundcubemail/main.inc.php || : &> /dev/null
# enable apache required apache modules
if [ -x /usr/sbin/a2enmod ]; then
a2enmod -q alias || a2enmod alias
a2enmod -q rewrite || a2enmod rewrite
fi
# restore backed up logs, temp and config
if [[ -h %{roundcubepath}/logs ]]; then
if [[ -d %{roundcubepath}/migration/logs ]]; then
mkdir -p %{roundcubepath}/migrated
cp %{roundcubepath}/migration/logs/* %{roundcubepath}/logs/.
mv %{roundcubepath}/migration/logs %{roundcubepath}/migrated/.
fi
fi
if [[ -h %{roundcubepath}/temp ]]; then
if [[ -d %{roundcubepath}/migration/temp ]]; then
mkdir -p %{roundcubepath}/migrated
cp %{roundcubepath}/migration/temp/* %{roundcubepath}/temp/.
mv %{roundcubepath}/migration/temp %{roundcubepath}/migrated/.
fi
fi
for PLUGIN in acl managesieve password; do
if [[ -f %{roundcubepath}/migration/$PLUGIN.inc.php ]]; then
if [[ -h %{roundcubepath}/plugins/$PLUGIN/config.inc.php ]]; then
cp %{roundcubepath}/migration/$PLUGIN.inc.php %{roundcubeconfigpath}/.
mv %{roundcubepath}/migration/$PLUGIN.inc.php %{roundcubepath}/migrated/$PLUGIN.inc.php
fi
fi
done
# make config, if none exist
if [ ! -f %{roundcubeconfigpath}/main.inc.php ]; then
cp %{roundcubeconfigpath}/main.inc.php.dist %{roundcubeconfigpath}/main.inc.php
fi
if [ ! -f %{roundcubeconfigpath}/db.inc.php ]; then
cp %{roundcubeconfigpath}/db.inc.php.dist %{roundcubeconfigpath}/db.inc.php
fi
exit 0
%files
%defattr(0644, root, root,0755)
%doc CHANGELOG
%doc LICENSE
%doc README.md
%doc README.openSUSE
%doc UPGRADING
%doc SQL/
%dir %{roundcubepath}
%dir %{roundcubeconfigpath}
%ghost %config(noreplace) %{roundcubeconfigpath}/db.inc.php
%ghost %config(noreplace) %{roundcubeconfigpath}/main.inc.php
%config(noreplace) %{roundcubeconfigpath}/acl.inc.php
%config(noreplace) %{roundcubeconfigpath}/managesieve.inc.php
%config(noreplace) %{roundcubeconfigpath}/password.inc.php
%config %{roundcubeconfigpath}/db.inc.php.dist
%config %{roundcubeconfigpath}/main.inc.php.dist
%config %{roundcubeconfigpath}/mimetypes.php
%config(noreplace) %{apache_sysconfdir}/conf.d/roundcubemail.conf
%dir %{_sysconfdir}/logrotate
%config(noreplace) %{_sysconfdir}/logrotate/%{name}.logrotate
%{roundcubepath}/composer.json-dist
%{roundcubepath}/config
%{roundcubepath}/index.php
%{roundcubepath}/robots.txt
%attr(0755,root,root) %{roundcubepath}/bin/*.sh
%dir %{roundcubepath}/bin
%{roundcubepath}/installer/
%{roundcubepath}/logs
%{roundcubepath}/plugins/
%{roundcubepath}/program/
%{roundcubepath}/skins/
%{roundcubepath}/SQL
%{roundcubepath}/temp
%dir %{_datadir}/php5
%{_datadir}/php5/Roundcube/
%attr(-, wwwrun, root) %{_localstatedir}/log/%{name}
%attr(-, wwwrun, root) %{_localstatedir}/lib/%{name}
%changelog