From 2645970ae942f13a942b369ad938db20ff641f75 Mon Sep 17 00:00:00 2001
From: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Date: Sat, 16 Apr 2016 21:20:44 +0200
Subject: [PATCH] travis-script.sh: test bootstrapping

---
 .travis.yml                |  1 -
 cabal-install/bootstrap.sh | 19 ++++++++++++++++---
 travis-script.sh           | 31 +++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 36274314ed..2bc39368cd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,7 +23,6 @@ before_install:
  - git version
 
 install:
- - cabal update
  # We intentionally do not install anything before trying to build Cabal because
  # it should build with each supported GHC version out-of-the-box.
 
diff --git a/cabal-install/bootstrap.sh b/cabal-install/bootstrap.sh
index 512bd0544b..17264cdcee 100755
--- a/cabal-install/bootstrap.sh
+++ b/cabal-install/bootstrap.sh
@@ -181,8 +181,21 @@ PARSEC_VER="3.1.9";    PARSEC_VER_REGEXP="[3]\.[01]\."
                        # >= 3.0 && < 3.2
 DEEPSEQ_VER="1.4.2.0"; DEEPSEQ_VER_REGEXP="1\.[1-9]\."
                        # >= 1.1 && < 2
-BINARY_VER="0.8.3.0";  BINARY_VER_REGEXP="[0]\.[78]\."
-                       # >= 0.7 && < 0.9
+
+case "$GHC_VER" in
+    7.4*|7.6*)
+        # GHC 7.4 or 7.6
+        BINARY_VER="0.8.2.1"
+        BINARY_VER_REGEXP="[0]\.[78]\.[0-2]\." # >= 0.7 && < 0.8.3
+        ;;
+    *)
+        # GHC >= 7.8
+        BINARY_VER="0.8.3.0"
+        BINARY_VER_REGEXP="[0]\.[78]\." # >= 0.7 && < 0.9
+        ;;
+esac
+
+
 TEXT_VER="1.2.2.1";    TEXT_VER_REGEXP="((1\.[012]\.)|(0\.([2-9]|(1[0-1]))\.))"
                        # >= 0.2 && < 1.3
 NETWORK_VER="2.6.2.1"; NETWORK_VER_REGEXP="2\.[0-6]\."
@@ -213,7 +226,7 @@ OLD_LOCALE_VER="1.0.0.7"; OLD_LOCALE_VER_REGEXP="1\.0\.?"
                        # >=1.0.0.0 && <1.1
 BASE16_BYTESTRING_VER="0.1.1.6"; BASE16_BYTESTRING_VER_REGEXP="0\.1"
                        # 0.1.*
-BASE64_BYTESTRING_VER="1.0.0.1";    BASE64_BYTESTRING_REGEXP="1\."
+BASE64_BYTESTRING_VER="1.0.0.1"; BASE64_BYTESTRING_REGEXP="1\."
                        # >=1.0
 CRYPTOHASH_SHA256_VER="0.11.7.1"; CRYPTOHASH_SHA256_VER_REGEXP="0\.11\.?"
                        # 0.11.*
diff --git a/travis-script.sh b/travis-script.sh
index cdb65a6da4..b479aacb8b 100755
--- a/travis-script.sh
+++ b/travis-script.sh
@@ -1,8 +1,39 @@
 #!/usr/bin/env bash
 set -ev
 
+# ---------------------------------------------------------------------
+# Bootstrap cabal, to verify bootstrap.sh script works.
+# ---------------------------------------------------------------------
+
+OLD_CWD=$PWD
+
+# Bootstrap
+cd Cabal
+ghc --make Setup
+./Setup configure --user
+./Setup build
+./Setup install
+cd ../cabal-install
+env EXTRA_CONFIGURE_OPTS="" ./bootstrap.sh --no-doc
+~/.cabal/bin/cabal --version
+
+# Move cabal for local use.
+mkdir ~/fresh-cabal
+mv -i ~/.cabal/bin/cabal ~/fresh-cabal/
+
+# Clean up after ourselves.
+rm -r ~/.ghc ~/.cabal
+
+# From here on we use the freshly built cabal executable.
+export PATH="$HOME/fresh-cabal/:$PATH"
+
+cd $OLD_CWD
+
+
 # Initial working directory: base directory of Git repository
 
+cabal update
+
 # We depend on parsec nowadays, which isn't distributed with GHC <8.0
 if [ "$PARSEC_BUNDLED" != "YES" ]; then
     cabal install parsec
-- 
GitLab