File horde3.spec of Package horde3

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

# norootforbuild

%define _phpdir php5
%define peardir %(pear config-get php_dir 2> /dev/null)
%define _hordedir %(%{_sbindir}/apxs2 -q datadir)/htdocs/horde

Name:           horde3
Summary:        Core Pieces for Running H3 Web Applications
Version:        3.3.11
Release:        2
Url:            http://www.horde.org/
License:        GPLv2+
Group:          Productivity/Networking/Web/Utilities
Requires:       mod_php_any
Requires:       php-gettext
Requires:       php-mcrypt
Requires:       php-imap
Requires:       php-pear
Requires:       php5-pear-Log
Requires:       php-session
Requires:       php-dom
Requires:       php5 
Requires:       php5-pear-Auth_SASL
Requires:       php5-pear-Date
Requires:       php5-pear-File
Requires:       php5-pear-Mail
Requires:       php5-pear-Mail_Mime
Requires:       php5-pear-DB
Requires:       php5-pear-MDB2
Requires:       php5-pear-Net_IMAP
Requires:       php5-pear-services_weather
Requires:       php5-pear-SOAP
Requires:       php5-pear-Text_CAPTCHA
Requires:       php5-pear-Text_Figlet
# this is atm provided by horde itself
#Requires:	php5-pear-text_diff
Requires:       php5-pear-HTTP_Request
Requires:       php5-pear-Services_Weather
Requires:       php5-pear-XML_SVG
Source0:        horde-%{version}.tar.bz2
############################
Patch0:         horde-3.1.2-log.patch
Patch1:         horde-fatal-on-admin-3.3.11.patch
Patch2:         horde-finer-grained-admin-privileges.patch
Patch3:         horde-3.2-rc1-usr_local.patch
Patch4:         horde-3.3.9-php5_exec.patch
BuildRequires:  apache2-devel
# This check is still needed for SLE-10-SP2
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
%endif
BuildRequires:  pcre-devel
BuildRequires:  php5-pear
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
These are the core pieces of the Horde suite of Web applications. This
package is needed to run any of the other programs, such as IMP.



Authors:
--------
	Chuck Hagenbuch <chuck@horde.org> 
	Jan Schneider <jan@horde.org> 
	Michael Slusarz <slusarz@horde.org>

%prep
%setup %setup -qn horde-%{version}
%patch0
%patch1
%patch2
%patch3
%patch4 -p1
# Remove the .orig files that are created by the above patch' commands
find -name "*.orig" -exec rm {} \;

%build
: if the following command fails, then apache dependencies are not met
/usr/sbin/apxs2 -q datadir >/dev/null
cd config
for i in *.dist; do
  %__mv $i ${i%.dist}
done

%install
%__mkdir_p %{buildroot}%{_hordedir}
%__cp -r ./* %{buildroot}%{_hordedir}
%__rm -rf %{buildroot}%{_hordedir}/{docs,README,LICENSE}
%if 0%{?sles_version} != 10 
 %fdupes %buildroot%{_hordedir}
%endif
%find_lang horde
%__install -d %{buildroot}/var/log/horde

# The following files are removed, because they are now provided
# by the packages: horde-auth, horde-group, horde-prefs, kolab-filter,
# kolab-format, kolab-freebusy, kolab-server and kolab-storage.
#
# The following files are provided by horde, it seems that should
# not be the case.
# Horde/Kolab/Storage/Session.php
# Horde/Prefs/kolab_imap.php
# Horde/Share/kolab.php
%__rm -rf %{buildroot}%{_hordedir}/lib/Horde/Kolab

# prevent rpmlint warning / errors
%if 0%{?suse_version} > 1020
%fdupes %{buildroot}%{_hordedir}/admin
%fdupes %{buildroot}%{_hordedir}/js
%fdupes %{buildroot}%{_hordedir}/lib
%fdupes %{buildroot}%{_hordedir}/po
%fdupes %{buildroot}%{_hordedir}/themes
%fdupes %{buildroot}%{_hordedir}/scripts
%fdupes %{buildroot}%{_hordedir}/templates
%fdupes %{buildroot}%{_hordedir}/docs
%fdupes %{buildroot}%{_hordedir}/services
%fdupes %{buildroot}%{_hordedir}/rpc
%fdupes %{buildroot}%{_hordedir}/util
%endif

%__install -d -m 755 %{buildroot}%{peardir}/Horde
%find_lang horde

%clean
%__rm -rf %{buildroot}

%files -f horde.lang
%defattr(-, root, root)
%doc README docs
%doc %{_hordedir}/COPYING
%dir %{_hordedir}
%{_hordedir}/locale/.htaccess
%{_hordedir}/locale/en_US/help.xml
%{_hordedir}/admin
%{_hordedir}/js
%{_hordedir}/lib
%{_hordedir}/po
%dir %{_hordedir}/locale
%dir %{_hordedir}/locale/en_US
%{_hordedir}/scripts
%{_hordedir}/services
%{_hordedir}/templates
%{_hordedir}/themes
%{_hordedir}/util
%{_hordedir}/rpc
%{_hordedir}/*.php
%attr(0750, wwwrun, www) %dir %{_hordedir}/config
%attr(0640, root, www)   %config(noreplace) %{_hordedir}/config/.htaccess
%attr(0640, wwwrun, www) %config(noreplace) %{_hordedir}/config/*.php
%attr(0640, wwwrun, www) %config(noreplace) %{_hordedir}/config/*.xml
%attr(0750, wwwrun, www) %dir %{_hordedir}/config/registry.d
%attr(0640, wwwrun, www) %{_hordedir}/config/registry.d/README
%attr(0750, wwwrun, www) %dir /var/log/horde

%post
if [[ "$1" == 1 ]]; then
  # Horde is not yet installed on the system
  if ! grep -q "^include_path.*/srv/www/htdocs/horde/lib" /etc/php5/cli/php.ini; then
    # The directory /srv/www/htdocs/horde/lib, must be placed before
    # /usr/share/php5/PEAR otherwise applications will fail
    eval $(grep -w ^include_path /etc/php5/cli/php.ini | tr -d " ")
    for D in $(tr ":" " " <<< $include_path); do
      if [[ $D == "/usr/share/php5/PEAR" ]]; then
        INCLUDE_PATH="$INCLUDE_PATH:/srv/www/htdocs/horde/lib"
      fi
      INCLUDE_PATH="$INCLUDE_PATH:$D"
    done

    # Replace the include_path and remove the ":" at the beginning of the line
    cp /etc/php5/cli/php.ini /etc/php5/cli/php.ini-rpm-%{version}-%{release}
    sed -i "s,^include_path = .*,include_path = \"${INCLUDE_PATH##:}\"," /etc/php5/cli/php.ini
  fi
fi

%postun
if [[ "$1" == 0 ]]; then
  # Horde is removed from the system
  if grep -qw /srv/www/htdocs/horde/lib /etc/php5/cli/php.ini; then
    cp /etc/php5/cli/php.ini /etc/php5/cli/php.ini-rpm-%{version}-%{release}-remove
    sed -i 's,/srv/www/htdocs/horde/lib:*,,' /etc/php5/cli/php.ini
  fi
fi

%changelog
openSUSE Build Service is sponsored by