Accepting request 343856 from home:pgajdos

- restart apache once after the rpm or zypper transaction 
  [bnc#893659]
- drop some old compat code from %post

OBS-URL: https://build.opensuse.org/request/show/343856
OBS-URL: https://build.opensuse.org/package/show/Apache/apache2?expand=0&rev=466
This commit is contained in:
Petr Gajdos 2015-11-11 14:08:56 +00:00 committed by Git OBS Bridge
parent a0baaeb8ec
commit e7ee2b1556
5 changed files with 62 additions and 46 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Nov 6 10:06:19 UTC 2015 - pgajdos@suse.com
- restart apache once after the rpm or zypper transaction
[bnc#893659]
- drop some old compat code from %post
-------------------------------------------------------------------
Thu Nov 5 16:52:45 UTC 2015 - crrodriguez@opensuse.org

View File

@ -2,6 +2,7 @@
Description=The Apache Webserver
After=network.target nss-lookup.target time-sync.target
Before=getty@tty1.service plymouth-quit.service xdm.service
PartOf=apache2.target
[Service]
Type=notify

View File

@ -19,9 +19,9 @@
%define apache_mmn %(test -s %{SOURCE0} && { echo -n apache_mmn_; bzcat %{SOURCE0} | awk '/^#define MODULE_MAGIC_NUMBER_MAJOR/ {printf "%d", $3}'; })
%define suse_maintenance_mmn 0
%define default_mpm prefork
%{!?prefork:%define prefork 1}
%{!?worker:%define worker 1}
%{!?event:%define event 1}
%define prefork 1
%define worker 1
%define event 1
%define mpms_to_build %(test %{prefork} = 1 && printf prefork) %(test %{worker} = 1 && printf worker) %(test %{event} = 1 && printf event)
# dir names
%define datadir /srv/www
@ -49,6 +49,7 @@
%define runtimedir %{_localstatedir}/run
%define mods_static unixd
%endif
Name: apache2
Version: 2.4.17
Release: 0
@ -110,6 +111,7 @@ Source144: apache2.service
Source145: apache2-find-directives
Source146: apache2@.service
Source147: apache2-script-helpers
Source148: apache2.target
Patch2: httpd-2.1.3alpha-layout.dif
Patch23: httpd-apachectl.patch
Patch66: httpd-2.0.54-envvars.dif
@ -124,6 +126,7 @@ Patch111: httpd-visibility.patch
Patch114: httpd-2.4.12-lua-5.2.patch
Patch1000: https://raw.githubusercontent.com/icing/mod_h2/master/sandbox/httpd/patches/2.4.17-protocols.patch
BuildRequires: automake
BuildRequires: apache-rpm-macros-control
BuildRequires: db-devel
BuildRequires: ed
BuildRequires: libapr-util1-devel
@ -255,6 +258,7 @@ Requires: apache2-prefork
Requires: gcc
Requires: libapr-util1-devel
Requires: libapr1-devel
Requires: apache-rpm-macros-control
%description devel
This package contains header files and include files that are needed
@ -534,6 +538,7 @@ mkdir -p %{buildroot}%{_unitdir}/
install -m 700 $RPM_SOURCE_DIR/apache2-systemd-ask-pass %{buildroot}%{_sbindir}/
install -m 644 $RPM_SOURCE_DIR/apache2.service %{buildroot}%{_unitdir}/
install -m 644 $RPM_SOURCE_DIR/apache2@.service %{buildroot}%{_unitdir}/
install -m 644 $RPM_SOURCE_DIR/apache2.target %{buildroot}%{_unitdir}/
ln -sf service %{buildroot}/%{_sbindir}/rcapache2
%else
mkdir -p %{buildroot}%{_sysconfdir}/init.d
@ -790,6 +795,7 @@ mv %{buildroot}/%{sysconfdir}/original .
%if 0%{?suse_version} >= 1210
%{_unitdir}/apache2.service
%{_unitdir}/apache2@.service
%{_unitdir}/apache2.target
%{_sbindir}/apache2-systemd-ask-pass
%else
%{_initddir}/%{name}
@ -1262,6 +1268,7 @@ mv %{buildroot}/%{sysconfdir}/original .
%{_sbindir}/suexec2
%if %{prefork}
#
%post prefork
# install /usr/sbin/httpd link
if [ -f /usr/share/apache2/script-helpers ]; then
@ -1274,8 +1281,18 @@ if [ -f /usr/share/apache2/script-helpers ]; then
find_mpm
ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE
fi
#
exit 0
#
%postun prefork
if [ $1 -eq 1 ]; then
%apache_request_restart
fi
exit 0
#
%posttrans prefork
%apache_restart_if_needed
exit 0
#
%endif
%if %{worker}
@ -1291,8 +1308,18 @@ if [ -f /usr/share/apache2/script-helpers ]; then
find_mpm
ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE
fi
#
exit 0
#
%postun worker
if [ $1 -eq 1 ]; then
%apache_request_restart
fi
exit 0
#
%posttrans worker
%apache_restart_if_needed
exit 0
#
%endif
%if %{event}
@ -1308,20 +1335,28 @@ if [ -f /usr/share/apache2/script-helpers ]; then
find_mpm
ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE
fi
#
exit 0
#
%postun event
if [ $1 -eq 1 ]; then
%apache_request_restart
fi
exit 0
#
%posttrans event
%apache_restart_if_needed
exit 0
#
%endif
%pre
%if 0%{?suse_version} >= 1210
%service_add_pre apache2.service
%service_add_pre apache2@.service
%endif
%preun
%if 0%{?suse_version} >= 1210
%service_del_preun apache2.service
%service_del_preun apache2@.service
%service_del_preun apache2.target
%endif
for i in %{_sbindir}/httpd \
%{installbuilddir}/config_vars.mk
@ -1332,8 +1367,11 @@ exit 0
%postun
%if 0%{?suse_version} >= 1210
%service_del_postun apache2.service
%service_del_postun apache2@.service
DISABLE_RESTART_ON_UPDATE='yes'
%service_del_postun apache2.target
if [ $1 -eq 1 ]; then
%apache_request_restart
fi
%else
%insserv_cleanup
%endif
@ -1350,46 +1388,12 @@ if grep -q "^wwwadmin:" %{_sysconfdir}/group; then
usermod -g %{httpdgroup} %{httpduser} 2>/dev/null ||:
usermod -s /bin/false %{httpduser} 2>/dev/null ||:
fi
tmpdir=$(mktemp -d etc/%{name}/%{name}-post.XXXXXX); test $? = 0 || { echo >&2 Could not create tmpdir. Exiting; exit 1; }
tmpfile=$tmpdir/tmpfile
if test -s etc/sysconfig/%{name} && grep -q "^LOADMODULES" etc/sysconfig/%{name}; then
sed "s/LOADMODULES/APACHE_MODULES/" etc/sysconfig/%{name} >| $tmpfile \
&& cp $tmpfile etc/sysconfig/%{name}
fi
%{fillup_only apache2}
%if 0%{?suse_version} >= 1210
%service_add_post apache2.service
%service_add_post apache2@.service
%else
%{fillup_and_insserv apache2}
%endif
if [ $1 -gt 1 ] ; then
# update from package with the old near-monolithic conf file?
if [ -s ./%{sysconfdir}/httpd.conf.default -a -s ./%{sysconfdir}/httpd.conf.rpmnew ]; then
diff -u .%{sysconfdir}/httpd.conf.default .%{sysconfdir}/httpd.conf \
> $tmpdir/httpd.conf.dif ||:
cp -p $tmpdir/httpd.conf.dif ./%{sysconfdir}/httpd.conf var/adm/backup/
archive_conf=$(old var/adm/backup/httpd.conf 2>/dev/null); archive_conf=${archive_conf##*/}
archive_dif=$(old var/adm/backup/httpd.conf.dif 2>/dev/null); archive_dif=${archive_dif##*/}
fi
#
sed "
# generated files were renamed from suse_* to sysconfig.d/*
s|\(^Include %{_sysconfdir}/apache2\)/suse_\(\(include\|loadmodule\|global\).conf\)|\1/sysconfig.d/\2|
# the access_log configuration is now configurable
s|^CustomLog %{_localstatedir}/log/apache2/access_log.*|# &|
# group of wwwrun has changed
s|^Group nogroup|Group www|
" < ./%{sysconfdir}/httpd.conf > $tmpfile
chmod --reference=./%{sysconfdir}/httpd.conf $tmpfile
chown --reference=./%{sysconfdir}/httpd.conf $tmpfile
cmp -s $tmpfile ./%{sysconfdir}/httpd.conf || cp -p $tmpfile ./%{sysconfdir}/httpd.conf
fi
rm -rf $tmpdir
# install /usr/bin/httpd link (the code here is
# needed when apache2 was installed after apache2-<MPM>)
. /usr/share/apache2/script-helpers
@ -1402,8 +1406,8 @@ exit 0
%posttrans
%{_datadir}/%{name}/apache-22-24-upgrade
%verifyscript
%verify_permissions -e %{_sbindir}/suexec
%apache_restart_if_needed
%changelog

3
apache2.target Normal file
View File

@ -0,0 +1,3 @@
[Unit]
Description=Apache target allowing to control multi setup

View File

@ -2,6 +2,7 @@
Description=The Apache Webserver %I
After=network.target nss-lookup.target time-sync.target
Before=getty@tty1.service plymouth-quit.service xdm.service
PartOf=apache2.target
[Service]
Type=notify