From 47c5fbefab7000eff07ee7f4003af54b716e21b41cc9bef61054bcf720d37bca Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Fri, 25 Sep 2015 14:10:14 +0000 Subject: [PATCH 1/2] Accepting request 333772 from home:pgajdos:apache2 - version 20150921 - make package usable also for other rpm based distros - %apache_test_module_start_apache: introduce -p, -u and -g options - %apache_test_module_curl: introduce -p and -u option OBS-URL: https://build.opensuse.org/request/show/333772 OBS-URL: https://build.opensuse.org/package/show/Apache/apache-rpm-macros?expand=0&rev=20 --- apache-rpm-macros.changes | 8 ++++++ apache-rpm-macros.spec | 21 +++++++++++++-- macros.apache-module-test | 55 ++++++++++++++++++++++++++++++++------- 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/apache-rpm-macros.changes b/apache-rpm-macros.changes index 8853cdb..fb45cb7 100644 --- a/apache-rpm-macros.changes +++ b/apache-rpm-macros.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Sep 22 07:16:24 UTC 2015 - pgajdos@suse.com + +- version 20150921 +- make package usable also for other rpm based distros +- %apache_test_module_start_apache: introduce -p, -u and -g options +- %apache_test_module_curl: introduce -p and -u option + ------------------------------------------------------------------- Fri Sep 18 08:18:45 UTC 2015 - pgajdos@suse.com diff --git a/apache-rpm-macros.spec b/apache-rpm-macros.spec index a293dfc..ee5a04a 100644 --- a/apache-rpm-macros.spec +++ b/apache-rpm-macros.spec @@ -21,21 +21,34 @@ %endif %define ap_major 2 +%if 0%{?suse_version} %define ap_branch %(rpm -q --qf "%%{version}" apache%{ap_major} | sed "s:\\(\\..*\\)\\..*:\\1:") +%else +%define ap_branch %(rpm -q --qf "%%{version}" httpd | sed "s:\\(\\..*\\)\\..*:\\1:") +%endif %define ap_pname apache%{ap_major} -%define ap_apxs %(rpm -ql apache%{ap_major}-devel | grep 'apxs[2]\\?$' | head -n 1) +%define ap_apxs %(ls -1 /usr/{,s}bin/apxs{,2} 2>/dev/null | 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) +%if 0%{?suse_version} %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) +%endif %define ap_serverroot %(%{ap_apxs} -q PREFIX) %define ap_sysconfdir %(%{ap_apxs} -q SYSCONFDIR) %define ap_datadir %(%{ap_apxs} -q DATADIR) +%if 0%{?suse_version} %define ap_user wwwrun %define ap_group www +%else +%define ap_user apache +%define ap_group apache +%endif +%if 0%{?suse_version} %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) +%endif # %if 0%{?suse_version} > 1230 %define macros_dir %{_libexecdir}/rpm/macros.d @@ -44,14 +57,18 @@ %endif %define macros_file macros.apache Name: apache-rpm-macros -Version: 20150918 +Version: 20150921 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 +%if 0%{?suse_version} BuildRequires: apache%{ap_major}-devel +%else +BuildRequires: httpd-devel +%endif BuildRoot: %{_tmppath}/%{name}-%{version}-build %description diff --git a/macros.apache-module-test b/macros.apache-module-test index a9f9349..3cdf1de 100644 --- a/macros.apache-module-test +++ b/macros.apache-module-test @@ -10,7 +10,8 @@ # # 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] +# usage: apache_test_module_start_apache -m module_list [-i include_list] [-r document_root] +# [-u user] [-g group] [-p port] # # module_list: colon separated list of module names to be loaded with test run # search path: %{buildroot} tree @@ -25,16 +26,21 @@ # %{apache_test_module_dir} # [example value: mod_asn.conf] # document_root: document root of the test server, -# [default value: $PWD/test/htdocs] +# [default value: /tmp/%%{name}-test/htdocs] +# user: user under which will run test instance (usable only +# when the test is run by root) +# [default value: abuild] +# group: group under which will run test instance (usable only +# when the test is run by root) +# [default value: abuild] +# port: listen on port +# [default value: 60080] # # -%apache_test_module_start_apache(m:,i:,r:) \ +%apache_test_module_start_apache(m:,i:,r:,u:,g:) \ # 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 ':' ' ') \ @@ -45,6 +51,20 @@ if [ -z "$DOCUMENT_ROOT" ]; then \ DOCUMENT_ROOT=$TEST_DIR/htdocs \ fi \ + # user and group running the apache instance \ + # (usable only when the test is run as root) \ + TEST_USER="%{-u:%{-u*}}" \ + if [ -z "$TEST_USER" ]; then \ + TEST_USER='%{__test_user}' \ + fi \ + TEST_GROUP="%{-g:%{-g*}}" \ + if [ -z "$TEST_GROUP" ]; then \ + TEST_GROUP='%{__test_group}' \ + fi \ + TEST_PORT="%{-p:%{-p*}}" \ + if [ -z "$TEST_PORT" ]; then \ + TEST_PORT='%{__test_port}' \ + fi \ # helpers \ APACHE_BRANCH=$(echo %{apache_branch} | tr -d '.') \ # begin \ @@ -141,18 +161,35 @@ # 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 +# usage: apache_test_module_curl -d document_to_curl -o output_of_curl +# -p port -u user:password +# +# document_to_curl: relative to DocumentRoot [default: /] +# output_of_curl: where to save document (required) +# port: from which port of localhost will be document +# downloaded [default value: 60080] +# user:password: --user parameter 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:) \ +%apache_test_module_curl(d:,o:,p:,u:) \ TEST_DOCUMENT="%{-d:%{-d*}}" \ TEST_OUTPUT="%{-o:%{-o*}}" \ + TEST_PORT="%{-p:%{-p*}}" \ + TEST_CURL_USER="%{-u:%{-u*}}" \ + if [ -z "$TEST_PORT" ]; then \ + TEST_PORT='%{__test_port}' \ + fi \ 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" \ + USER_PARAM="" \ + if [ ! -z "$TEST_CURL_USER" ]; then \ + USER_PARAM="-u $TEST_CURL_USER" \ + fi \ + curl -s "http://localhost:$TEST_PORT/$TEST_DOCUMENT" --create-dirs -o "$TEST_OUTPUT" $USER_PARAM \ %nil # From 348ddeb8925cd096683e4e1bc61819e71fd3a0b94a6981c6d613fd0dad65cf05 Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Fri, 2 Oct 2015 20:13:35 +0000 Subject: [PATCH 2/2] Accepting request 335993 from home:pgajdos:apache2 - version 20150930 - %apache_test_module_start_apache, %apache_test_module_load: introduce -t option - %apache_test_module_curl: introduce -r option OBS-URL: https://build.opensuse.org/request/show/335993 OBS-URL: https://build.opensuse.org/package/show/Apache/apache-rpm-macros?expand=0&rev=21 --- apache-rpm-macros.changes | 8 ++++++++ apache-rpm-macros.spec | 2 +- macros.apache-module-test | 42 +++++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/apache-rpm-macros.changes b/apache-rpm-macros.changes index fb45cb7..ccacc82 100644 --- a/apache-rpm-macros.changes +++ b/apache-rpm-macros.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Sep 30 17:14:29 UTC 2015 - pgajdos@suse.com + +- version 20150930 +- %apache_test_module_start_apache, %apache_test_module_load: + introduce -t option +- %apache_test_module_curl: introduce -r option + ------------------------------------------------------------------- Tue Sep 22 07:16:24 UTC 2015 - pgajdos@suse.com diff --git a/apache-rpm-macros.spec b/apache-rpm-macros.spec index ee5a04a..27e4f55 100644 --- a/apache-rpm-macros.spec +++ b/apache-rpm-macros.spec @@ -57,7 +57,7 @@ %endif %define macros_file macros.apache Name: apache-rpm-macros -Version: 20150921 +Version: 20150930 Release: 0 Summary: Apache RPM Macros License: Apache-2.0 diff --git a/macros.apache-module-test b/macros.apache-module-test index 3cdf1de..350285f 100644 --- a/macros.apache-module-test +++ b/macros.apache-module-test @@ -10,8 +10,8 @@ # # 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] -# [-u user] [-g group] [-p port] +# usage: apache_test_module_start_apache [-m module_list] [-i include_list] [-r document_root] +# [-u user] [-g group] [-p port] [-t mpm] # # module_list: colon separated list of module names to be loaded with test run # search path: %{buildroot} tree @@ -35,12 +35,13 @@ # [default value: abuild] # port: listen on port # [default value: 60080] +# mpm: multiprocessing module (prefork, worker, event) +# [default value: prefork] # # -%apache_test_module_start_apache(m:,i:,r:,u:,g:) \ +%apache_test_module_start_apache(m:,i:,r:,u:,g:,t:) \ # constants \ TEST_DIR='%{__test_dir}' \ - TEST_MPM='%{__test_mpm}' \ # arguments \ # modules to load, from BUILD tree or system \ MODULES=$(echo %{-m:%{-m*}} | tr ':' ' ') \ @@ -65,6 +66,10 @@ if [ -z "$TEST_PORT" ]; then \ TEST_PORT='%{__test_port}' \ fi \ + TEST_MPM="%{-t:%{-t*}}" \ + if [ -z "$TEST_MPM" ]; then \ + TEST_MPM='%{__test_mpm}' \ + fi \ # helpers \ APACHE_BRANCH=$(echo %{apache_branch} | tr -d '.') \ # begin \ @@ -119,15 +124,6 @@ done \ echo "DocumentRoot $DOCUMENT_ROOT" >> $TEST_CONF_FILE \ echo "DirectoryIndex index.html" >> $TEST_CONF_FILE \ - echo "" >> $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 "" >> $TEST_CONF_FILE \ # run apache \ CMD=$(ls %{_sbindir}/httpd*-$TEST_MPM | head -n 1) \ echo -n "Starting Apache ... " \ @@ -162,22 +158,25 @@ # document root of test instance # # usage: apache_test_module_curl -d document_to_curl -o output_of_curl -# -p port -u user:password +# -p port -u user:password -r protocol # # document_to_curl: relative to DocumentRoot [default: /] # output_of_curl: where to save document (required) # port: from which port of localhost will be document # downloaded [default value: 60080] # user:password: --user parameter of curl +# protocol: protocol to download document +# [default: http] # # 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:,p:,u:) \ +%apache_test_module_curl(d:,o:,p:,u:,r:) \ TEST_DOCUMENT="%{-d:%{-d*}}" \ TEST_OUTPUT="%{-o:%{-o*}}" \ TEST_PORT="%{-p:%{-p*}}" \ TEST_CURL_USER="%{-u:%{-u*}}" \ + TEST_PROTO="%{-r:%{-r*}}" \ if [ -z "$TEST_PORT" ]; then \ TEST_PORT='%{__test_port}' \ fi \ @@ -189,13 +188,16 @@ if [ ! -z "$TEST_CURL_USER" ]; then \ USER_PARAM="-u $TEST_CURL_USER" \ fi \ - curl -s "http://localhost:$TEST_PORT/$TEST_DOCUMENT" --create-dirs -o "$TEST_OUTPUT" $USER_PARAM \ + if [ -z "$TEST_PROTO" ]; then \ + TEST_PROTO="http" \ + fi \ + curl -s -k "$TEST_PROTO://127.0.0.1:$TEST_PORT/$TEST_DOCUMENT" --create-dirs -o "$TEST_OUTPUT" $USER_PARAM \ %nil # # macro: apache_test_module_load -- tests that module(s) can be loaded # -# usage: apache_test_module_load -m module_list [-i include_list] +# usage: apache_test_module_load [-m module_list] [-i include_list] [-t mpm] # # module_list: colon separated list of module names to be loaded with test run # search path: %{buildroot} tree @@ -207,9 +209,11 @@ # search path %{buildroot}%{apache_sysconfdir} tree # $PWD tree # [example value: mod_asn.conf] +# mpm: multiprocessing module (prefork, worker, event) +# [default value: prefork] # -%apache_test_module_load(m:,i:) \ - %apache_test_module_start_apache %{-m:-m %{-m*}} %{-i:-i %{-i*}} \ +%apache_test_module_load(m:,i:,t:) \ + %apache_test_module_start_apache %{-m:-m %{-m*}} %{-i:-i %{-i*}} %{-t:-t %{-t*}} \ %apache_test_module_stop_apache \ %nil