File wordpress.spec of Package wordpress

#
# spec file for package wordpress
#
# Copyright (c) 2025 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 wp_root %{apache_serverroot}/%{name}
%define wp_config_root %{_sysconfdir}/%{name}
Name:           wordpress
Version:        6.7.2
Release:        0
Summary:        World largest Bloging tool
License:        GPL-2.0-only
Group:          Productivity/Networking/Web/Frontends
URL:            https://wordpress.org
Source0:        https://wordpress.org/%{name}-%{version}.tar.gz
Source1:        %{name}-%{version}-lang-de_DE.tar.gz
Source10:       README.SUSE
Source11:       %{name}.httpd
Source12:       %{name}.fpm
Source20:       %{name}.rpmlintrc
# prepare wp-config for unique phrase
Patch1:         %{name}-sysconfdir.patch
Patch2:         %{name}-disable-core-auto-updates.patch
BuildRequires:  apache-rpm-macros
BuildRequires:  systemd-rpm-macros
Requires:       %{name}-plugins = %{version}-%{release}
Requires:       %{name}-themes = %{version}-%{release}
Requires:       php-dom
Requires:       php-gd
Requires:       php-mysql
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         shadow
# php-curl and php-zlib are used to download themes
Recommends:     php-curl
Recommends:     php-zlib
BuildArch:      noarch
%{?systemd_ordering}
%if 0%{?suse_version}
BuildRequires:  fdupes
BuildRequires:  php-fpm
%endif

%description
WordPress started in 2003 with a single bit of code to enhance the
typography of everyday writing and with fewer users than you can count
on your fingers and toes. Since then it has grown to be the largest
self-hosted blogging tool in the world, used on hundreds of thousands
of sites and seen by tens of millions of people every day.

%package lang-de_DE
Summary:        German language files for wordpress
Group:          Productivity/Networking/Web/Frontends
Requires:       %{name} = %{version}-%{release}
Conflicts:      lang-de_DE_formal

%description lang-de_DE
This package includes german language files for wordpress

%package plugins
Summary:        Plugins for wordpress
Group:          Productivity/Networking/Web/Frontends
Requires:       %{name} = %{version}-%{release}

%description plugins
This package includes plugins for wordpress:
custom-post-widget 1.9.5

%package themes
Summary:        Original Themes for wordpress
Group:          Productivity/Networking/Web/Frontends
Requires:       %{name} = %{version}-%{release}

%description themes
This package includes original themes for wordpress

%package apache
Summary:        Apache configuration for %{name}
Group:          Productivity/Networking/Web/Frontends
Requires:       %{name} = %{version}-%{release}
Supplements:    (apache2 and %name)
%if 0%{?suse_version}
BuildRequires:  apache2
Requires:       apache2
Requires:       (mod_php_any or php-fpm)
%else
# These are Redhat identifiers
BuildRequires:  httpd-devel
Requires:       httpd
Requires:       (mod_php_any or php-fpm)
%endif

%description apache
This subpackage contains the Apache configuration files

%if 0%{?suse_version}
%package fpm
Summary:        Configuration file for php-fpm
Group:          Productivity/Networking/Web/Frontends
Requires:       %{name} = %{version}-%{release}
Requires:       php-fpm
Supplements:    (php-fpm and %name)

%description fpm
This package is useful for deployments with nginx and php-fpm as web app server.
It provides a php-fpm pool config file, and creates a wordpress user, used to
run the fpm subprocess.
%endif

%prep
%setup -q -n %{name} -a 1
# add README.SUSE
cp -a %{SOURCE10} .
# create wp-config
%patch -P 1 -p1
%patch -P 2 -p1

## rpmlint
# wrong-file-end-of-line-encoding
perl -p -i -e "s|\r\n|\n|" license.txt
# wrong-script-end-of-line-encoding
#%%{__perl} -p -i -e "s|\r\n|\n|" wp-content/themes/layers/*
perl -p -i -e "s|\r\n|\n|" wp-config-sample.php
# script-without-shebang (has executable bits set)
find ./ -type f -exec chmod 0644 {} \;
# unneeded htaccess-file, it is in wordpress.httpd
rm wp-content/plugins/akismet/.htaccess

%build
# no need for build

%install
install -d %{buildroot}%{wp_config_root}
install -d %{buildroot}%{wp_root}
cp -av * %{buildroot}%{wp_root}/

# install apache conf
install -D -m0644 %{SOURCE11} %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
sed -i -e "s|@WP_ROOT@|%{wp_root}|" %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf

%if 0%{?suse_version}
# install fpm conf
install -D -m0644 %{SOURCE12} %{buildroot}%{_sysconfdir}/php7/fpm/pool.d/%{name}.conf
%endif

# move wp-config to /etc/wordpress
mv %{buildroot}%{wp_root}/wp-config-sample.php %{buildroot}%{wp_config_root}/wp-config-sample.php
cp %{buildroot}%{wp_config_root}/wp-config-sample.php %{buildroot}%{wp_config_root}/wp-config.php
sed -i -e "s|@WP_CONFIG_ROOT@|%{wp_config_root}|g" \
    %{buildroot}%{wp_root}/wp-admin/setup-config.php \
    %{buildroot}%{wp_root}/wp-load.php

# some cleanup
rm %{buildroot}%{wp_root}/{license.txt,readme.html}

## rpmlint
# files duplicates
%fdupes %{buildroot}%{wp_root}

%post
chown -R %{apache_user}:root %{wp_root}
chown -R root:%{apache_group} %{wp_config_root}

%post apache
%service_add_post apache2.service

%postun apache
%service_del_postun apache2.service

%if 0%{?suse_version}
%pre fpm
%{_sbindir}/groupadd -r %{name}  &>/dev/null || :
%{_sbindir}/useradd  -g %{name} -s /bin/false -r -c "%{name}" -d %{wp_root} %{name} &>/dev/null || :
%endif

%files
%license license.txt
%doc readme.html README.SUSE
%config(noreplace) %attr(640,root,%{apache_group}) %{wp_config_root}/wp-config.php
%config %{wp_config_root}/wp-config-sample.php
%attr(640,root,%{apache_group}) %{wp_config_root}/wp-config-sample.php
%dir %attr(750,root,%{apache_group}) %{wp_config_root}
%{wp_root}
# exclude language de_DE
%exclude %{wp_root}/wp-content/languages/*de_DE*
%exclude %{wp_root}/wp-content/languages/themes/*de_DE*
%exclude %{wp_root}/wp-content/languages/plugins/*de_DE*
# exlude plugins
%exclude %{wp_root}/wp-content/plugins/*
# exclude themes
%exclude %{wp_root}/wp-content/themes/*
# only wp-content for upgrade
%defattr(-,%{apache_user},root)
%{wp_root}/wp-content/

%files apache
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf

%if 0%{?suse_version}
%files fpm
%dir %{_sysconfdir}/php7/fpm/pool.d
%config(noreplace) %{_sysconfdir}/php7/fpm/pool.d/%{name}.conf
%dir %{_sysconfdir}/php7
%dir %{_sysconfdir}/php7/fpm
%endif

%files lang-de_DE
%defattr(-,%{apache_user},root)
%{wp_root}/wp-content/languages/*de_DE.*
%{wp_root}/wp-content/languages/themes/*de_DE.*
%{wp_root}/wp-content/languages/plugins/*de_DE.*

%files plugins
%defattr(-,%{apache_user},root)
%{wp_root}/wp-content/plugins/*

%files themes
%defattr(-,%{apache_user},root)
%{wp_root}/wp-content/themes/index.php
%{wp_root}/wp-content/themes/twentytwentythree
%{wp_root}/wp-content/themes/twentytwentyfour
%{wp_root}/wp-content/themes/twentytwentyfive

%changelog
openSUSE Build Service is sponsored by