From a69afd5cf97dba77811642e9b86f8ccba628b61c Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Sat, 9 Mar 2019 09:00:59 -0600 Subject: [PATCH] autoconf/python: check for distutils Require distutils to install the Python tools. Update the logic to only install suricatactl (and suricatasc) if Python and distutils are found. Suricata-Update will only be installed if bundled, and python-distutils and python-yaml are found. --- configure.ac | 51 ++++++++++++++++++++++++++++++++++--- python/Makefile.am | 2 ++ suricata-update/Makefile.am | 2 ++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 34c79cb91d..45380ffbb7 100644 --- a/configure.ac +++ b/configure.ac @@ -108,6 +108,28 @@ fi AM_CONDITIONAL([HAVE_PYTHON], [test "x$enable_python" = "xyes"]) + # Check for python-distutils (setup). + have_python_distutils="no" + if test "x$enable_python" = "xyes"; then + AC_MSG_CHECKING([for python-distutils]) + if $HAVE_PYTHON -c "import distutils; from distutils.core import setup" 2>/dev/null; then + AC_MSG_RESULT([yes]) + have_python_distutils="yes" + else + AC_MSG_RESULT([no]) + fi + fi + AM_CONDITIONAL([HAVE_PYTHON_DISTUTILS], + [test "x$have_python_distutils" = "xyes"]) + if test "$have_python_distutils" = "no"; then + echo "" + echo " Warning: Python distutils not found. Python tools will" + echo " not be installed." + echo "" + echo " Ubuntu/Debian: apt install `basename ${HAVE_PYTHON}`-distutils" + echo "" + fi + # Check for python-yaml. have_python_yaml="no" if test "x$enable_python" = "xyes"; then @@ -1518,7 +1540,6 @@ AM_CONDITIONAL([HAVE_SURICATA_UPDATE], [test "x$have_suricata_update" != "xno"]) - install_suricata_update="no" if test "$have_suricata_update" = "yes"; then if test "$have_python_yaml" != "yes"; then echo "" @@ -1530,7 +1551,6 @@ echo " CentOS/RHEL: yum install python-yaml" echo "" else - install_suricata_update="yes" SURICATA_UPDATE_DIR="suricata-update" AC_SUBST(SURICATA_UPDATE_DIR) AC_OUTPUT(suricata-update/Makefile) @@ -1540,6 +1560,28 @@ fi fi + # Test to see if suricatactl (and suricatasc) can be installed. + if test "x$enable_python" != "xyes"; then + install_suricatactl="requires python" + elif test "x$have_python_distutils" != "xyes"; then + install_suricatactl="requires distutils" + else + install_suricatactl="yes" + fi + + # Test to see if suricata-update can be installed. + if test "x$have_suricata_update" != "xyes"; then + install_suricata_update="not bundled" + elif test "x$enable_python" != "xyes"; then + install_suricata_update="requires python" + elif test "x$have_python_distutils" != "xyes"; then + install_suricata_update="requires distutils" + elif test "x$have_python_yaml" != "xyes"; then + install_suricata_update="requires pyyaml" + else + install_suricata_update="yes" + fi + # libhtp AC_ARG_ENABLE(non-bundled-htp, AS_HELP_STRING([--enable-non-bundled-htp], [Enable the use of an already installed version of htp]),[enable_non_bundled_htp=$enableval],[enable_non_bundled_htp=no]) @@ -2546,7 +2588,10 @@ SURICATA_BUILD_CONF="Suricata Configuration: Python support: ${enable_python} Python path: ${python_path} Python version: ${python_version} - Install suricatasc: ${enable_python} + Python distutils ${have_python_distutils} + Python yaml ${have_python_yaml} + Install suricatactl: ${install_suricatactl} + Install suricatasc: ${install_suricatactl} Install suricata-update: ${install_suricata_update} Profiling enabled: ${enable_profiling} diff --git a/python/Makefile.am b/python/Makefile.am index 59d195f290..7188318784 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -4,6 +4,7 @@ EXTRA_DIST = setup.py \ suricatasc if HAVE_PYTHON +if HAVE_PYTHON_DISTUTILS all-local: cd $(srcdir) && \ $(HAVE_PYTHON) setup.py build --build-base $(abs_builddir) @@ -30,3 +31,4 @@ clean-local: distclean-local: rm -f version endif +endif diff --git a/suricata-update/Makefile.am b/suricata-update/Makefile.am index 896cfad564..fedf5647f3 100644 --- a/suricata-update/Makefile.am +++ b/suricata-update/Makefile.am @@ -1,4 +1,5 @@ if HAVE_PYTHON +if HAVE_PYTHON_DISTUTILS if HAVE_PYTHON_YAML install-exec-local: @@ -22,3 +23,4 @@ distclean-local: endif endif +endif