From 19824976f74e838ea73e77602a885b7676a3f5e6 Mon Sep 17 00:00:00 2001
From: Matthias Volk <matthias.volk@cs.rwth-aachen.de>
Date: Tue, 19 Mar 2019 18:27:48 +0100
Subject: [PATCH] Added helper script for downloading the QVBS

---
 CHANGELOG.md                        |  1 +
 resources/examples/download_qvbs.sh | 40 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100755 resources/examples/download_qvbs.sh

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9bd78afd2..e0d7c9087 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ Version 1.3.x
 ### Version 1.3.1 (under development)
 - Added support for multi-dimensional quantile queries
 - Allow to quickly check a benchmark from the [Quantitative Verification Benchmark Set](http://qcomp.org/benchmarks/) using the --qvbs option.
+- Added script resources/examples/download_qvbs.sh to download the QVBS.
 - Allow bounded types for constants in JANI.
 - Fixed sparse bisimulation of MDPs (which failed if all non-absorbing states in the quotient are initial)
 
diff --git a/resources/examples/download_qvbs.sh b/resources/examples/download_qvbs.sh
new file mode 100755
index 000000000..0657c5dba
--- /dev/null
+++ b/resources/examples/download_qvbs.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Get arguments
+if [ $# -ne 1 ]; then
+    # Print usage
+    echo "Download helper for the 'Quantitative Verification Benchmark Set' (QVBS) from http://qcomp.org/benchmarks/"
+    FILE_NAME=$(basename $BASH_SOURCE)
+    echo "- Usage:"
+    echo -e "\t./$FILE_NAME <destination directory>"
+    exit 1
+fi
+
+DIR=$1
+
+# Check if directory already exists
+if [ -d "$DIR" ]; then
+    # Check if directory already contains git repo
+    git -C $DIR rev-parse
+    GIT_RET=$?
+    if [ $GIT_RET -ne 0 ]; then
+        echo "- Directory already exists."
+        exit 2
+    fi
+    # Directory contains git repo
+    GIT_URL=$(git -C $DIR config --get remote.origin.url)
+    if [ "$GIT_URL" = "https://github.com/ahartmanns/qcomp.git" ]; then
+        echo "- QVBS repo already exists. Updating the repo instead."
+        git -C $DIR pull
+    else
+        echo "- Unknown git repo already exists in directory."
+        exit 3
+    fi
+else
+    echo "- Will clone repo from https://github.com/ahartmanns/qcomp.git"
+    git clone https://github.com/ahartmanns/qcomp.git $DIR
+    echo "- QVBS successfully downloaded to $DIR"
+fi
+
+echo "- Integrate QVBS into Storm by adding the following flag to CMake:"
+echo "-DSTORM_QVBS_ROOT=$DIR/benchmarks"