|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eux |
| 4 | + |
| 5 | +# shellcheck disable=SC1091 |
| 6 | +. .github/scripts/env.sh |
| 7 | +# shellcheck disable=SC1091 |
| 8 | +. .github/scripts/common.sh |
| 9 | + |
| 10 | +uname -a |
| 11 | +uname -p |
| 12 | +uname |
| 13 | +pwd |
| 14 | +env |
| 15 | + |
| 16 | +# ensure ghcup |
| 17 | +install_ghcup |
| 18 | + |
| 19 | +# build |
| 20 | +ghcup install ghc "${GHC_VERSION}" |
| 21 | +ghcup set ghc "${GHC_VERSION}" |
| 22 | +sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project |
| 23 | +ecabal update |
| 24 | +ecabal user-config diff |
| 25 | +ecabal user-config init -f |
| 26 | +"ghc-${GHC_VERSION}" --info |
| 27 | +"ghc" --info |
| 28 | + |
| 29 | +# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884 |
| 30 | +if [ "$(getconf LONG_BIT)" == "32" ] || [ "${DISTRO}" == "CentOS" ] ; then |
| 31 | + echo 'constraints: lukko -ofd-locking' >> cabal.release.project.local |
| 32 | +fi |
| 33 | + |
| 34 | +# shellcheck disable=SC2206 |
| 35 | +args=( |
| 36 | + -w "ghc-$GHC_VERSION" |
| 37 | + --disable-profiling |
| 38 | + --enable-executable-stripping |
| 39 | + --project-file=cabal.release.project |
| 40 | + ${ADD_CABAL_ARGS} |
| 41 | +) |
| 42 | + |
| 43 | +run cabal v2-build "${args[@]}" cabal-install |
| 44 | + |
| 45 | +mkdir -p "$CI_PROJECT_DIR/out" |
| 46 | +# shellcheck disable=SC2154 |
| 47 | +cp "$(cabal list-bin "${args[@]}" cabal-install:exe:cabal)" "$CI_PROJECT_DIR/out/cabal$ext" |
| 48 | +cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json" |
| 49 | +cd "$CI_PROJECT_DIR/out/" |
| 50 | + |
| 51 | +# create tarball/zip |
| 52 | +TARBALL_PREFIX="cabal-install-$("$CI_PROJECT_DIR/out/cabal" --numeric-version)" |
| 53 | +case "${TARBALL_EXT}" in |
| 54 | + zip) |
| 55 | + zip "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json |
| 56 | + ;; |
| 57 | + tar.xz) |
| 58 | + tar caf "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json |
| 59 | + ;; |
| 60 | + *) |
| 61 | + fail "Unknown TARBALL_EXT: ${TARBALL_EXT}" |
| 62 | + ;; |
| 63 | +esac |
| 64 | + |
| 65 | +rm cabal plan.json |
| 66 | + |
0 commit comments