fix(setup ghc): register haskell packages recursively

previously only main dependencies were registered, ignoring dependencies of dependencies.

Signed-off-by: Aditya Alok <dev.aditya.alok@gmail.com>
This commit is contained in:
Aditya Alok 2022-04-25 21:52:36 +05:30
parent 597726cf10
commit 3ba86891ed
No known key found for this signature in database
GPG Key ID: 345AE134142077D8

View File

@ -1,18 +1,25 @@
# shellcheck shell=bash
__termux_haskell_register_packages() {
# Register dependency haskell packages with termux-ghc-pkg.
IFS=',' read -r -a DEP <<<"$(echo "${TERMUX_PKG_DEPENDS},${TERMUX_PKG_BUILD_DEPENDS}" | tr -d ' ')"
for dep in "${DEP[@]}"; do
if [[ "${dep/haskell-/}" != "${dep}" ]]; then
echo "Dependency '${dep}' is a haskell package, registering it with ghc-pkg..."
echo "Registering haskell packages with ghc-pkg...(if any)"
while read -r DEP DEP_DIR; do
if [[ -z $DEP ]]; then
continue
elif [[ "${DEP}" == "ERROR" ]]; then
termux_error_exit "Failed to find dependencies of ${TERMUX_PKG_NAME}[Context: ${FUNCNAME[0]}]"
fi
if [[ "${DEP/haskell-/}" != "${DEP}" ]]; then
sed "s|${TERMUX_PREFIX}/bin/ghc-pkg|$(command -v termux-ghc-pkg)|g" \
"${TERMUX_PREFIX}/share/haskell/register/${dep}.sh" | sh
"${TERMUX_PREFIX}/share/haskell/register/${DEP}.sh" | sh
termux-ghc-pkg recache
# NOTE: Above command rewrites a cache file at
# "${TERMUX_PREFIX}/lib/ghc-${TERMUX_GHC_VERSION}/package.conf.d". Since it is done after
# timestamp creation, we need to remove it in massage step.
fi
done
done <<<"$(
# shellcheck disable=SC2086
"${TERMUX_SCRIPTDIR}"/buildorder.py -i "${TERMUX_PKG_BUILDER_DIR}" ${TERMUX_PACKAGES_DIRECTORIES} || echo "ERROR"
)"
}
__termux_haskell_setup_build_script() {