Commit c6476049 authored by Tomas Popela's avatar Tomas Popela

meson: Use apachectl for obtaining the Apache configuration

For running some of the tests we need the Apache's httpd binary. As we want to
know more about its configuration we have to run it and parse the output. But
here is the first problem, because on Debian we can't run the binary unless the
/etc/apache2/envvars file is sourced, otherwise it ends with failure. The
recommended way to communicate with the Apache is the apachectl that passes
the arguments to httpd and also sources the envvars file. In the ideal world
we could use the apachectl to run the tests as well, but on Fedora any non
trivial call to it ends with the following error:
    Passing arguments to httpd using apachectl is no longer supported.

The summary is that for the configuration parsing we will use the apachectl,
but for running the tests we will use the httpd binary.

Closes: #7
parent 0d86b87b
......@@ -43,27 +43,27 @@ def main():
"""Checks whether the required Apache modules are available and prints their
paths to stdout (values are separated by colons).
Only one argument is required - path to the Apache httpd2 executable"""
Only one argument is required - path to the Apache's apachectl executable"""
if len(sys.argv) != 2:
print('Only argument with path to the Apache httpd executable expected!', file=sys.stderr)
print('Only one argument with path to the Apache apachectl executable expected!', file=sys.stderr)
sys.exit(1)
httpd_executable = sys.argv[1]
apachectl_executable = sys.argv[1]
if not os.path.isfile(httpd_executable):
print('The passed Apache httpd executable does not exist!', file=sys.stderr)
if not os.path.isfile(apachectl_executable):
print('The passed Apache apachectl executable does not exist!', file=sys.stderr)
sys.exit(1)
apache_prefix = os.path.dirname(os.path.dirname(httpd_executable))
apache_httpd_output = subprocess.run(
[httpd_executable, '-V', '-C', 'ServerName localhost'], stdout=subprocess.PIPE)
if apache_httpd_output.returncode != 0:
print('Something went wrong when calling Apache httpd executable!', file=sys.stderr)
apache_prefix = os.path.dirname(os.path.dirname(apachectl_executable))
apachectl_output = subprocess.run(
[apachectl_executable, '-V', '-C', 'ServerName localhost'], stdout=subprocess.PIPE)
if apachectl_output.returncode != 0:
print('Something went wrong when calling ' + apachectl_executable + '!', file=sys.stderr)
sys.exit(1)
mpm_regex = re.compile(r'\nServer MPM:[\s]+([\w]+)\n')
mpm = mpm_regex.search(apache_httpd_output.stdout.decode('utf-8')).group(1).lower()
mpm = mpm_regex.search(apachectl_output.stdout.decode('utf-8')).group(1).lower()
apache_modules_dir = ''
apache_ssl_module_dir = ''
......
......@@ -103,15 +103,30 @@ endif
#################################
# Regression tests dependencies #
#################################
# The situation here is a little bit complicated. For running some of the tests
# we need the Apache's httpd binary. As we want to know more about its
# configuration we have to run it and parse the output. But here is the first
# problem, because on Debian we can't run the binary unless the
# /etc/apache2/envvars file is sourced, otherwise it ends with failure. The
# recommended way to communicate with the Apache is the apachectl that passes
# the arguments to httpd and also sources the envvars file. In the ideal world
# we could use the apachectl to run the tests as well, but on Fedora any non
# trivial call to it ends with the following error:
# Passing arguments to httpd using apachectl is no longer supported.
#
# The summary is that for the configuration parsing we will use the apachectl,
# but for running the tests we will use the httpd binary.
apachectl = find_program('apachectl', '/sbin/apachectl', '/usr/sbin/apachectl', required : false)
# This abomination is a result of https://github.com/mesonbuild/meson/issues/1576
apache_httpd2 = find_program('httpd2', 'httpd', 'apache2', 'apache',
'/sbin/httpd2', '/sbin/httpd', '/sbin/apache2', '/sbin/apache',
'/usr/sbin/httpd2', '/usr/sbin/httpd', '/usr/sbin/apache2', '/usr/sbin/apache',
required : false)
'/sbin/httpd2', '/sbin/httpd', '/sbin/apache2', '/sbin/apache',
'/usr/sbin/httpd2', '/usr/sbin/httpd', '/usr/sbin/apache2', '/usr/sbin/apache',
required : false)
have_apache=false
apache_httpd2_version = ''
if apache_httpd2.found()
apache_httpd2_version_raw = run_command(apache_httpd2.path(), '-v')
if apache_httpd2.found() and apachectl.found()
apache_httpd2_version_raw = run_command(apachectl.path(), '-v')
if apache_httpd2_version_raw.returncode() == 0
apache_httpd2_version = apache_httpd2_version_raw.stdout().split('\n')[0]
apache_httpd2_version = apache_httpd2_version.split('/')[1].split(' ')[0]
......@@ -125,7 +140,7 @@ if apache_httpd2.found()
endif
if have_apache
apache_modules_dirs_out = run_command('get_apache_modules_dirs.py', apache_httpd2.path())
apache_modules_dirs_out = run_command('get_apache_modules_dirs.py', apachectl.path())
have_apache = (apache_modules_dirs_out.returncode() == 0)
if have_apache
apache_modules_dirs = apache_modules_dirs_out.stdout().split(':')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment