File joomla.spec of Package joomla

#
# spec file for package joomla
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define         installdir        %{_datadir}/php/%{name}
%define         joomla_webroot    /%{name}
%define         joomla_root       %{installdir}/%{name}
%define         joomla_tmpdir     %{installdir}/%{name}_tmpdir
%define         joomla_sessiondir %{installdir}/%{name}_sessiondir
Name:           joomla
Version:        5.2.4
Release:        0
Summary:        Joomla Open Source (CMS)
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Web/Frontends
URL:            http://www.joomla.org
Source0:        https://github.com/%{name}/%{name}-cms/releases/download/%{version}/Joomla_%{version}-Stable-Full_Package.zip
Source1:        %{name}-apache.conf
Source2:        joomla-apparmor.profile
Source90:       README.SUSE
Source99:       %{name}.rpmlintrc
BuildRequires:  apache-rpm-macros
BuildRequires:  fdupes
BuildRequires:  unzip
Requires:       php-dom
Requires:       php-mysql
Requires:       php-zlib
BuildArch:      noarch
Provides:       joomla5

%description
Joomla! is a Content Management System (CMS) created by the same award-winning
team that brought the Mambo CMS to its current state of stardom.

%package apache
Summary:        Apache configuration for %{name}
Group:          Productivity/Networking/Web/Frontends
BuildRequires:  apache2
Requires:       apache2
Requires:       mod_php_any >= 7.2.5
Requires:       %{name} >= %{version}
Supplements:    (apache2 and %{name})

%description apache
This subpackage contains the Apache configuration files

%package installation
Summary:        Joomla Open Source (CMS)
Group:          Productivity/Networking/Web/Frontends
URL:            http://www.joomla.org
Requires:       joomla = %{version}

%description installation
Joomla! is a Content Management System (CMS) created by the same award-winning
team that brought the Mambo CMS to its current state of stardom.

Installation tools that should be removed when they aren't in use.

%prep
%setup -q -c -n joomla-%{version}
install %{SOURCE90} .

# clean up CVS stuff
for i in `find . -type d -name CVS` `find . -type f -name .cvs\*` `find . -type f -name .#\*`;
do
    if [ -e "$i" ]; then rm -r $i; fi
done
rm -rf libraries/vendor/tobscure/json-api/.git

# remove hidden files
find . -type f "(" -name '.drone.jsonnet' -o -name '.drone.yml' -o -name '.php_cs' ")" -delete

# fix file perms
find . -type f | xargs chmod 644

# strip away annoying ^M
find . -type f|xargs file|grep 'CRLF'|cut -d: -f1|xargs perl -p -i -e 's/\r//'
find . -type f|xargs file|grep 'text'|cut -d: -f1|xargs perl -p -i -e 's/\r//'

# remove .htacces; it was in joomla-apache.conf
rm libraries/.htaccess

%build
# nothiing to do

%install
mkdir -p %{buildroot}%{joomla_root} %{buildroot}%{joomla_tmpdir} %{buildroot}%{joomla_sessiondir}
cp -aRf *  %{buildroot}%{joomla_root}

# favicon
test -f %{buildroot}%{joomla_root}/favicon.ico || touch %{buildroot}%{joomla_root}/favicon.ico
test -f %{buildroot}%{joomla_root}/robots.txt  || \
	sed -e "s|Disallow: /|Disallow: %{joomla_webroot}/|g" \
		%{buildroot}%{joomla_root}/robots.txt.dist \
		> %{buildroot}%{joomla_root}/robots.txt

# apache config
mkdir -p %{buildroot}%{apache_sysconfdir}/conf.d/
sed -e "s|__JOOMLA_ROOT__|%{joomla_root}|g; \
		s|__JOOMLA_WEBROOT__|%{joomla_webroot}|g; \
		s|__JOOMLA_TMPDIR__|%{joomla_tmpdir}|g; \
		s|__JOOMLA_SESSIONDIR__|%{joomla_sessiondir}|g;" \
		%{SOURCE1} > %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
# apparmor config
mkdir -p %{buildroot}%{_sysconfdir}/apparmor.d/{apache2.d,local}
sed -e "s|__JOOMLA_ROOT__|%{joomla_root}|g; \
        s|__JOOMLA_WEBROOT__|%{joomla_webroot}|g; \
        s|__JOOMLA_TMPDIR__|%{joomla_tmpdir}|g; \
        s|__JOOMLA_SESSIONDIR__|%{joomla_sessiondir}|g;" \
        %{SOURCE2} > %{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 LICENSE.txt README.txt htaccess.txt robots.txt.dist web.config.txt \
  %{buildroot}%{_defaultdocdir}/%{name}/

# directories
pushd %{buildroot}%{joomla_root}
mkdir -p uploadfiles
popd

%fdupes %{buildroot}%{joomla_root}

%post apache
# only do on install, not on upgrade
if [ $1 -eq 1 ]; then
  # enable required apache modules
  a2enmod version >/dev/null || :

  # enable mod_php if preform MPM is used
  if start_apache2 -V | grep -q prefork; then
    mod_php=$(php -r "echo 'php' . PHP_MAJOR_VERSION;")
    echo "info: adding ${mod_php} to APACHE_MODULES"
    a2enmod ${mod_php} >/dev/null || :
  fi
fi
%restart_on_update apache2
# Fix not can't llogin -  it will be recreated automatically
echo "o %{name}: Remove some cache files..."
rm -f %{joomla_root}/administrator/cache/autoload_psr4.php || :

%postun apache
%restart_on_update apache2

%files
%defattr(0644,root,root,0755)
%doc README.SUSE
%doc %{_defaultdocdir}/%{name}/*
%dir %{_datadir}/php
%dir %{installdir}
%dir %{_sysconfdir}/apparmor.d
%dir %{_sysconfdir}/apparmor.d/local
%{_defaultdocdir}/%{name}/
%config(noreplace) %{joomla_root}/robots.txt
%config(noreplace) %{joomla_root}/favicon.ico
%config(noreplace) %{_sysconfdir}/apparmor.d/local/%{name}
%defattr(0644,%{apache_user},%{apache_group},0755)
%dir %{joomla_tmpdir}
%dir %{joomla_sessiondir}
%{joomla_root}/
%{joomla_root}/uploadfiles
%{joomla_root}/administrator/
%{joomla_root}/cache
%{joomla_root}/components/
%{joomla_root}/images/
%{joomla_root}/includes
%{joomla_root}/language/
%{joomla_root}/libraries/
%{joomla_root}/media/
%{joomla_root}/modules/
%{joomla_root}/plugins/
%{joomla_root}/templates/
%{joomla_root}/tmp/
%{joomla_root}/cli/
%{joomla_root}/api/
%{joomla_root}/layouts/
%exclude %{joomla_root}/installation

%files apache
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%dir %{_sysconfdir}/apparmor.d/apache2.d
%config %{_sysconfdir}/apparmor.d/apache2.d/%{name}
%exclude %{joomla_root}/installation

%files installation
%defattr(0644,root,root,0755)
%dir %{joomla_root}/installation/
%{joomla_root}/installation/*

%changelog
openSUSE Build Service is sponsored by