Merge pull request #5870 from fgaz/new-install/bindir-method
[cabal.git] / travis-common.sh
blobd6fe02c5acdd9051a740deba285387f75a469799
1 set -e
3 HACKAGE_REPO_TOOL_VERSION="0.1.1.1"
4 CABAL_VERSION="3.0.0.0"
5 CABAL_INSTALL_VERSION="3.0.0.0"
7 if [ "$TRAVIS_OS_NAME" = "linux" ]; then
8 ARCH="x86_64-linux"
9 else
10 ARCH="x86_64-osx"
13 CABAL_STORE_DB="${HOME}/.cabal/store/ghc-${GHCVER}/package.db"
14 CABAL_LOCAL_DB="${TRAVIS_BUILD_DIR}/dist-newstyle/packagedb/ghc-${GHCVER}"
15 CABAL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/Cabal-${CABAL_VERSION}"
16 CABAL_TESTSUITE_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/cabal-testsuite-${CABAL_VERSION}"
17 CABAL_INSTALL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/cabal-install-${CABAL_INSTALL_VERSION}"
18 SOLVER_BENCHMARKS_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/solver-benchmarks-${CABAL_VERSION}"
19 HACKAGE_REPO_TOOL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}/x/hackage-repo-tool"
20 CABAL_INSTALL_EXE=${CABAL_INSTALL_BDIR}/x/cabal/build/cabal/cabal
22 # ---------------------------------------------------------------------
23 # Timing / diagnostic output
24 # ---------------------------------------------------------------------
26 JOB_START_TIME=$(date +%s)
28 timed() {
29 echo "\$ $*"
30 start_time=$(date +%s)
32 # Run the job
33 $* || exit $?
35 # Calculate the durations
36 end_time=$(date +%s)
37 duration=$((end_time - start_time))
38 total_duration=$((end_time - JOB_START_TIME))
40 # Print them
41 echo "$* took $duration seconds."
42 echo "whole job took $total_duration seconds so far."
44 # Terminate if the job is taking too long (we must do this to
45 # preserve the populated cache for the next run).
46 if [ $total_duration -ge 2400 ]; then
47 echo "Job taking over 38 minutes. Terminating"
48 exit 1
50 echo "----"
53 travis_retry () {
54 $* || (sleep 1 && $*) || (sleep 2 && $*)