File elgg.spec of Package elgg

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

Name:           elgg
Version:        5.1.4
Release:        0
License:        GPL-2.0+
Summary:        Open source social networking engine
Url:            https://elgg.org/
Group:          Productivity/Networkin/Web/Servers 
Source:         %{name}-%{version}.zip
Source1:        %{name}-rpmlintrc
Source2:        %{name}_apache.conf
Source3:        %{name}-apparmor.profile
BuildRequires:  apache2-devel
BuildRequires:  fdupes
BuildRequires:  unzip
Recommends:     apache2
Requires:       http_daemon
Requires:       mod_php_any
Requires:       php-gd
Requires:       php-mysql
Requires:       php-mbstring
Requires:       php-pdo
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         apache_serverroot %(/usr/bin/apxs -q DATADIR)
%define         apache_sysconfdir %(/usr/bin/apxs -q SYSCONFDIR)
%define         elgg_webroot    %{apache_serverroot}/%{name}
%define         elgg_datadir    %{apache_serverroot}/%{name}_data
%define         elgg_root       %{apache_serverroot}/%{name}
%define         elgg_tmpdir     %{apache_serverroot}/%{name}_tmpdir
%define         elgg_sessiondir %{apache_serverroot}/%{name}_sessiondir
%define         crondir %{_sysconfdir}/cron.d

%description
Elgg is an award-winning open source social networking engine that provides a
robust framework on which to build all kinds of social environments, from a
campus wide social network for your university, school or college or an
internal collaborative platform for your organization through to a
brand-building communications tool for your company and its clients. 

%package install
Summary:        Elgg install files
Group:          Productivity/Networkin/Web/Servers
Requires:       %{name} == %{version}

%description install
This package contains installation files that should be removed after 
installation of Elgg

%prep
%setup -q -c -n %{name}-%{version}
find . -name .gitignore -delete
find . -name .travis.yml -delete

%build
#
%install
mkdir -p %{buildroot}%{elgg_root} %{buildroot}%{elgg_tmpdir} %{buildroot}%{elgg_sessiondir} %{buildroot}%{elgg_datadir}
cp -aRf %{name}-%{version}/*  %{buildroot}%{elgg_root}
# touch files for the installer - they should be writable by apache later
touch %{buildroot}%{elgg_root}/.htaccess
touch %{buildroot}%{elgg_root}/elgg-config/settings.php

# apache config
mkdir -p %{buildroot}%{apache_sysconfdir}/conf.d/
sed -e "s|__ELGG_ROOT__|%{elgg_root}|g; \
        s|__ELGG_DATADIR__|%{elgg_webroot}|g; \
        s|__ELGG_WEBROOT__|%{elgg_webroot}|g; \
        s|__ELGG_TMPDIR__|%{elgg_tmpdir}|g; \
        s|__ELGG_SESSIONDIR__|%{elgg_sessiondir}|g;" \
        %{SOURCE2} > %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf

# apparmor config
mkdir -p %{buildroot}%{_sysconfdir}/apparmor.d/{apache2.d,local}
sed -e "s|__ELGG_ROOT__|%{elgg_root}|g; \
        s|__ELGG_DATADIR__|%{elgg_datadir}|g; \
        s|__ELGG_WEBROOT__|%{elgg_webroot}|g; \
        s|__ELGG_TMPDIR__|%{elgg_tmpdir}|g; \
        s|__ELGG_SESSIONDIR__|%{elgg_sessiondir}|g;" \
        %{SOURCE3} > %{buildroot}%{_sysconfdir}/apparmor.d/apache2.d/%{name}
echo "# Site-specific additions and overrides for '%{name}'" > %{buildroot}%{_sysconfdir}/apparmor.d/local/%{name}

# documentation
mkdir -p  %{buildroot}%{_defaultdocdir}/%{name}
mv %{buildroot}%{elgg_root}/vendor/elgg/elgg/docs/*.{md,txt} %{buildroot}%{_defaultdocdir}/%{name}/
mv %{buildroot}%{elgg_root}/vendor/elgg/elgg/*.{md,txt} %{buildroot}%{_defaultdocdir}/%{name}/

%fdupes %{buildroot}%{elgg_root}

%clean
rm -rf %{buildroot}

%files
%defattr(0644,root,root,0755)
%doc %{_defaultdocdir}/%{name}
%dir %{_sysconfdir}/apparmor.d
%dir %{_sysconfdir}/apparmor.d/apache2.d
%dir %{_sysconfdir}/apparmor.d/local
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%config(noreplace) %{_sysconfdir}/apparmor.d/local/%{name}
%config %{_sysconfdir}/apparmor.d/apache2.d/%{name}
%{elgg_root}/
%exclude %{elgg_root}/vendor/elgg/elgg/views/installation
%exclude %{elgg_root}/vendor/elgg/elgg/install
%exclude %{elgg_root}/vendor/elgg/elgg/install.php
%defattr(0644,wwwrun,www,0775)
%dir %{elgg_tmpdir}
%dir %{elgg_sessiondir}
%attr(0770,wwwrun,www) %dir %{elgg_datadir}
%config(noreplace) %{elgg_root}/.htaccess
%config(noreplace) %{elgg_root}/elgg-config/settings.php

%files install
%defattr(0644,root,root,0755)
%{elgg_root}/vendor/elgg/elgg/views/installation
%{elgg_root}/vendor/elgg/elgg/install
%{elgg_root}/vendor/elgg/elgg/install.php

%changelog
openSUSE Build Service is sponsored by