git: 3eb1fbc04130 - main - Uses/cabal.mk: Pass correct XDG_* environment in cabal invocations.

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Sun, 12 Mar 2023 07:16:31 UTC
The branch main has been updated by arrowd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3eb1fbc04130a5de07a27a7fe63faa1af5bdad00

commit 3eb1fbc04130a5de07a27a7fe63faa1af5bdad00
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2023-03-11 19:38:40 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2023-03-12 07:15:53 +0000

    Uses/cabal.mk: Pass correct XDG_* environment in cabal invocations.
---
 Mk/Uses/cabal.mk | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/Mk/Uses/cabal.mk b/Mk/Uses/cabal.mk
index a788a66c2b9b..0221eb36a78a 100644
--- a/Mk/Uses/cabal.mk
+++ b/Mk/Uses/cabal.mk
@@ -84,6 +84,7 @@ CABAL_EXECUTABLES?=	${PORTNAME}
 CABAL_CMD?=	cabal
 CABAL_PORT=	devel/hs-cabal-install
 CABAL_HOME=	${WRKDIR}/cabal-home
+CABAL_HOME_ENV=XDG_DATA_HOME=${CABAL_HOME} XDG_CONFIG_HOME=${CABAL_HOME} XDG_CACHE_HOME=${CABAL_HOME} HOME=${CABAL_HOME}
 CABAL_LIBEXEC=	libexec/cabal
 CABAL_EXTRACT_SUFX=	.tar.gz
 CABAL_ARCH=	${ARCH:S/amd64/x86_64/:C/armv.*/arm/:S/powerpc64/ppc64/}
@@ -190,14 +191,14 @@ cabal-extract: check-cabal
 	${RM} -r ${CABAL_HOME}
 .  endif
 	@${ECHO_MSG} "===> Fetching Hackage index into ${CABAL_HOME}/.cabal"
-	${SETENV} HOME=${CABAL_HOME} ${CABAL_CMD} update
+	${SETENV} ${CABAL_HOME_ENV} ${CABAL_CMD} update
 .  if ${_hackage_is_default} == yes
 	cd ${WRKDIR} && \
-		${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} get ${PORTNAME}-${PORTVERSION}
+		${SETENV} ${MAKE_ENV} ${CABAL_HOME_ENV} ${CABAL_CMD} get ${PORTNAME}-${PORTVERSION}
 .  else
 .    if ${cabal_ARGS:Mhpack}
 	@${ECHO_MSG} "===> Running ${HPACK_CMD} to generate .cabal file"
-	cd ${WRKSRC} && ${SETENV} HOME=${CABAL_HOME} ${HPACK_CMD}
+	cd ${WRKSRC} && ${SETENV} ${CABAL_HOME_ENV} ${HPACK_CMD}
 .    endif
 .  endif
 # Remove Haskell dependencies that come from GH_TUPLE
@@ -205,7 +206,7 @@ cabal-extract: check-cabal
 .  ifdef CABAL_REPOSITORIES
 	@${ECHO_MSG} "===> Fetching additional Cabal repositories index into ${CABAL_HOME}/.cabal"
 	@cd ${WRKSRC} && \
-		${SETENV} HOME=${CABAL_HOME} ${CABAL_CMD} update
+		${SETENV} ${CABAL_HOME_ENV} ${CABAL_CMD} update
 .  endif
 # Create a cookie for cabal-post-patch
 	@${TOUCH} ${EXTRACT_COOKIE} ${CABAL_COOKIE}
@@ -215,12 +216,12 @@ cabal-extract: check-cabal
 # This pulls in all source dependencies, resolves them and generates build plan
 cabal-configure: check-cabal
 	cd ${WRKSRC} && \
-		${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} build --dry-run --disable-benchmarks --disable-tests --flags="${CABAL_FLAGS}" ${CABAL_WITH_ARGS} ${CABAL_LTO_ARGS} ${BUILD_ARGS} ${BUILD_TARGET}
+		${SETENV} ${MAKE_ENV} ${CABAL_HOME_ENV} ${CABAL_CMD} build --dry-run --disable-benchmarks --disable-tests --flags="${CABAL_FLAGS}" ${CABAL_WITH_ARGS} ${CABAL_LTO_ARGS} ${BUILD_ARGS} ${BUILD_TARGET}
 
 # Calls cabal build on the Haskell package located in ${WRKSRC}
 cabal-build: check-cabal
 	cd ${WRKSRC} && \
-		${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} build --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} ${CABAL_LTO_ARGS} ${BUILD_ARGS} ${BUILD_TARGET}
+		${SETENV} ${MAKE_ENV} ${CABAL_HOME_ENV} ${CABAL_CMD} build --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} ${CABAL_LTO_ARGS} ${BUILD_ARGS} ${BUILD_TARGET}
 
 # Generates USE_CABAL= ... line ready to be pasted into the port based on the plan.json file generated by cabal configure.
 make-use-cabal: check-cabal2tuple
@@ -300,13 +301,13 @@ cabal-post-patch:
 cabal-pre-configure:
 # Generate .cabal file with hpack if requested
 .  if ${cabal_ARGS:Mhpack}
-	cd ${WRKSRC} && ${SETENV} HOME=${CABAL_HOME} hpack
+	cd ${WRKSRC} && ${SETENV} ${CABAL_HOME_ENV} hpack
 .  endif
 
 .  if !target(do-build)
 do-build:
 	cd ${WRKSRC} && \
-		${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} build --offline --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} ${CABAL_LTO_ARGS} --flags "${CABAL_FLAGS}" ${BUILD_ARGS} ${BUILD_TARGET}
+		${SETENV} ${MAKE_ENV} ${CABAL_HOME_ENV} ${CABAL_CMD} build --offline --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} ${CABAL_LTO_ARGS} --flags "${CABAL_FLAGS}" ${BUILD_ARGS} ${BUILD_TARGET}
 .  endif
 
 .  if !target(do-install)