Sync from SUSE:ALP:Source:Standard:1.0 apache-rpm-macros-control revision 176b2ddd152df8b1c4cbdd34828d0ee9

This commit is contained in:
Adrian Schröter 2024-10-14 13:52:49 +02:00
commit d3bc8842e2
4 changed files with 160 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,19 @@
-------------------------------------------------------------------
Sun Nov 24 17:42:16 UTC 2019 - Neal Gompa <ngompa13@gmail.com>
- Replace incorrect usage of %_libexecdir/rpm with %_rpmconfigdir
-------------------------------------------------------------------
Fri Dec 18 23:37:37 UTC 2015 - opensuse@cboltz.de
- fix typo in %apache_request_restart
-------------------------------------------------------------------
Tue Nov 10 15:12:08 UTC 2015 - pgajdos@suse.com
- initial version of the package 20151110 [bsc#893659]
macros: %define apache_restart_flag
%apache_request_restart
%apache_restart_if_needed

View File

@ -0,0 +1,50 @@
#
# spec file for package apache-rpm-macros-control
#
# Copyright (c) 2015 SUSE LINUX 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/
#
%if 0%{?suse_version} > 1230
%define macros_dir %{_rpmconfigdir}/macros.d
%else
%define macros_dir %{_sysconfdir}/rpm
%endif
Name: apache-rpm-macros-control
Version: 20151110
Release: 0
Summary: Apache RPM Macros
License: Apache-2.0
Group: Productivity/Networking/Web/Servers
Url: http://httpd.apache.org/
Source1: macros.apache-control
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Macros intended for Apache restarts in rpm scriptlets.
%prep
%build
%install
mkdir -p %{buildroot}%{macros_dir}
install -m 644 %{SOURCE1} %{buildroot}%{macros_dir}
%files
%defattr(-,root,root)
%dir %{macros_dir}
%{macros_dir}/macros.apache*
%changelog

68
macros.apache-control Normal file
View File

@ -0,0 +1,68 @@
# flag pattern: %%{apache_restart_flag} restart all
# %%{apache_restart_flag}@ restart apache2.service
# %%{apache_restarT_flag}@<name> restart apache2@<name>.service
%apache_restart_flag /var/run/httpd.restart.flag
#
# macro: apache_module_request_restart -- request restart of the apache
# instance(s) after rpm or zypper transaction
#
# usage: apache_request_restart [-m module]
#
# module: restart every instance for which a2enmod -q <module> is true; if
# no module specified, request restart of all instances
#
%apache_request_restart(m:) \
if [ -x /usr/bin/systemctl ]; then \
MODULE=%{-m:%{-m*}} \
if [ -z "$MODULE" ]; then \
# restart all instances \
touch %{apache_restart_flag} \
echo 'Requesting apache restart (all instances)' \
else \
running_units=$(systemctl list-units | grep 'apache2\\(@.*\\)\\?.service' | sed 's:\\(\\.service\\).*:\\1:') \
for unit in $running_units; do \
instance_name=$(echo $unit | sed 's:apache2@\\?\\(.*\\).service:\\1:') \
if HTTPD_INSTANCE="$instance_name" a2enmod -q $MODULE; then \
# restart only specified instance, %%{apache_restart_flag}@ \
# means _only_ apache2.service \
echo "$instance_name" > %{apache_restart_flag}@$instance_name \
echo "Requesting apache restart ($instance_name instance)" \
fi \
done \
fi \
fi \
%nil
#
# macro: apache_module_restart_if_needed
#
#
%apache_restart_if_needed() \
if [ -x /usr/bin/systemctl ]; then \
if [ -e %{apache_restart_flag} ]; then \
/usr/bin/systemctl daemon-reload > /dev/null 2>&1 || : \
/usr/bin/systemctl restart apache2.target > /dev/null 2>&1 || : \
echo 'Restarting apache (all instances)' \
# all instances was restarted, removing all flags \
rm %{apache_restart_flag}* \
else \
/usr/bin/systemctl daemon-reload > /dev/null 2>&1 || : \
for flag in %{apache_restart_flag}@*; do \
if [ ! -e $flag ]; then \
# %%{apache_restart_flag}@* have not matched anything \
break \
fi \
instance_name=$(cat $flag) \
if [ -z "$instance_name" ]; then \
instance_suffix="" \
else \
instance_suffix="@$instance_name" \
fi \
echo "Restarting apache ($instance_name instance)" \
/usr/bin/systemctl restart apache2${instance_suffix}.service > /dev/null 2>&1 || : \
rm %{apache_restart_flag}@$instance_name \
done \
fi \
fi \
%nil