termux-packages/scripts/build/setup/termux_setup_cabal.sh
Aditya Alok dc2474b2c2 feat(ghc): enable cross-compiling haskell packages on CI
- `termux_setup_ghc_cross_compiler` should not be called by build.sh, as it installs cross-compiler
in $TERMUX_PREFIX (otherwise ghc adds wrong `rpaths` to built libs and executables)

Signed-off-by: Aditya Alok <dev.aditya.alok@gmail.com>
2022-03-09 10:01:57 +09:00

36 lines
1.3 KiB
Bash

termux_setup_cabal() {
if [ "${TERMUX_ON_DEVICE_BUILD}" = "false" ]; then
local TERMUX_CABAL_VERSION=3.6.2.0
local TERMUX_CABAL_TAR="${TERMUX_COMMON_CACHEDIR}/cabal-${TERMUX_CABAL_VERSION}.tar.xz"
local TERMUX_CABAL_RUNTIME_FOLDER
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
TERMUX_CABAL_RUNTIME_FOLDER="${TERMUX_SCRIPTDIR}/build-tools/cabal-${TERMUX_CABAL_VERSION}-runtime"
else
TERMUX_CABAL_RUNTIME_FOLDER="${TERMUX_COMMON_CACHEDIR}/cabal-${TERMUX_CABAL_VERSION}-runtime"
fi
export PATH="${TERMUX_CABAL_RUNTIME_FOLDER}:${PATH}"
[ -d "${TERMUX_CABAL_RUNTIME_FOLDER}" ] && return
termux_download "https://github.com/MrAdityaAlok/ghc-cross-tools/releases/download/cabal-install-v${TERMUX_CABAL_VERSION}/cabal-install-${TERMUX_CABAL_VERSION}.tar.xz" \
"${TERMUX_CABAL_TAR}" \
"54de3ac03f9648a7e71715c1c4cba3ada34d9d20c812f39d134545e3e32708d4"
mkdir -p "${TERMUX_CABAL_RUNTIME_FOLDER}"
tar xf "${TERMUX_CABAL_TAR}" -C "${TERMUX_CABAL_RUNTIME_FOLDER}"
rm "${TERMUX_CABAL_TAR}"
cabal update
else
if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' cabal-install 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q cabal-install 2>/dev/null)" ]]; then
echo "Package 'cabal-install' is not installed."
exit 1
fi
fi
}