about summary refs log tree commit diff
path: root/unicorn_mode
diff options
context:
space:
mode:
Diffstat (limited to 'unicorn_mode')
-rw-r--r--unicorn_mode/UNICORNAFL_VERSION1
-rwxr-xr-x[-rw-r--r--]unicorn_mode/build_unicorn_support.sh43
m---------unicorn_mode/unicornafl0
-rwxr-xr-xunicorn_mode/update_uc_ref.sh25
4 files changed, 54 insertions, 15 deletions
diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION
new file mode 100644
index 00000000..0afcf291
--- /dev/null
+++ b/unicorn_mode/UNICORNAFL_VERSION
@@ -0,0 +1 @@
+25ae270
diff --git a/unicorn_mode/build_unicorn_support.sh b/unicorn_mode/build_unicorn_support.sh
index df2a7f6d..1e5b3ef4 100644..100755
--- a/unicorn_mode/build_unicorn_support.sh
+++ b/unicorn_mode/build_unicorn_support.sh
@@ -33,6 +33,8 @@
 # You must make sure that Unicorn Engine is not already installed before
 # running this script. If it is, please uninstall it first.
 
+UNICORNAFL_VERSION="$(cat ./UNICORNAFL_VERSION)"
+
 echo "================================================="
 echo "UnicornAFL build script"
 echo "================================================="
@@ -105,7 +107,7 @@ for i in $PYTHONBIN automake autoconf git $MAKECMD $TARCMD; do
 
 done
 
-if ! type $EASY_INSTALL > /dev/null; then
+if ! command -v $EASY_INSTALL >/dev/null; then
 
   # work around for installs with executable easy_install
   EASY_INSTALL_FOUND=0
@@ -121,7 +123,7 @@ if ! type $EASY_INSTALL > /dev/null; then
 
     fi
   done
-  if [ '!' $EASY_INSTALL_FOUND ]; then
+  if [ "0" = $EASY_INSTALL_FOUND ]; then
 
     echo "[-] Error: Python setup-tools not found. Run 'sudo apt-get install python-setuptools'."
     PREREQ_NOTFOUND=1
@@ -144,26 +146,37 @@ fi
 echo "[+] All checks passed!"
 
 echo "[*] Making sure unicornafl is checked out"
-rm -rf unicornafl # workaround for travis ... sadly ...
-#test -d unicorn && { cd unicorn && { git stash ; git pull ; cd .. ; } }
-test -d unicornafl || {
-   CNT=1
-   while [ '!' -d unicornafl -a "$CNT" -lt 4 ]; do
-     echo "Trying to clone unicornafl (attempt $CNT/3)"
-     git clone https://github.com/AFLplusplus/unicornafl
-     CNT=`expr "$CNT" + 1`
-   done
-}
+
+git status 1>/dev/null 2>/dev/null
+if [ $? -eq 0 ]; then
+  echo "[*] initializing unicornafl submodule"
+  git submodule init || exit 1
+  git submodule update 2>/dev/null # ignore errors
+else
+  echo "[*] cloning unicornafl"
+  test -d unicornafl || {
+    CNT=1
+    while [ '!' -d unicornafl -a "$CNT" -lt 4 ]; do
+      echo "Trying to clone unicornafl (attempt $CNT/3)"
+      git clone https://github.com/AFLplusplus/unicornafl
+      CNT=`expr "$CNT" + 1`
+    done
+  }
+fi
+
 test -d unicornafl || { echo "[-] not checked out, please install git or check your internet connection." ; exit 1 ; }
 echo "[+] Got unicornafl."
 
+cd "unicornafl" || exit 1
+echo "[*] Checking out $UNICORNAFL_VERSION"
+sh -c 'git stash && git stash drop' 1>/dev/null 2>/dev/null
+git checkout "$UNICORNAFL_VERSION" || exit 1
+
 echo "[*] making sure config.h matches"
-cp "../config.h" "./unicornafl/" || exit 1
+cp "../../config.h" "." || exit 1
 
 echo "[*] Configuring Unicorn build..."
 
-cd "unicornafl" || exit 1
-
 echo "[+] Configuration complete."
 
 echo "[*] Attempting to build unicornafl (fingers crossed!)..."
diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl
new file mode 160000
+Subproject 25ae270c1b949a5d1c2c5460b778f0a35bfe67d
diff --git a/unicorn_mode/update_uc_ref.sh b/unicorn_mode/update_uc_ref.sh
new file mode 100755
index 00000000..d198fa2a
--- /dev/null
+++ b/unicorn_mode/update_uc_ref.sh
@@ -0,0 +1,25 @@
+#/bin/sh
+
+UC_VERSION_FILE='./UNICORNAFL_VERSION'
+
+NEW_VERSION="$1"
+if [ -z "$NEW_VERSION" ]; then
+  echo "Internal script to update bound unicornafl version."
+  echo
+  echo "Usage: ./update_uc_ref.sh <new commit hash>"
+  exit 1
+fi
+
+git submodule init && git submodule update || exit 1
+cd ./unicornafl
+git fetch origin master 1>/dev/null || exit 1
+git stash 1>/dev/null 2>/dev/null
+git stash drop 1>/dev/null 2>/dev/null
+git checkout "$NEW_VERSION" || exit 1
+
+cd ..
+
+rm "$UC_VERSION_FILE"
+echo "$NEW_VERSION" > "$UC_VERSION_FILE"
+
+echo "Done. New unicornafl version is $NEW_VERSION."