File drupal7.spec of Package drupal7
#
# spec file for package drupal7
#
# Copyright (c) 2023 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 drupaldir %{apache_serverroot}/%{name}
Name: drupal7
Version: 7.98
Release: 0
Summary: Open source content management platform
License: GPL-2.0-or-later
Group: Productivity/Networking/Web/Utilities
URL: https://www.drupal.org
Source0: https://ftp.drupal.org/files/projects/drupal-%{version}.tar.gz
Source4: %{name}-README.SUSE
BuildRequires: apache-rpm-macros
BuildRequires: cron
Requires: cron
Requires: curl
Requires: mysql
Requires: php >= 5.3
Requires: php-gd >= 5.3
Requires: php-mbstring >= 5.3
Recommends: php-mysql >= 5.3
Recommends: php-pgsql >= 5.3
BuildArch: noarch
%description
Drupal is a free software package that allows an individual or a
community of users to easily publish, manage and organize a wide variety
of content on a website. Tens of thousands of people and organizations
have used Drupal to power scores of different web sites, including
* Community web portals
* Discussion sites
* Corporate web sites
* Intranet applications
* Personal web sites or blogs
* Aficionado sites
* E-commerce applications
* Resource directories
* Social Networking sites
%package apache
Summary: Apache configuration for %{name}
Group: Productivity/Networking/Web/Utilities
BuildRequires: apache2
Requires: %{name} = %{version}
Requires: apache2
Requires: mod_php_any >= 5.3
Supplements: packageand(apache2:%name)
%description apache
This subpackage contains the Apache configuration files
%prep
%setup -q -n drupal-%{version}
find . -type f -name "*.txt" -exec chmod -x {} +
sh scripts/code-clean.sh
cp %{SOURCE4} ./README.SUSE
find . -type f -exec sed -i 's|#!%{_bindir}/env.*sh$|#!/bin/sh|' {} \;
find . -type f -exec sed -i 's|#!%{_bindir}/env.*php$|#!%{_bindir}/php|' {} \;
%build
# nothing to build
%install
install -d %{buildroot}%{drupaldir}
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_sysconfdir}/%{name}
install -d %{buildroot}%{_docdir}/%{name}
install -d %{buildroot}%{_localstatedir}/lib/%{name}
install -d %{buildroot}%{_sysconfdir}/cron.hourly
cat > %{buildroot}%{_sysconfdir}/cron.hourly/%{name} << EOF
#!/bin/sh
if [ -f /run/httpd2.pid ]; then
%{_bindir}/drupal.sh --root %{drupaldir} http://localhost/drupal/cron.php 1>/dev/null 2>&1
fi
EOF
install -d %{buildroot}%{apache_sysconfdir}/conf.d
cat > %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf << EOF
#
# Drupal is an open-source content-management platform.
#
Alias /drupal "%{drupaldir}"
<Directory "%{drupaldir}">
AllowOverride None
# Uncomment "Allow from all" and "Require all granted" for public use
<IfModule mod_authz_core.c>
#Require all granted
Require local
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
#Allow from all
Allow from localhost
</IfModule>
# The following line for is for setup - uncomment for public use
# Uncomment the next line if using with SSL/TLS
#php_flag session.cookie_secure on
EOF
sed -e 's/^/ /' .htaccess >> %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
cat >> %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf << EOF
</Directory>
EOF
install -m755 scripts/drupal.sh %{buildroot}%{_bindir}/
cp -pR * %{buildroot}%{drupaldir}
# remove unneeded stuff/scripts
rm -rf %{buildroot}%{drupaldir}/scripts
mv %{buildroot}%{drupaldir}/robots.txt %{buildroot}%{drupaldir}/robots.txt.save
rm %{buildroot}%{drupaldir}/*.txt
mv %{buildroot}%{drupaldir}/robots.txt.save %{buildroot}%{drupaldir}/robots.txt
# move site-configs to %%{_sysconfdir}/%%{name} with symlink to it
mv %{buildroot}%{drupaldir}/sites/* %{buildroot}%{_sysconfdir}/%{name}
rmdir %{buildroot}%{drupaldir}/sites
ln -s %{_sysconfdir}/%{name} %{buildroot}%{drupaldir}/sites
# linking filesdir
ln -s %{_localstatedir}/lib/%{name} %{buildroot}%{_sysconfdir}/%{name}/default/files
# copy ./sites/default/default.settings.php to ./sites/default/settings.php
cp -pR %{buildroot}%{_sysconfdir}/%{name}/default/default.settings.php %{buildroot}%{_sysconfdir}/%{name}/default/settings.php
# create new robots.txt
cat > %{buildroot}%{_sysconfdir}/%{name}/robots.txt << EOF
User-agent: *
Disallow: /
EOF
%post apache
%restart_on_update apache2
%postun apache
%restart_on_update apache2
%files
%doc CHANGELOG.txt INSTALL*.txt MAINTAINERS.txt README.* UPGRADE.txt scripts
%license COPYRIGHT.txt LICENSE.txt
%{_bindir}/drupal.sh
%{drupaldir}
%attr(-,%{apache_user},%{apache_group}) %config(noreplace) %{_sysconfdir}/%{name}/default/settings.php
%attr(-,%{apache_user},%{apache_group}) %dir %{_sysconfdir}/%{name}/default
%attr(-,%{apache_user},%{apache_group}) %dir %{_sysconfdir}/%{name}/
%attr(-,%{apache_user},%{apache_group}) %dir %{_localstatedir}/lib/%{name}
%config %{_sysconfdir}/%{name}/README.txt
%config %{_sysconfdir}/%{name}/all/modules/README.txt
%config %{_sysconfdir}/%{name}/all/themes/README.txt
%config(noreplace) %{_sysconfdir}/%{name}/all
%attr(-,%{apache_user},%{apache_group}) %config(noreplace) %{_sysconfdir}/%{name}/default
%attr(755,root,%{apache_group}) %config(noreplace) %{_sysconfdir}/cron.hourly/%{name}
%dir %attr(775,root,%{apache_group})
%attr(640,root,%{apache_group}) %config(noreplace) %{_sysconfdir}/%{name}/robots.txt
%config %attr(640,root,%{apache_group}) %{_sysconfdir}/%{name}/example.sites.php
%files apache
%attr(-,%{apache_user},%{apache_group}) %config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%changelog