diff --git a/apache2-script-helpers b/apache2-script-helpers index 9c06343..3f67881 100644 --- a/apache2-script-helpers +++ b/apache2-script-helpers @@ -25,37 +25,33 @@ function load_sysconfig function find_mpm { - [ -n "$mpm_found" ] && return - - # load sysconfig variables if they weren't yet + # load sysconfig variables if they weren't yet; + # this has no effect when find_mpm is not called + # from start_apache2 load_sysconfig # try to read from sysconfig's APACHE_MPM - HTTPD_MPM=$APACHE_MPM + HTTPD_MPM="$APACHE_MPM" # if empty, then choose one from installed if [ -z "$HTTPD_MPM" ]; then - # guess + installed_mpms="" for i in $HTTPD_SBIN_BASE-*; do test -f $i || continue i=$(basename $i) i=${i#*-} - installed_mpms=(${installed_mpms[*]} $i) + installed_mpms="$installed_mpms $i" + done + # hardcoded preference here: + for mpm in event worker prefork; do + if [[ $installed_mpms =~ "$mpm" ]]; then + HTTPD_MPM=$mpm + break + fi done - if [ -z "${installed_mpms[*]}" ]; then - HTTPD_MPM="" - return - elif [ ${#installed_mpms[*]} = 1 ]; then - HTTPD_MPM=${installed_mpms[*]} - else - case ${installed_mpms[*]} in - *prefork*) HTTPD_MPM=prefork;; - *worker*) HTTPD_MPM=worker;; - *event*) HTTPD_MPM=event;; - esac - fi fi - export HTTPD_MPM mpm_found=true + # in case no + export HTTPD_MPM } # diff --git a/apache2.changes b/apache2.changes index 3a2527f..7da864a 100644 --- a/apache2.changes +++ b/apache2.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Sep 27 10:25:40 UTC 2018 - Petr Gajdos + +- relink /usr/sbin/httpd after apache2-MPM uninstall [bsc#1107930c#1] +- simplify find_mpm function from script-helpers +- /usr/sbin/httpd is now created depending on preference hardcoded + in find_mpm (script-helpers), not depending on alphabetical + order of MPMs +- simplify spec file a bit + ------------------------------------------------------------------- Mon Sep 24 12:53:08 UTC 2018 - Michael Ströder diff --git a/apache2.spec b/apache2.spec index 299de1c..52bd1ec 100644 --- a/apache2.spec +++ b/apache2.spec @@ -25,11 +25,7 @@ %define apache_mmn %(test -s %{SOURCE0} && { echo -n apache_mmn_; bzcat %{SOURCE0} | awk '/^#define MODULE_MAGIC_NUMBER_MAJOR/ {printf "%d", $3}'; } || echo apache_mmn_notfound) %define suse_maintenance_mmn 0 %define default_mpm prefork -%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 mpms_to_build prefork worker event %define datadir /srv/www %define htdocsdir %{datadir}/htdocs %define manualdir %{_datadir}/%{name}/manual @@ -228,7 +224,6 @@ Caching API. See %{_docdir}/apache2/, http://httpd.apache.org/, and http://httpd.apache.org/docs-2.4/upgrading.html. -%if %worker %package worker Summary: Apache 2 worker MPM (Multi-Processing Module) Group: Productivity/Networking/Web/Servers @@ -236,9 +231,7 @@ Requires: %{name} = %{version} # the post scriptlet sources /usr/share/apache2/script-helpers Requires(post): %{name} = %{version} Provides: %{name}-MPM -%endif -%if %prefork %package prefork Summary: Apache 2 "prefork" MPM (Multi-Processing Module) Group: Productivity/Networking/Web/Servers @@ -247,9 +240,7 @@ Requires: %{name} = %{version} Requires(post): %{name} = %{version} Provides: %{name}-MPM Provides: apache:%{_sbindir}/httpd -%endif -%if %event %package event Summary: Apache 2 event MPM (Multi-Processing Module) Group: Productivity/Networking/Web/Servers @@ -257,27 +248,21 @@ Requires: %{name} = %{version} # the post scriptlet sources /usr/share/apache2/script-helpers Requires(post): %{name} = %{version} Provides: %{name}-MPM -%endif -%if %worker %description worker The worker MPM (multi-Processing Module) implementing a hybrid multi-threaded multi-process web server. This combination offers a performance boost and retains some of the stability of the multi-process model. -%endif -%if %{prefork} %description prefork "prefork" MPM (Multi-Processing Module) This MPM is basically the one that Apache 1.3.x used. It warrants the maximum stability because each server runs in its own process. If a process dies it will not affect other servers. -%endif -%if %{event} %description event The event MPM (multi-Processing Module) is experimental, so it may or may not work as expected. @@ -289,7 +274,6 @@ again until the Keep Alive timeout was reached. This MPM depends on APR's atomic compare-and-swap operations for thread synchronization. -%endif %package devel Summary: Apache 2 Header and Include Files @@ -894,7 +878,6 @@ rm %{buildroot}/%{sysconfdir}/*.test /usr/share/apache2/load_configuration %endif -%if %{prefork} %files prefork %defattr(-,root,root) %{_sbindir}/httpd-prefork @@ -1021,9 +1004,7 @@ rm %{buildroot}/%{sysconfdir}/*.test %{_libdir}/%{name}-prefork/mod_vhost_alias.so %{_libdir}/%{name}-prefork/mod_watchdog.so %{_libdir}/%{name}-prefork/mod_xml2enc.so -%endif -%if %{worker} %files worker %defattr(-,root,root) %{_sbindir}/httpd-worker @@ -1150,9 +1131,7 @@ rm %{buildroot}/%{sysconfdir}/*.test %{_libdir}/%{name}-worker/mod_vhost_alias.so %{_libdir}/%{name}-worker/mod_watchdog.so %{_libdir}/%{name}-worker/mod_xml2enc.so -%endif -%if %{event} %files event %defattr(-,root,root) %{_sbindir}/httpd-event @@ -1279,7 +1258,6 @@ rm %{buildroot}/%{sysconfdir}/*.test %{_libdir}/%{name}-event/mod_vhost_alias.so %{_libdir}/%{name}-event/mod_watchdog.so %{_libdir}/%{name}-event/mod_xml2enc.so -%endif %files devel -f filelist-devel %defattr(-,root,root) @@ -1347,94 +1325,69 @@ rm %{buildroot}/%{sysconfdir}/*.test %{_sbindir}/rotatelogs %{_sbindir}/rotatelogs2 -%if %{prefork} -# + +%define install_httpd_link() \ +( \ + # it might happen that apache2 including \ + # %{_datadir}/apache2/script-helpers is not installed \ + # yet even if apache2- has Requires(post): apache2 \ + # because of circular dependency between apache2 \ + # and apache2-MPM \ + if [ -f %{_datadir}/apache2/script-helpers ]; then \ + . %{_datadir}/apache2/script-helpers \ + find_mpm \ + # when this is run in %post(apache2), it may happen \ + # no MPM is installed so far \ + if [ -n "$HTTPD_MPM" ]; then \ + ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE \ + fi \ + fi \ +) %post prefork -# install /usr/sbin/httpd link -if [ -f %{_datadir}/apache2/script-helpers ]; then - # it might happen that apache2 including - # %{_datadir}/apache2/script-helpers is not installed - # yet even if apache2- has Requires(post): apache2 - # because of circular dependency between apache2 - # and apache2-MPM - . %{_datadir}/apache2/script-helpers - find_mpm - ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE -fi +%install_httpd_link exit 0 -# %postun prefork if [ $1 -eq 1 ]; then %apache_request_restart fi +%install_httpd_link exit 0 -# %posttrans prefork %apache_restart_if_needed exit 0 -# -%endif -%if %{worker} %post worker -# install /usr/sbin/httpd link -if [ -f %{_datadir}/apache2/script-helpers ]; then - # it might happen that apache2 including - # %{_datadir}/apache2/script-helpers is not installed - # yet even if apache2- has Requires(post): apache2 - # because of circular dependency between apache2 - # and apache2-MPM - . %{_datadir}/apache2/script-helpers - find_mpm - ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE -fi +%install_httpd_link exit 0 -# %postun worker if [ $1 -eq 1 ]; then %apache_request_restart fi +%install_httpd_link exit 0 -# %posttrans worker %apache_restart_if_needed exit 0 -# -%endif -%if %{event} %post event -# install /usr/sbin/httpd link -if [ -f %{_datadir}/apache2/script-helpers ]; then - # it might happen that apache2 including - # %{_datadir}/apache2/script-helpers is not installed - # yet even if apache2- has Requires(post): apache2 - # because of circular dependency between apache2 - # and apache2-MPM - . %{_datadir}/apache2/script-helpers - find_mpm - ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE -fi +%install_httpd_link exit 0 -# %postun event if [ $1 -eq 1 ]; then %apache_request_restart fi +%install_httpd_link exit 0 -# %posttrans event %apache_restart_if_needed exit 0 -# -%endif %pre %if 0%{?suse_version} >= 1210 @@ -1484,14 +1437,6 @@ fi %else %{fillup_and_insserv apache2} %endif -# install /usr/bin/httpd link (the code here is -# needed when apache2 was installed after apache2-) -. %{_datadir}/apache2/script-helpers -find_mpm -if [ -n "$HTTPD_MPM" ]; then - ln -sf $HTTPD_SBIN_BASE-$HTTPD_MPM $HTTPD_SBIN_BASE -fi -# %if %{use_firewalld} %firewalld_reload %endif