File koseven.spec of Package koseven

#
# spec file for package koseven
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2015 Lars Vogdt <lars@linux-schulserver.de>
#
# 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         apache_serverroot %(%{_sbindir}/apxs2 -q DATADIR)
%define         apache_sysconfdir %(%{_sbindir}/apxs2 -q SYSCONFDIR)
%define         installpath %{apache_serverroot}/%{name}

Name:           koseven
Version:        3.3.7
Release:        0
Summary:        PHP 7 framework that uses the Model View Controller architectural pattern
License:        BSD-3-Clause
Group:          Productivity/Networking/Web/Utilities

Url:            https://kohanaframework.org/
Source0:        https://github.com/koseven/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        apache2-%{name}.conf

BuildRequires:  apache2-devel
BuildRequires:  fdupes
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

Requires:       mod_php_any
Requires:       php5-ZendFramework

Requires(pre):  http_daemon

Recommends:     php5-mcrypt

Provides:       kohana3 = %{version}
Obsoletes:      kohana3 < %{version}


%description
Koseven is a PHP 7 framework that uses the Model View Controller architectural
pattern with a loosely coupled architecture and UTF-8 compatibility.

%prep
%setup -q -n %{name}-%{version}

%build

%install
mkdir -p %{buildroot}/%{installpath}
cp -r * %{buildroot}/%{installpath}/

find %{buildroot}/%{installpath}/ -type d -exec chmod 755 {} +
find %{buildroot}/%{installpath}/ -type f -exec chmod 644 {} +
find %{buildroot}/%{installpath}/ -type f -name ".gitignore" -delete

for dir in application/logs application/cache; do
  chmod 775 %{buildroot}/%{installpath}/$dir
done

# install apache config
mkdir -p %{buildroot}/%{apache_sysconfdir}/conf.d/
install -m640 %{SOURCE1} %{buildroot}/%{apache_sysconfdir}/conf.d/%{name}.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}/public/example.htaccess

%fdupes %{buildroot}

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

%post
%restart_on_update apache2

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

%files
%defattr(-,root,root)
%doc LICENSE.md README.md
%dir %{apache_serverroot}/%{name}
%{apache_serverroot}/%{name}/
%attr(-,wwwrun,www) %{apache_serverroot}/%{name}/application/cache
%attr(-,wwwrun,www) %{apache_serverroot}/%{name}/application/logs
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/

%changelog
openSUSE Build Service is sponsored by