From 54f5461610448272b0cfb780f068e7781559e077 Mon Sep 17 00:00:00 2001
From: Daniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Date: Thu, 5 Apr 2018 17:53:44 +0200
Subject: [PATCH] Check the SHA256 checksum for astyle_2.04_linux.tar.gz

---
 .travis.yml                       |  1 -
 contrib/utilities/indent          |  2 +-
 contrib/utilities/setup_astyle.sh | 13 +++++++++----
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d711326c09..0121779323 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,7 +13,6 @@ cache:
     - programs
 
 install:
-    - export PATH=$PWD/programs/astyle/build/gcc/bin:$PATH
     - ./contrib/utilities/setup_astyle.sh 
 
 script: 
diff --git a/contrib/utilities/indent b/contrib/utilities/indent
index 30151d0b54..2a28b6c1ea 100755
--- a/contrib/utilities/indent
+++ b/contrib/utilities/indent
@@ -31,7 +31,7 @@
 #
 
 # Add the location 'setup_astyle.sh' installs astyle to to the local PATH.
-THIS_PATH="$(dirname $0)"            # relative
+THIS_PATH="$(dirname $0)"              # relative
 THIS_PATH="$( cd $THIS_PATH && pwd )"  # absolutized and normalized
 export PATH=$THIS_PATH/programs/astyle/build/gcc/bin/:$PATH
 
diff --git a/contrib/utilities/setup_astyle.sh b/contrib/utilities/setup_astyle.sh
index 1a5dda842f..2c29ded938 100755
--- a/contrib/utilities/setup_astyle.sh
+++ b/contrib/utilities/setup_astyle.sh
@@ -33,8 +33,13 @@ if [ ! -d "$PRG/astyle" ]
 then
     echo "Downloading and installing astyle."
     mkdir "$PRG/astyle"
-    wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.04/astyle_2.04_linux.tar.gz  > /dev/null
-    tar xfz astyle_2.04_linux.tar.gz -C "$PRG" > /dev/null
-    cd "$PRG/astyle/build/gcc"
-    make -j4 > /dev/null
+    wget https://downloads.sourceforge.net/project/astyle/astyle/astyle%202.04/astyle_2.04_linux.tar.gz  > /dev/null
+    if echo "70b37f4853c418d1e2632612967eebf1bdb93dfbe558c51d7d013c9b4e116b60 astyle_2.04_linux.tar.gz" | sha256sum -c; then
+      tar xfz astyle_2.04_linux.tar.gz -C "$PRG" > /dev/null
+      cd "$PRG/astyle/build/gcc" || exit 1
+      make -j4 > /dev/null
+    else
+      echo "*** The downloaded file has the wrong SHA256 checksum!"
+      exit 1
+    fi
 fi
-- 
2.39.5