about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRuben ten Hove <git@rhtenhove.nl>2020-05-14 16:56:40 +0200
committerDominik Maier <domenukk@gmail.com>2020-05-14 21:49:36 +0200
commit867f948bb22688bc2ca250f3cc28402662cc1b0c (patch)
tree4bb34c5bcf1d5822dedf15e0f59509ee4a8b3dda
parent767ed8c5da985601dbd956cd3776abfa3a86cff8 (diff)
downloadafl++-867f948bb22688bc2ca250f3cc28402662cc1b0c.tar.gz
create temp symlink to python3 for qemu mode if python isn't found
-rw-r--r--CONTRIBUTING.md5
-rw-r--r--GNUmakefile2
-rwxr-xr-xqemu_mode/build_qemu_support.sh20
3 files changed, 25 insertions, 2 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 90049432..bd0a0ed8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -20,3 +20,8 @@ No camel case at all and use the AFL's macros wherever possible
 Remember that AFLplusplus has to build and run on many platforms, so
 generalize your Makefiles (or your patches to our pre-existing Makefiles)
 to be as much generic as possible.
+
+
+# Local testing
+
+To try
diff --git a/GNUmakefile b/GNUmakefile
index fd43e11a..8bdd642e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -105,7 +105,7 @@ ifneq "$(shell command -v python3m 2>/dev/null)" ""
   ifneq "$(shell command -v python3m-config 2>/dev/null)" ""
     PYTHON_INCLUDE  ?= $(shell python3m-config --includes)
     PYTHON_VERSION  ?= $(strip $(shell python3m --version 2>&1))
-    # Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
+    # Starting with python3.8, we need to pass the `embed` flag. Earlier versions didn't know this flag.
     ifeq "$(shell python3m-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
       PYTHON_LIB      ?= $(shell python3m-config --libs --embed --ldflags)
     else
diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh
index bd18927f..983373ce 100755
--- a/qemu_mode/build_qemu_support.sh
+++ b/qemu_mode/build_qemu_support.sh
@@ -63,7 +63,7 @@ if [ ! -f "../afl-showmap" ]; then
 fi
 
 PREREQ_NOTFOUND=
-for i in libtool wget python automake autoconf sha384sum bison flex iconv patch pkg-config; do
+for i in libtool wget automake autoconf sha384sum bison flex iconv patch pkg-config; do
 
   T=`command -v "$i" 2>/dev/null`
 
@@ -76,6 +76,18 @@ for i in libtool wget python automake autoconf sha384sum bison flex iconv patch
 
 done
 
+PYTHON_TEMP_SYMLINK=0
+if ! command -v python 1>/dev/null; then
+  if command -v python3 1>/dev/null; then
+    echo "[*] 'python' not found. 'python3' was found. Creating temporary symlink."
+    update-alternatives --install /usr/bin/python python "$(command -v python3)" 0 1>/dev/null
+    PYTHON_TEMP_SYMLINK=1
+  else
+    echo "[-] Error: 'python' not found, please install using 'sudo apt install python3'."
+    PREREQ_NOTFOUND=1
+  fi
+fi
+
 if [ ! -d "/usr/include/glib-2.0/" -a ! -d "/usr/local/include/glib-2.0/" ]; then
 
   echo "[-] Error: devel version of 'glib2' not found, please install first."
@@ -279,6 +291,12 @@ echo "[+] Building libcompcov ..."
 make -C libcompcov && echo "[+] libcompcov ready"
 echo "[+] Building unsigaction ..."
 make -C unsigaction && echo "[+] unsigaction ready"
+
+if [ "PYTHON_TEMP_SYMLINK" = "1" ]; then
+  echo "[*] Removing temporary symlink for 'python'"
+  update-alternatives --remove python /usr/bin/python
+fi
+
 echo "[+] All done for qemu_mode, enjoy!"
 
 exit 0