Accepting request 331901 from Apache

- version 20150918
- -m is no longer required (see apache2-mod_apreq2 for usecase) (forwarded request 331898 from pgajdos)

OBS-URL: https://build.opensuse.org/request/show/331901
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/apache-rpm-macros?expand=0&rev=6
This commit is contained in:
Stephan Kulow 2015-09-19 04:54:32 +00:00 committed by Git OBS Bridge
commit 5220ce11e4
3 changed files with 240 additions and 16 deletions

View File

@ -1,3 +1,44 @@
-------------------------------------------------------------------
Fri Sep 18 08:18:45 UTC 2015 - pgajdos@suse.com
- version 20150918
- -m is no longer required (see apache2-mod_apreq2 for usecase)
-------------------------------------------------------------------
Tue Sep 15 09:13:18 UTC 2015 - pgajdos@suse.com
- version 20150915
- new macro: %apache_access_syntax_version
-------------------------------------------------------------------
Sat Sep 5 07:22:53 UTC 2015 - pgajdos@suse.com
- version 20150904
- new macros: %apache_test_module_curl, %apache_test_module_dir
-------------------------------------------------------------------
Thu Sep 3 08:36:35 UTC 2015 - pgajdos@suse.com
- version 20150903
- %apache_test_module_start_apache:
* better check that httpd is really running
* add -p to mkdir test to not fail if test exist and do not
remove test dir
-------------------------------------------------------------------
Mon Aug 31 08:30:28 UTC 2015 - pgajdos@suse.com
- bump version to 20150902
-------------------------------------------------------------------
Fri Aug 28 08:27:11 UTC 2015 - pgajdos@suse.com
- added macros to test loading modules
%apache_test_module_start_apache
%apache_test_module_stop_apache
%apache_test_module_load
+ macros.apache-module-test
-------------------------------------------------------------------
Tue Jul 28 12:01:08 UTC 2015 - pgajdos@suse.com

View File

@ -20,21 +20,22 @@
%define _libexecdir /usr/lib
%endif
%define ap_major 2
%define ap_branch %(rpm -q --qf "%%{version}" apache%{ap_major} | sed "s:\\(\\..*\\)\\..*:\\1:")
%define ap_pname apache%{ap_major}
%define ap_apxs %(rpm -ql apache%{ap_major}-devel | grep 'apxs[2]\\?$' | head -n 1)
%define ap_cflags %(%{ap_apxs} -q CFLAGS)
%define ap_includedir %(%{ap_apxs} -q INCLUDEDIR)
%define ap_libexecdir %(%{ap_apxs} -q LIBEXECDIR)
%define ap_localstatedir %(%{ap_apxs} -q LOCALSTATEDIR)
%define ap_mmn %(MMN=$(%{ap_apxs} -q LIBEXECDIR)_MMN; test -x $MMN && $MMN)
%define ap_maint_mmn %(MMN=$(rpm -q --provides apache2 | grep suse_maintenance_mmn); test -z "$MMN" && MMN=apache2; echo $MMN)
%define ap_serverroot %(%{ap_apxs} -q PREFIX)
%define ap_sysconfdir %(%{ap_apxs} -q SYSCONFDIR)
%define ap_datadir %(%{ap_apxs} -q DATADIR)
%define ap_user wwwrun
%define ap_group www
%define ap_major 2
%define ap_branch %(rpm -q --qf "%%{version}" apache%{ap_major} | sed "s:\\(\\..*\\)\\..*:\\1:")
%define ap_pname apache%{ap_major}
%define ap_apxs %(rpm -ql apache%{ap_major}-devel | grep 'apxs[2]\\?$' | head -n 1)
%define ap_cflags %(%{ap_apxs} -q CFLAGS)
%define ap_includedir %(%{ap_apxs} -q INCLUDEDIR)
%define ap_libexecdir %(%{ap_apxs} -q LIBEXECDIR)
%define ap_localstatedir %(%{ap_apxs} -q LOCALSTATEDIR)
%define ap_mmn %(MMN=$(%{ap_apxs} -q LIBEXECDIR)_MMN; test -x $MMN && $MMN)
%define ap_maint_mmn %(MMN=$(rpm -q --provides apache2 | grep suse_maintenance_mmn); test -z "$MMN" && MMN=apache2; echo $MMN)
%define ap_serverroot %(%{ap_apxs} -q PREFIX)
%define ap_sysconfdir %(%{ap_apxs} -q SYSCONFDIR)
%define ap_datadir %(%{ap_apxs} -q DATADIR)
%define ap_user wwwrun
%define ap_group www
%define ap_access_syntax_version %(if [ $(grep -c '^[[:space:]]*Require all denied' /etc/apache2/httpd.conf) -gt 0 ]; then echo 24; else echo 22; fi)
#
%if 0%{?suse_version} > 1230
%define macros_dir %{_libexecdir}/rpm/macros.d
@ -43,12 +44,13 @@
%endif
%define macros_file macros.apache
Name: apache-rpm-macros
Version: 20150717
Version: 20150918
Release: 0
Summary: Apache RPM Macros
License: Apache-2.0
Group: Productivity/Networking/Web/Servers
Url: http://httpd.apache.org/
Source1: macros.apache-module-test
BuildRequires: apache%{ap_major}-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -74,7 +76,10 @@ cat << eom > %{macros_file}
%%apache_datadir %{ap_datadir}
%%apache_user %{ap_user}
%%apache_group %{ap_group}
%%apache_access_syntax_version %{ap_access_syntax_version}
eom
echo >> %{macros_file}
cat %{SOURCE1} >> %{macros_file}
%install
mkdir -p %{buildroot}%{macros_dir}

178
macros.apache-module-test Normal file
View File

@ -0,0 +1,178 @@
%__test_dir /tmp/%{name}-test
%__test_mpm prefork
%__test_user abuild
%__test_group abuild
%__test_port 60080
# world writeable dir for testing purposes (logs, document root, ..)
%apache_test_module_dir %{__test_dir}
#
# macro: apache_test_module_start_apache -- start apache with specified modules loaded
#
# usage: apache_test_module_start_apache -m module_list [-i include_list] [-r document_root]
#
# module_list: colon separated list of module names to be loaded with test run
# search path: %{buildroot} tree
# %{apache_libexecdir}-prefork
# %{apache_libexecdir}
# [example value: asn:dbd]
# include_list: colon separated list of names of apache configuration files
# to be included; can be either existing path or just name
# of the configuration file,which will be searched under:
# %{buildroot}%{apache_sysconfdir} tree
# $PWD tree
# %{apache_test_module_dir}
# [example value: mod_asn.conf]
# document_root: document root of the test server,
# [default value: $PWD/test/htdocs]
#
#
%apache_test_module_start_apache(m:,i:,r:) \
# constants \
TEST_DIR='%{__test_dir}' \
TEST_MPM='%{__test_mpm}' \
TEST_USER='%{__test_user}' \
TEST_GROUP='%{__test_group}' \
TEST_PORT='%{__test_port}' \
# arguments \
# modules to load, from BUILD tree or system \
MODULES=$(echo %{-m:%{-m*}} | tr ':' ' ') \
# configs to include \
CONFIGS="%{-i:%{-i*}}" \
# document root of the test server \
DOCUMENT_ROOT="%{-r:%{-r*}}" \
if [ -z "$DOCUMENT_ROOT" ]; then \
DOCUMENT_ROOT=$TEST_DIR/htdocs \
fi \
# helpers \
APACHE_BRANCH=$(echo %{apache_branch} | tr -d '.') \
# begin \
echo "-----------------------------------------------------------" \
echo "APACHE MODULE TEST" \
echo \
echo "modules to load: $MODULES" \
echo "configs to include: $CONFIGS" \
# create test dir \
mkdir -p $TEST_DIR \
# create document root if not exist \
mkdir -p $DOCUMENT_ROOT \
# create test/httpd-test.conf \
TEST_CONF_FILE="$TEST_DIR/httpd.conf" \
SYSTEM_MODULE_PATH="%{apache_libexecdir}-$TEST_MPM" \
echo "ServerName test" > $TEST_CONF_FILE \
echo "User $TEST_USER" >> $TEST_CONF_FILE \
echo "Group $TEST_GROUP" >> $TEST_CONF_FILE \
echo "Listen $TEST_PORT" >> $TEST_CONF_FILE \
echo "PidFile $TEST_DIR/pid" >> $TEST_CONF_FILE \
echo "ErrorLog $TEST_DIR/error_log" >> $TEST_CONF_FILE \
echo "LoadModule dir_module $SYSTEM_MODULE_PATH/mod_dir.so" >> $TEST_CONF_FILE \
echo "LoadModule auth_basic_module $SYSTEM_MODULE_PATH/mod_auth_basic.so" >> $TEST_CONF_FILE \
if [ $APACHE_BRANCH -ge 24 ]; then \
echo "LoadModule authz_core_module $SYSTEM_MODULE_PATH/mod_authz_core.so" >> $TEST_CONF_FILE \
fi \
echo "LoadModule authz_host_module $SYSTEM_MODULE_PATH/mod_authz_host.so" >> $TEST_CONF_FILE \
for m in $(echo $MODULES | tr ':' ' '); do \
module_path=$(find %{buildroot} %{apache_libexecdir}-$TEST_MPM %{apache_libexecdir} -name "mod_$m.so" | tail -n 1) \
if [ -z "$module_path" ]; then \
echo "ERROR: Module $m not found." \
exit 1 \
fi \
echo "Will load ${m}_module $module_path" \
echo "LoadModule ${m}_module $module_path" >> $TEST_CONF_FILE \
done \
for c in $(echo $CONFIGS | tr ':' ' '); do \
if [ -f $c ]; then \
if [[ ! "$c" = /* ]]; then \
c="$PWD/$c" \
fi \
include_path="$c" \
else \
include_path=$(find %{buildroot}%{apache_sysconfdir} %{apache_test_module_dir} $PWD -name "$c" 2>/dev/null | tail -n 1) \
fi \
if [ -z "$include_path" ]; then \
echo "ERROR: Config file $c not found." \
exit 1 \
fi \
echo "Will include $include_path" \
echo "Include $include_path" >> $TEST_CONF_FILE \
done \
echo "DocumentRoot $DOCUMENT_ROOT" >> $TEST_CONF_FILE \
echo "DirectoryIndex index.html" >> $TEST_CONF_FILE \
echo "<Directory $DOCUMENT_ROOT>" >> $TEST_CONF_FILE \
if [ $APACHE_BRANCH -ge 24 ]; then \
echo " Require local" >> $TEST_CONF_FILE \
else \
echo " Order deny,allow" >> $TEST_CONF_FILE \
echo " Deny from all" >> $TEST_CONF_FILE \
echo " Allow from localhost" >> $TEST_CONF_FILE \
fi \
echo "</Directory>" >> $TEST_CONF_FILE \
# run apache \
CMD=$(ls %{_sbindir}/httpd*-$TEST_MPM | head -n 1) \
echo -n "Starting Apache ... " \
$CMD -f $TEST_CONF_FILE -k start \
# wait to be sure apache finished start \
sleep 2 \
if [ ! -f $TEST_DIR/pid ]; then \
echo "FAILED:" \
cat $TEST_DIR/error_log \
echo "See $PWD/$TEST_DIR for details" \
exit 1 \
fi \
echo "SUCCESS" \
%nil
#
# macro: apache_test_module_stop_apache -- stops apache previously started with *_start_apache
#
# usage: apache_test_module_stop_apache
#
%apache_test_module_stop_apache() \
TEST_DIR='%{__test_dir}' \
# stop apache \
echo "Stopping Apache ..." \
kill -TERM `cat $TEST_DIR/pid` \
echo "Done." \
echo "-----------------------------------------------------------" \
%nil
#
# macro: apache_test_module_curl -- outputs curl on particular document relative to
# document root of test instance
#
# usage: apache_test_module_curl -d document_to_curl -o output_of_curl
# example: apache_test_module_curl -d foo/test.html -o test.html
# apache_test_module_curl -d foo/ -o output.txt
#
%apache_test_module_curl(d:,o:) \
TEST_DOCUMENT="%{-d:%{-d*}}" \
TEST_OUTPUT="%{-o:%{-o*}}" \
if [ -z "$TEST_OUTPUT" ]; then \
echo "Missing argument -o to apache_test_module_curl." \
exit 1 \
fi \
curl -s "http://localhost:%{__test_port}/$TEST_DOCUMENT" --create-dirs -o "$TEST_OUTPUT" \
%nil
#
# macro: apache_test_module_load -- tests that module(s) can be loaded
#
# usage: apache_test_module_load -m module_list [-i include_list]
#
# module_list: colon separated list of module names to be loaded with test run
# search path: %{buildroot} tree
# %{apache_libexecdir}-prefork
# %{apache_libexecdir}
# [example value: asn:dbd]
# include_list: colon separated list of names of apache configuration files
# to be included (path relative to current dir)
# search path %{buildroot}%{apache_sysconfdir} tree
# $PWD tree
# [example value: mod_asn.conf]
#
%apache_test_module_load(m:,i:) \
%apache_test_module_start_apache %{-m:-m %{-m*}} %{-i:-i %{-i*}} \
%apache_test_module_stop_apache \
%nil