File drupal7.spec of Package drupal7

# spec file for package drupal7
# Copyright (c) 2020 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

%define         drupaldir %{apache_serverroot}/%{name}
Name:           drupal7
Version:        7.76
Release:        0
Summary:        Open source content management platform
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Web/Utilities
Source4:        %{name}-README.SUSE
# Just needed to own packages
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

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:       apache2
Requires:       mod_php_any >= 5.3
Supplements:    packageand(apache2:%name)

%description apache
This subpackage contains the Apache configuration files

%setup -q -n drupal-%{version}
find . -type f -name "*.txt" -exec chmod -x {} +
sh scripts/
find . -type f -exec sed -i 's|#!%{_bindir}/env.*sh$|#!/bin/sh|' {} \;
find . -type f -exec sed -i 's|#!%{_bindir}/env.*php$|#!%{_bindir}/php|' {} \;

# nothing to build

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
if [ -f /run/ ]; then
    %{_bindir}/ --root %{drupaldir} http://localhost/drupal/cron.php 1>/dev/null 2>&1
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 !mod_authz_core.c>
      Order allow,deny
      #Allow from all
      Allow from localhost

    # 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

sed -e 's/^/    /' .htaccess >> %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
cat >> %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf << EOF
install -m755 scripts/  %{buildroot}%{_bindir}/
cp -pR * %{buildroot}%{drupaldir}
# remove unneeded stuff/scripts
rm -rf %{buildroot}%{drupaldir}/scripts
mv %{buildroot}%{drupaldir}/robots.txt %{buildroot}%{drupaldir}/
rm %{buildroot}%{drupaldir}/*.txt
mv %{buildroot}%{drupaldir}/ %{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}%{drupaldir}/sites/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:   /

%post apache
%restart_on_update apache2

%postun apache
%restart_on_update apache2

%license COPYRIGHT.txt LICENSE.txt
%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

openSUSE Build Service is sponsored by