File horde5.spec of Package horde5

#
# spec file for package horde5
#
# Copyright (c) 2013 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/
#


%define peardir %(pear config-get php_dir 2> /dev/null || echo %{_datadir}/pear)
%define xmldir  /var/lib/pear
%define hordedir /usr/share/php5/PEAR/www/horde

Summary:        Horde Base Application
License:        LGPL-2.1
Group:          Productivity/Networking/Web/Utilities

Name:           horde5
Version:        5.0.2
Release:        0
Source0:        http://pear.horde.org/get/horde-%{version}.tgz
Source1:        horde.conf
Source2:        horde.vhost.conf.template
Source3:        registry.local.php
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Url:            http://pear.horde.org/package/horde
BuildRequires:  php-pear >= 1.8.2
## Required pear modules
Requires:       php5-pear-Horde_Alarm >= 2.0.0
Requires:       php5-pear-Horde_Argv >= 2.0.0
Requires:       php5-pear-Horde_Auth >= 2.0.0
Requires:       php5-pear-Horde_Autoloader >= 2.0.0
Requires:       php5-pear-Horde_Browser >= 2.0.0
Requires:       php5-pear-Horde_Core >= 2.0.0
Requires:       php5-pear-Horde_Date >= 2.0.0
Requires:       php5-pear-Horde_Exception >= 2.0.0
Requires:       php5-pear-Horde_Form >= 2.0.0
Requires:       php5-pear-Horde_Group >= 2.0.0
Requires:       php5-pear-Horde_Http >= 2.0.0
Requires:       php5-pear-Horde_Image >= 2.0.0
Requires:       php5-pear-Horde_LoginTasks >= 2.0.0
Requires:       php5-pear-Horde_Mail >= 2.0.0
Requires:       php5-pear-Horde_Mime >= 2.0.0
Requires:       php5-pear-Horde_Nls >= 2.0.0
Requires:       php5-pear-Horde_Perms >= 2.0.0
Requires:       php5-pear-Horde_Prefs >= 2.0.0
Requires:       php5-pear-Horde_Role >= 1.0.1
Requires:       php5-pear-Horde_Rpc >= 2.0.0
Requires:       php5-pear-Horde_Serialize >= 2.0.0
Requires:       php5-pear-Horde_Support >= 2.0.0
Requires:       php5-pear-Horde_Template >= 2.0.0
Requires:       php5-pear-Horde_Text_Diff >= 2.0.0
Requires:       php5-pear-Horde_Text_Filter >= 2.0.0
Requires:       php5-pear-Horde_Token >= 2.0.0
Requires:       php5-pear-Horde_Tree >= 2.0.0
Requires:       php5-pear-Horde_Url >= 2.0.0
Requires:       php5-pear-Horde_Util >= 2.0.0
Requires:       php5-pear-Horde_Vfs  >= 2.0.0
Requires:       php5-pear-Horde_View >= 2.0.0
Suggests:       php5-pear-Horde_ActiveSync >= 2.0.3
Suggests:       php5-pear-Horde_Db >= 2.0.1
Suggests:       php5-pear-Horde_Feed >= 2.0.0
Suggests:       php5-pear-Horde_Oauth >= 2.0.0
Suggests:       php5-pear-Horde_Service_Facebook >= 2.0.0
Suggests:       php5-pear-Horde_Service_Twitter >= 2.0.0
Suggests:       php5-pear-Horde_Service_Weather >= 2.0.0
Suggests:       php5-pear-Horde_SyncMl >= 2.0.0

## The following are "optional" but functionality will fail without further notice when they are missing
## People were discussing so it's probably wiser to add them by default
Requires:       php5-pear-Auth_SASL
## As of horde H5, pear Date should not be needed for the base horde installation anymore ## Ralf Lang ## 2012-11-27
#Requires:       php5-pear-Date
Requires:       php5-pear-HTTP_Request
Requires:       php5-pear-HTTP_WebDAV_Server
Requires:       php5-pear-Net_SMTP
Requires:       php5-pear-XML_Serializer

## These are less frequently necessary and don't result in things just not working
Suggests:       php5-pear-Net_DNS2
Suggests:       php5-pear-Console_Getopt
Suggests:       php5-pear-Console_Table
Suggests:       php5-pear-File_Find
Suggests:       php-filter
Suggests:       php-pear-Services_Weather
Suggests:       php-ssh2
Suggests:       php-fileinfo
Suggests:       php-tidy
Suggests:       php-iconv

## Channel file
Requires:       php5-pear-channel-horde
## php pecl

Requires:       php-ctype
Requires:       php-ftp
Requires:       php-gettext
Requires:       php-hash
Requires:       php-json
Requires:       php-mbstring
Requires:       php-zip
## Conflicts
Requires:       php-pear >= 1.8.2
BuildRequires:  php5-pear-Horde_Role >= 1.0.1
BuildRequires:  php5-pear-channel-horde
## Normal pear requirements
Requires:       php5-pear-MDB2
Suggests:       php5-pear-MDB2_Driver_mysqli php5-pear-MDB2_Driver_mysql
BuildRequires:  fdupes

BuildArch:      noarch

%description
The base application of the Horde Framework, gluing together the Horde Framework
with applications like IMP Webmailer, Kronolith Calendar or Whups Ticket Management.

The Horde Application Framework is a flexible, modular, general-purpose web
application framework written in PHP. It provides an extensive array of
components that are targeted at the common problems and tasks involved in
developing modern web applications. It is the basis for a large number of
production-level web applications, notably the Horde Groupware suites. For
more information on Horde or the Horde Groupware suites, visit
http://www.horde.org.

%prep
%setup -c -T
%{_bindir}/pear config-set horde_dir %{hordedir}
pear -v -c pearrc \
        -d php_dir=%{peardir} \
        -d doc_dir=%{_docdir}/%{name} \
        -d bin_dir=%{_bindir} \
        -d data_dir=%{peardir}/data \
        -d test_dir=%{peardir}/tests \
        -d ext_dir=%{_libdir} \
        -d horde_dir=%{hordedir} \
        -s

%build

%install
pear -c pearrc install --nodeps --packagingroot %{buildroot} %{SOURCE0}

## configs written by the web configurator should go to etc
%{__install} -m 0660 -D  %{buildroot}/%{hordedir}/config/conf.php.dist %{buildroot}/etc/horde/horde/conf.php
%{__install} -m 0660 -D  %{buildroot}/%{hordedir}/config/conf.php.dist %{buildroot}/etc/horde/horde/conf.bak.php
%{__rm} %{buildroot}/%{hordedir}/config/conf.php.dist
%{__ln_s} /etc/horde/horde/conf.php %{buildroot}/%{hordedir}/config/conf.php
%{__ln_s} /etc/horde/horde/conf.bak.php %{buildroot}/%{hordedir}/config/conf.bak.php
## registry modifications should happen in etc
%{__rm} %{buildroot}/%{hordedir}/config/registry.d/README
%{__mv} %{buildroot}/%{hordedir}/config/registry.d %{buildroot}/etc/horde/horde/registry.d
%{__ln_s} /etc/horde/horde/registry.d %{buildroot}/%{hordedir}/config/registry.d
%{__install} -m 0660 -D  %{SOURCE3} %{buildroot}/etc/horde/horde/registry.local.php
%{__ln_s} /etc/horde/horde/registry.local.php %{buildroot}/%{hordedir}/config/registry.local.php
## custom prefs should be configured in prefs.local.php
%{__install} -m 0660 -D  %{buildroot}/%{hordedir}/config/prefs.php %{buildroot}/etc/horde/horde/prefs.local.php
%{__ln_s} /etc/horde/horde/prefs.local.php %{buildroot}/%{hordedir}/config/prefs.local.php

%{__install} -m 0660 -D  %{SOURCE1} %{buildroot}/etc/horde/apache-snippets.d/horde.conf
%{__install} -m 0660 -D  %{SOURCE2} %{buildroot}/etc/apache2/vhosts.d/horde.vhost.conf.template

## clean individual .htaccess files as they are incorporated into vhost snippets
%{__rm} %{buildroot}/%{hordedir}/.htaccess
%{__rm} %{buildroot}/%{hordedir}/locale/.htaccess
%{__rm} %{buildroot}/%{hordedir}/config/.htaccess
%{__rm} %{buildroot}/%{hordedir}/templates/.htaccess
%{__rm} %{buildroot}/%{hordedir}/lib/.htaccess
%{__rm} %{buildroot}/%{peardir}/data/horde/scripts/.htaccess
%{__rm} %{buildroot}/%{hordedir}/rpc/.htaccess

%if 0%{?suse_version} > 1020
%fdupes %buildroot%{hordedir}
%find_lang horde
%endif

# Clean up unnecessary files
rm pearrc
rm %{buildroot}/%{peardir}/.filemap
rm %{buildroot}/%{peardir}/.lock
rm -rf %{buildroot}/%{peardir}/.registry
rm -rf %{buildroot}%{peardir}/.channels
rm %{buildroot}%{peardir}/.depdb
rm %{buildroot}%{peardir}/.depdblock

# Install XML package description
mkdir -p %{buildroot}%{xmldir}
tar -xzf %{SOURCE0} package.xml
cp -p package.xml %{buildroot}%{xmldir}/horde.xml

%clean
rm -rf %{buildroot}

%post
%{_bindir}/pear config-set horde_dir %{hordedir}
%{_bindir}/pear install --nodeps --soft --force --register-only %{xmldir}/horde.xml

%postun
if [ "$1" -eq "0" ]; then
    %{_bindir}/pear uninstall --nodeps --ignore-errors --register-only pear.horde.org/horde
fi

%files -f horde.lang
%defattr(0644,root,root,0755)
%doc %{_docdir}/%{name}
%{peardir}/*
%{xmldir}/horde.xml
%dir %{hordedir}
%{hordedir}/admin
%{hordedir}/js
%{hordedir}/lib
%dir %{hordedir}/locale/
%{hordedir}/locale/horde.pot
%{hordedir}/locale/en
%{hordedir}/rpc
%{hordedir}/services
%{hordedir}/templates
%{hordedir}/themes
%{hordedir}/util
%{hordedir}/*.php
%attr(0775,root,www) %dir %{hordedir}/config/
%config(noreplace) %{hordedir}/config/*.php
%{hordedir}/config/*.xml
%config(noreplace) %{hordedir}/config/registry.d
%{hordedir}/config/*.dist
%attr(0775, wwwrun, root ) %{hordedir}/static
%attr(0664, wwwrun, root ) %{hordedir}/static/README
%attr(0775, wwwrun, root ) %{peardir}/data/horde/scripts/*.cron
%defattr(0744,root,root,0755)
%{_bindir}/horde-active-sessions
%{_bindir}/horde-alarms
%{_bindir}/horde-check-logger
%{_bindir}/horde-clear-cache
%{_bindir}/horde-crond
%{_bindir}/horde-db-migrate
%{_bindir}/horde-import-squirrelmail-prefs
%{_bindir}/horde-memcache-stats
%{_bindir}/horde-run-task
%{_bindir}/horde-set-perms
%{_bindir}/horde-themes
%{_bindir}/horde-translation
%dir /etc/apache2
%dir /etc/apache2/vhosts.d
## the config stuff in /etc
%defattr(0640, wwwrun, root, 0750)
%dir /etc/horde
%dir /etc/horde/horde
%dir /etc/horde/horde/registry.d
%dir /etc/horde/apache-snippets.d
%config /etc/horde/apache-snippets.d/horde.conf
%config(noreplace) /etc/horde/horde/conf.php
%config(noreplace) /etc/horde/horde/conf.bak.php
%config(noreplace) /etc/horde/horde/registry.local.php
%config(noreplace) /etc/horde/horde/prefs.local.php
%config /etc/apache2/vhosts.d/horde.vhost.conf.template

%changelog
openSUSE Build Service is sponsored by