File kohana2.spec of Package kohana2

# spec file for package kohana2
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2015 Lars Vogdt <>
# 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

%define         realname Kohana
%define         apache_serverroot %(%{_sbindir}/apxs2 -q DATADIR)
%define         apache_sysconfdir %(%{_sbindir}/apxs2 -q SYSCONFDIR)
%define         installpath %{apache_serverroot}/%{name}
Name:           kohana2
Version:        2.3.4
Release:        0
Summary:        PHP 5 framework that uses the Model View Controller architectural pattern
License:        BSD-3-Clause
Group:          Productivity/Networking/Web/Utilities
Source0:        %{realname}_v%{version}.tar.bz2
Source1:        kohana2-apache_include
BuildRequires:  apache2-devel
Requires:       mod_php_any
Requires:       php5-ZendFramework
Requires(pre):  http_daemon
Recommends:     php5-mcrypt
Provides:       kohana = %{version}
Obsoletes:      kohana <= %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%if 0%{?suse_version} >= 1020
BuildRequires:  fdupes

Kohana is a PHP 5 framework that uses the Model View Controller architectural
pattern with a loosely coupled architecture and UTF-8 compatibility.

%setup -q -n %{realname}_v%{version}


mkdir -p %{buildroot}/%{installpath}
cp -r * %{buildroot}/%{installpath}/
find %{buildroot}/%{installpath}/ -type d -exec chmod 755 {} +
find %{buildroot}/%{installpath}/ -type f -exec chmod 644 {} +
for dir in application/logs application/cache; do
	chmod 775 %{buildroot}/%{installpath}/$dir
# install apache config
mkdir -p %{buildroot}/%{apache_sysconfdir}/conf.d/
install -m640 %{SOURCE1} %{buildroot}/%{apache_sysconfdir}/conf.d/%{name}_include.conf
# move system and modules folder out of webroot
mkdir -p %{buildroot}/%{_datadir}/%{name}/
mv %{buildroot}/%{installpath}/{system,modules} %{buildroot}/%{_datadir}/%{name}/
# remove example file
rm %{buildroot}/%{installpath}/example.htaccess
# move the global config files to /etc
for dir in system ; do
	mkdir -p %{buildroot}/%{_sysconfdir}/%{name}/$dir
	mv %{buildroot}/%{_datadir}/%{name}/$dir/config %{buildroot}/%{_sysconfdir}/%{name}/$dir/
	pushd %{buildroot}/%{_datadir}/%{name}/$dir
	ln -s %{_sysconfdir}/%{name}/$dir/config .
# same for the initial application config directory
mkdir %{buildroot}/%{_sysconfdir}/%{name}/application
mv %{buildroot}/%{installpath}/application/config %{buildroot}/%{_sysconfdir}/%{name}/application/
pushd %{buildroot}/%{installpath}/application/
ln -s %{_sysconfdir}/%{name}/application/config .
%if 0%{?suse_version} >= 1020
%fdupes %{buildroot}

if [ "$1" = "0" ]; then
    # deinstallation of the package - remove the apache flag
    test -x %{_sbindir}/a2disflag && %{_sbindir}/a2disflag KOHANA2 >/dev/null
    %restart_on_update apache2

if [ "$1" = "1" ]; then
    # enable php5 in apache config
    test -x %{_sbindir}/a2enmod && %{_sbindir}/a2enmod php5 >/dev/null
    # enable KOHANA in /etc/sysconfig/apache2
    test -x %{_sbindir}/a2enflag && %{_sbindir}/a2enflag KOHANA2 >/dev/null

%restart_on_update apache2

%if 0%{?suse_version} <= 1230
%doc Kohana\ License.html
%doc "Kohana License.html"
%dir %{installpath}
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/application
%dir %{_sysconfdir}/%{name}/application/config
%dir %{_sysconfdir}/%{name}/system
%dir %{_sysconfdir}/%{name}/system/config
%config(noreplace) %{_sysconfdir}/%{name}/*/config/*
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}_include.conf
%dir %{_datadir}/%{name}
%attr(-,wwwrun,www) %{installpath}/application/cache
%attr(-,wwwrun,www) %{installpath}/application/logs

openSUSE Build Service is sponsored by