File kopano-webapp.spec of Package kopano-webapp

Name:           kopano-webapp
Summary:        The next-generation web client of Kopano
License:        AGPL-3.0
Group:          Productivity/Networking/Email/Clients
Version:        2.2.0
Release:        0
Url:            http://www.kopano.com

Source:         %{name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Obsoletes:		kopano-webapp-plugin-zdeveloper kopano-webapp-plugin-webappmanual kopano-webapp-plugin-folderwidgets kopano-webapp-plugin-quickitems kopano-webapp-plugin-titlecounter kopano-webapp-plugin-desktopnotifications kopano-webapp-plugin-filepreviewer
Provides:		kopano-webapp-plugin-zdeveloper kopano-webapp-plugin-webappmanual kopano-webapp-plugin-folderwidgets kopano-webapp-plugin-quickitems kopano-webapp-plugin-titlecounter kopano-webapp-plugin-desktopnotifications kopano-webapp-plugin-filepreviewer

%if 0%{?suse_version}
BuildRequires:	fdupes
BuildRequires:	java >= 1.6.0
BuildRequires:	java-devel >= 1.6.0
BuildRequires:	php-json
BuildRequires:	php7-gettext
%endif
%if 0%{?centos_version} == 600
BuildRequires:	java-1.7.0-openjdk-devel
%endif
%if 0%{?centos_version} == 700 || 0%{?rhel_version} == 700 || 0%{?fedora_version} == 20
BuildRequires:	java-1.7.0-openjdk-devel
%endif
%if 0%{?fedora_version} >= 21
BuildRequires:	java-1.8.0-openjdk-devel
%endif

BuildRequires:	php
BuildRequires:	xz
%if 0%{?suse_version} >= 1220
BuildRequires:	libxml2-tools
%else
BuildRequires:	libxml2
%endif
BuildArch:	noarch

# The language files are just in a separate package just to keep the
# file lists relatively short. They are still needed by the base in any case.
Requires:       %name-lang = %version
Requires:       php-mapi >= 7.2.5

%if "%_repository" == "RHEL_6_PHP_56" || "%_repository" == "RHEL_7_PHP_56"
Requires:	rh-php56-php-common rh-php56-php-xml rh-php56-php-mbstring
%endif

%if "%_repository" == "RHEL_7_PHP_71"
Requires:	rh-php71-php-common rh-php71-php-xml rh-php71-php-mbstring
%endif

%if "%_repository" == "RHEL_6" || "%_repository" == "RHEL_7" || "%_repository" == "RHEL_8"
Requires:	php-common php-xml php-curl php-mbstring
%endif

%if "%_repository" == "SLE_12" || "%_repository" == "SLE_12_PHP7"
Requires:       php-iconv php-zlib php-openssl php-gettext php-xml php-json php-zip php-mbstring
%endif

%define langdir %_datadir/%name/server/language
%define plugindir %_datadir/%name/plugins

%if 0%{?suse_version}
    %define apache_dir %_sysconfdir/apache2
%else
	%if "%_repository" == "RHEL_6_PHP_56" || "%_repository" == "RHEL_7_PHP_56"
		%define apache_dir /opt/rh/httpd24/root/etc/httpd/
	%else
		%define apache_dir %_sysconfdir/httpd
	%endif
%endif

%description
Provides a web-client written in PHP that makes use of HTML5, JSON and ExtJS
to allow users to make full use of the Kopano
through a modern web browser.

%package lang
Summary:        Languages for package %name
Group:          System/Localization

%description lang
Provides translations to the package %name.

%package plugin-contactfax
Summary:        Contact fax plugin for kopano-webapp
Group:          Productivity/Networking/Email/Clients

%description plugin-contactfax
Opens a new "create mail" dialog with contact's fax number in the To:
field of the email.

%package plugin-gmaps
Summary:        Google Maps plugin for kopano-webapp
Group:          Productivity/Networking/Email/Clients

%description plugin-gmaps
Shows contact address on Google Maps with Kopano WebApp.

%package plugin-pimfolder
Summary:        Personal Inbox Management plugin for WebApp
Group:          Productivity/Networking/Email/Clients

%description plugin-pimfolder
Kopano PIM plugin, allows you to set-up a folder quickly moving
your mail to another folder

%prep
%setup -qn %{name}-%{version}
find . -type f "(" -name "*.js" -o -name "*.php" ")" \
	-exec chmod a-x "{}" "+";
# Set git revision
echo "%{version}-%{release}" > version
echo "%{version}-%{release}" | sha1sum | cut -b 1-8 > cachebuster

%build

test -f /opt/rh/rh-php71/enable && source /opt/rh/rh-php71/enable
test -f /opt/rh/rh-php56/enable && source /opt/rh/rh-php56/enable

make

%install
b="%buildroot";
d="$b/%_datadir";
mkdir -p "$d";
cp -a deploy "$d/%name";

# Install LICENSE.txt
install -m644 LICENSE.txt "$d/%name/LICENSE.txt"

# Apache conf
mkdir -p "$b/%apache_dir/conf.d";
install -Dpm 644 "$d/%name/%name.conf" "$b/%apache_dir/conf.d/%name.conf";

# WebApp config
mkdir -p "$b/%_sysconfdir/kopano/webapp"
mv "$d/%name/config.php.dist" "$b/%_sysconfdir/kopano/webapp/config.php"
ln -s "%_sysconfdir/kopano/webapp/config.php" "$b/%_datadir/kopano-webapp/config.php"
rm "$d/%name/debug.php.dist"
mkdir -p "$b/var/lib/%name/tmp"

for dir in "$d/%name/plugins"/*; do 
	plugindir=$(basename "$dir")
	if [ -f "$d/%name/plugins/$plugindir/config.php" ];
	then
		mv "$d/%name/plugins/$plugindir/config.php" "$b/%_sysconfdir/kopano/webapp/config-$plugindir.php"
		ln -s "%_sysconfdir/kopano/webapp/config-$plugindir.php" "$d/%name/plugins/$plugindir/config.php"
	else
		echo "we did not find a config.php"
	fi
done

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

%files
%defattr(-,root,root)
%_datadir/%name

%exclude %plugindir/*
%exclude %langdir
%dir %_sysconfdir/kopano
%dir %_sysconfdir/kopano/webapp

%dir %apache_dir
%dir %apache_dir/conf.d

%if 0%{?suse_version}
%config(noreplace) %attr(0640,root,www) %_sysconfdir/kopano/webapp/config.php
%config(noreplace) %attr(0640,root,www) %apache_dir/conf.d/kopano-webapp.conf
%dir %attr(0770,root,www) /var/lib/kopano-webapp
%else
%config(noreplace) %attr(0640,root,apache) %_sysconfdir/kopano/webapp/config.php
%config(noreplace) %attr(0640,root,apache) %apache_dir/conf.d/kopano-webapp.conf
%dir %attr(0770,root,apache) /var/lib/kopano-webapp
%endif

%if 0%{?suse_version}
%dir %attr(0775, wwwrun, www) /var/lib/kopano-webapp/tmp
%else
%dir %attr(0775, apache, apache) /var/lib/kopano-webapp/tmp
%endif

%config(noreplace) %_datadir/%name/.htaccess

%files lang
%defattr(-,root,root)
%dir %langdir
%lang(ca_ES) %langdir/ca_ES.UTF-8
%lang(cs_CZ) %langdir/cs_CZ.UTF-8
%lang(da_DK) %langdir/da_DK.UTF-8
%lang(de_DE) %langdir/de_DE.UTF-8
%lang(en_US) %langdir/en_US.UTF-8
%lang(es_CA) %langdir/es_CA.UTF-8
%lang(es_ES) %langdir/es_ES.UTF-8
%lang(fi_FI) %langdir/fi_FI.UTF-8
%lang(fr_FR) %langdir/fr_FR.UTF-8
%lang(he_IL) %langdir/he_IL.UTF-8
%lang(hu_HU) %langdir/hu_HU.UTF-8
%lang(it_IT) %langdir/it_IT.UTF-8
%lang(ja_JP) %langdir/ja_JP.UTF-8
%lang(lt_LT) %langdir/lt_LT.UTF-8
%lang(nb_NO) %langdir/nb_NO.UTF-8
%lang(nl_NL) %langdir/nl_NL.UTF-8
%lang(pl_PL) %langdir/pl_PL.UTF-8
%lang(pt_BR) %langdir/pt_BR.UTF-8
%lang(pt_PT) %langdir/pt_PT.UTF-8
%lang(ru_RU) %langdir/ru_RU.UTF-8
%lang(sv_SE) %langdir/sv_SE.UTF-8
%lang(uk_UA) %langdir/uk_UA.UTF-8
%lang(zh_CN) %langdir/zh_CN.UTF-8

%files plugin-contactfax
%defattr(-,root,root)
%dir %_datadir/%name
%dir %plugindir
%plugindir/contactfax
%config(noreplace) %_sysconfdir/kopano/webapp/config-contactfax.php

%files plugin-gmaps
%defattr(-,root,root)
%dir %_datadir/%name
%dir %plugindir
%plugindir/gmaps
%config(noreplace) %_sysconfdir/kopano/webapp/config-gmaps.php

%files plugin-pimfolder
%defattr(-,root,root)
%dir %_datadir/%name
%dir %plugindir
%plugindir/pimfolder
%config(noreplace) %_sysconfdir/kopano/webapp/config-pimfolder.php

%changelog
* Wed Apr 27 2016 development@kopano.io
- Current release
openSUSE Build Service is sponsored by