]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
autoconf/python: check for distutils 3714/head
authorJason Ish <ish@unx.ca>
Sat, 9 Mar 2019 15:00:59 +0000 (09:00 -0600)
committerJason Ish <ish@unx.ca>
Sat, 9 Mar 2019 15:00:59 +0000 (09:00 -0600)
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
python/Makefile.am
suricata-update/Makefile.am

index 34c79cb91d9d58d876f86c958e3c3431134c8f9f..45380ffbb706fba5fc2cf58b184b3a57378d237f 100644 (file)
     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
     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 ""
            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)
        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}
index 59d195f290d919ced7b050703c80d2bb6a576ccd..71883187845cf5af7708c54b17bd2c59f120e5b7 100644 (file)
@@ -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
index 896cfad564b555cb8c1dee7c5ccfe4d71743afd7..fedf5647f315230e5982ecd5a4bcc32464f605b0 100644 (file)
@@ -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