about summary refs log tree commit diff
path: root/qemu_mode/update_ref.sh
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-11-06 09:37:14 +0100
committerGitHub <noreply@github.com>2020-11-06 09:37:14 +0100
commit3b799c09cd68bb68b26784261f1fbaa3e737c747 (patch)
treee581c3689d5fe231678464bb6bd48cab75c7db41 /qemu_mode/update_ref.sh
parent5ee63a6e6267e448342ccb28cc8d3c0d34ffc1cd (diff)
parent50c98445fe74b92d2e6ab784def3e8b26a662b36 (diff)
downloadafl++-3b799c09cd68bb68b26784261f1fbaa3e737c747.tar.gz
Merge pull request #594 from AFLplusplus/dev
push to stable
Diffstat (limited to 'qemu_mode/update_ref.sh')
-rwxr-xr-xqemu_mode/update_ref.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/qemu_mode/update_ref.sh b/qemu_mode/update_ref.sh
new file mode 100755
index 00000000..13be376f
--- /dev/null
+++ b/qemu_mode/update_ref.sh
@@ -0,0 +1,47 @@
+#/bin/sh
+
+##################################################
+# AFL++ internal tool to update qemuafl ref.
+# Usage: ./update_ref.sh <new commit hash>
+# If no commit hash was provided, it'll take HEAD.
+##################################################
+
+UC_VERSION_FILE='./QEMUAFL_VERSION'
+
+NEW_VERSION="$1"
+
+if [ "$NEW_VERSION" = "-h" ]; then
+  echo "Internal script to update bound qemuafl version."
+  echo
+  echo "Usage: ./update_ref.sh <new commit hash>"
+  echo "If no commit hash is provided, will use HEAD."
+  echo "-h to show this help screen."
+  exit 1
+fi
+
+git submodule init && git submodule update || exit 1
+cd ./qemuafl || exit 1
+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 master
+git pull origin master 1>/dev/null || exit 1
+
+if [ -z "$NEW_VERSION" ]; then
+  # No version provided, take HEAD.
+  NEW_VERSION=$(git rev-parse --short HEAD)
+fi
+
+if [ -z "$NEW_VERSION" ]; then
+  echo "Error getting version."
+  exit 1
+fi
+
+git checkout "$NEW_VERSION" || exit 1
+
+cd ..
+
+rm "$UC_VERSION_FILE"
+echo "$NEW_VERSION" > "$UC_VERSION_FILE"
+
+echo "Done. New qemuafl version is $NEW_VERSION."