Sun Apr 28 08:55:37 2024 UTC (14d)
mk/haskell/{DE,}INSTALL.in: Be explicit about Haskell package DB to work with

Prior to this change the DEINSTALL hook for Haskell packages left garbage files in ${LOCALBASE}/lib/ghc-X.Y.Z/lib/package.conf.d when the major version of GHC changed.


(pho)
diff -r1.59 -r1.60 pkgsrc/mk/haskell.mk
diff -r1.3 -r1.4 pkgsrc/mk/haskell/DEINSTALL.in
diff -r1.3 -r1.4 pkgsrc/mk/haskell/INSTALL.in

cvs diff -r1.59 -r1.60 pkgsrc/mk/haskell.mk (expand / switch to unified diff)

--- pkgsrc/mk/haskell.mk 2024/04/28 08:33:44 1.59
+++ pkgsrc/mk/haskell.mk 2024/04/28 08:55:37 1.60
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: haskell.mk,v 1.59 2024/04/28 08:33:44 pho Exp $ 1# $NetBSD: haskell.mk,v 1.60 2024/04/28 08:55:37 pho Exp $
2# 2#
3# This Makefile fragment handles Haskell Cabal packages. Package 3# This Makefile fragment handles Haskell Cabal packages. Package
4# configuration, building, installation, registration and unregistration 4# configuration, building, installation, registration and unregistration
5# are fully automated. See also mk/haskell/README.md for a packaging guide. 5# are fully automated. See also mk/haskell/README.md for a packaging guide.
6# 6#
7# Package-settable variables: 7# Package-settable variables:
8# 8#
9# PKGNAME 9# PKGNAME
10# Defaults to hs-${DISTNAME}. 10# Defaults to hs-${DISTNAME}.
11# 11#
12# HOMEPAGE 12# HOMEPAGE
13# MASTER_SITES 13# MASTER_SITES
14# Default to HackageDB URLs. 14# Default to HackageDB URLs.
@@ -99,39 +99,42 @@ _DEF_VARS.haskell= \ @@ -99,39 +99,42 @@ _DEF_VARS.haskell= \
99 BUILDLINK_PASSTHRU_DIRS \ 99 BUILDLINK_PASSTHRU_DIRS \
100 USE_LANGUAGES \ 100 USE_LANGUAGES \
101 CONFIGURE_ARGS \ 101 CONFIGURE_ARGS \
102 PLIST_SUBST \ 102 PLIST_SUBST \
103 PRINT_PLIST_AWK \ 103 PRINT_PLIST_AWK \
104 GENERATE_PLIST \ 104 GENERATE_PLIST \
105 PLIST_SRC \ 105 PLIST_SRC \
106 FILES_SUBST \ 106 FILES_SUBST \
107 INSTALLATION_DIRS \ 107 INSTALLATION_DIRS \
108 INSTALL_TEMPLATES \ 108 INSTALL_TEMPLATES \
109 DEINSTALL_TEMPLATES \ 109 DEINSTALL_TEMPLATES \
110 UNLIMIT_RESOURCES \ 110 UNLIMIT_RESOURCES \
111 _HASKELL_BIN \ 111 _HASKELL_BIN \
 112 _HASKELL_GLOBAL_PKG_DB \
112 _HASKELL_PKG_BIN \ 113 _HASKELL_PKG_BIN \
113 _HASKELL_PKG_DESCR_FILE_OR_DIR \ 114 _HASKELL_PKG_DESCR_FILE_OR_DIR \
114 _HASKELL_PKG_ID_FILE \ 115 _HASKELL_PKG_ID_FILE \
115 _HASKELL_VERSION \ 116 _HASKELL_VERSION \
116 _HS_ORIG_LD_CMD 117 _HS_ORIG_LD_CMD
117_USE_VARS.haskell= \ 118_USE_VARS.haskell= \
118 DISTNAME \ 119 DISTNAME \
119 PKG_VERBOSE \ 120 PKG_VERBOSE \
120 BUILDLINK_PREFIX.ghc \ 121 BUILDLINK_PREFIX.ghc \
121 MASTER_SITE_HASKELL_HACKAGE \ 122 MASTER_SITE_HASKELL_HACKAGE \
122 PKGDIR DESTDIR \ 123 PKGDIR DESTDIR \
123 PREFIX \ 124 PREFIX \
124 WRKSRC 125 WRKSRC \
 126 _MAKE_JOBS_N \
 127 _PATH_ORIG
125_SORTED_VARS.haskell= \ 128_SORTED_VARS.haskell= \
126 HASKELL_UNRESTRICT_DEPENDENCIES 129 HASKELL_UNRESTRICT_DEPENDENCIES
127_LISTED_VARS.haskell= \ 130_LISTED_VARS.haskell= \
128 BUILDLINK_PASSTHRU_DIRS \ 131 BUILDLINK_PASSTHRU_DIRS \
129 CONFIGURE_ARGS \ 132 CONFIGURE_ARGS \
130 PLIST_SUBST \ 133 PLIST_SUBST \
131 PRINT_PLIST_AWK \ 134 PRINT_PLIST_AWK \
132 FILES_SUBST 135 FILES_SUBST
133_IGN_VARS.haskell= \ 136_IGN_VARS.haskell= \
134 USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _* 137 USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _*
135 138
136PKGNAME?= hs-${DISTNAME} 139PKGNAME?= hs-${DISTNAME}
137MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} 140MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/}
@@ -157,26 +160,33 @@ HASKELL_UNRESTRICT_DEPENDENCIES?= # empt @@ -157,26 +160,33 @@ HASKELL_UNRESTRICT_DEPENDENCIES?= # empt
157.include "../../mk/haskell/tools/cpphs.mk" 160.include "../../mk/haskell/tools/cpphs.mk"
158.include "../../mk/haskell/tools/happy.mk" 161.include "../../mk/haskell/tools/happy.mk"
159 162
160# Tools 163# Tools
161_HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc 164_HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc
162_HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc-pkg 165_HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc-pkg
163 166
164.if !defined(_HASKELL_VERSION) 167.if !defined(_HASKELL_VERSION)
165_HASKELL_VERSION_CMD= ${_HASKELL_BIN:Q} --numeric-version 168_HASKELL_VERSION_CMD= ${_HASKELL_BIN:Q} --numeric-version
166_HASKELL_VERSION:= ghc-${_HASKELL_VERSION_CMD:sh} 169_HASKELL_VERSION:= ghc-${_HASKELL_VERSION_CMD:sh}
167.endif 170.endif
168MAKEVARS+= _HASKELL_VERSION 171MAKEVARS+= _HASKELL_VERSION
169 172
 173# Determine the path to the global Haskell package database. We need this
 174# in our INSTALL and DEINSTALL hooks.
 175.if !defined(_HASKELL_GLOBAL_PKG_DB)
 176_HASKELL_GLOBAL_PKG_DB!= ${_HASKELL_BIN:Q} --print-global-package-db
 177.endif
 178MAKEVARS+= _HASKELL_GLOBAL_PKG_DB
 179
170# By default GHC uses a per-user default environment file if one is 180# By default GHC uses a per-user default environment file if one is
171# available. Cabal has to be visible in order to compile Setup.?hs, 181# available. Cabal has to be visible in order to compile Setup.?hs,
172# but per-user default environment files usually don't mark it as 182# but per-user default environment files usually don't mark it as
173# visible. Tell GHC not to read any environment files. 183# visible. Tell GHC not to read any environment files.
174_HASKELL_BUILD_SETUP_OPTS= -package-env - 184_HASKELL_BUILD_SETUP_OPTS= -package-env -
175 185
176# GHC requires C compiler. 186# GHC requires C compiler.
177USE_LANGUAGES+= c 187USE_LANGUAGES+= c
178 188
179# Haskell packages don't use semvars but they use something similar to it, 189# Haskell packages don't use semvars but they use something similar to it,
180# which is called Haskell PVP (https://pvp.haskell.org/). Packages usually 190# which is called Haskell PVP (https://pvp.haskell.org/). Packages usually
181# have version constraints on their dependencies that specify not only 191# have version constraints on their dependencies that specify not only
182# lower bounds but also upper bounds. The problem is that, while lower 192# lower bounds but also upper bounds. The problem is that, while lower
@@ -296,27 +306,27 @@ _HS_PLIST_STATUS= ok @@ -296,27 +306,27 @@ _HS_PLIST_STATUS= ok
296 306
297# Starting from GHC 7.10 (or 7.8?), packages are installed in directories 307# Starting from GHC 7.10 (or 7.8?), packages are installed in directories
298# with a hashed name, which makes it a bit more complicated to generate 308# with a hashed name, which makes it a bit more complicated to generate
299# the PLIST. 309# the PLIST.
300# 310#
301 311
302# There is no easy way to obtain a platform string such as 312# There is no easy way to obtain a platform string such as
303# "x86_64-netbsd-ghc-9.0.1". If the package contains a library we 313# "x86_64-netbsd-ghc-9.0.1". If the package contains a library we
304# could extract it from the description file, but if it's 314# could extract it from the description file, but if it's
305# executable-only there's no such file. As a workaround we read the 315# executable-only there's no such file. As a workaround we read the
306# description of "base" (which always exists) and extract the platform 316# description of "base" (which always exists) and extract the platform
307# from it. 317# from it.
308.if !defined(_HS_PLIST.platform) 318.if !defined(_HS_PLIST.platform)
309_HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN} --simple-output field base data-dir 319_HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN:Q} --simple-output field base data-dir
310_HS_PLIST.platform:= ${_HS_PLIST.platform.cmd:sh:H:T} 320_HS_PLIST.platform:= ${_HS_PLIST.platform.cmd:sh:H:T}
311.endif 321.endif
312MAKEVARS+= _HS_PLIST.platform 322MAKEVARS+= _HS_PLIST.platform
313# Abbreviated compiler version. Used for shared libraries. 323# Abbreviated compiler version. Used for shared libraries.
314_HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,} 324_HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,}
315 325
316PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform} 326PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform}
317PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION} 327PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION}
318PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver} 328PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver}
319# Package IDs formatted as "{name}-{version}-{hash}": these only exist if 329# Package IDs formatted as "{name}-{version}-{hash}": these only exist if
320# the package contains at least one library. 330# the package contains at least one library.
321_HS_PLIST.subst-libs.cmd= \ 331_HS_PLIST.subst-libs.cmd= \
322 if [ -f ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} ]; then \ 332 if [ -f ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} ]; then \
@@ -462,29 +472,30 @@ do-install: @@ -462,29 +472,30 @@ do-install:
462 elif [ -f dist/package-description ]; then \ 472 elif [ -f dist/package-description ]; then \
463 ${INSTALL_DATA} dist/package-description \ 473 ${INSTALL_DATA} dist/package-description \
464 ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}; \ 474 ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}; \
465 ${INSTALL_DATA} dist/package-id \ 475 ${INSTALL_DATA} dist/package-id \
466 ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \ 476 ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \
467 fi 477 fi
468# Executable-only packages tend to create an empty directory tree in 478# Executable-only packages tend to create an empty directory tree in
469# lib/ which results in useless @pkgdir in PLIST. 479# lib/ which results in useless @pkgdir in PLIST.
470 ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \ 480 ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \
471 ${TAIL} -n 1 | \ 481 ${TAIL} -n 1 | \
472 ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE} 482 ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE}
473 483
474# Substitutions for INSTALL and DEINSTALL. 484# Substitutions for INSTALL and DEINSTALL.
475FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN} 485FILES_SUBST+= HASKELL_GLOBAL_PKG_DB=${_HASKELL_GLOBAL_PKG_DB:Q}
476FILES_SUBST+= HASKELL_PKG_DESCR_FILE_OR_DIR=${_HASKELL_PKG_DESCR_FILE_OR_DIR} 486FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN:Q}
477FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE} 487FILES_SUBST+= HASKELL_PKG_DESCR_FILE_OR_DIR=${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}
 488FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE:Q}
478FILES_SUBST+= AWK=${AWK:Q} 489FILES_SUBST+= AWK=${AWK:Q}
479FILES_SUBST+= EXPR=${EXPR:Q} 490FILES_SUBST+= EXPR=${EXPR:Q}
480FILES_SUBST+= TRUE=${TRUE:Q} 491FILES_SUBST+= TRUE=${TRUE:Q}
481 492
482INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in 493INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in
483DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in 494DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in
484 495
485# Only present these variables if the definitions can be extracted 496# Only present these variables if the definitions can be extracted
486# from the files in DESTDIR. 497# from the files in DESTDIR.
487_DEF_VARS.haskell+= _HS_PLIST.platform 498_DEF_VARS.haskell+= _HS_PLIST.platform
488_DEF_VARS.haskell+= _HS_PLIST.short-ver 499_DEF_VARS.haskell+= _HS_PLIST.short-ver
489 500
490.endif # HASKELL_MK 501.endif # HASKELL_MK

cvs diff -r1.3 -r1.4 pkgsrc/mk/haskell/DEINSTALL.in (expand / switch to unified diff)

--- pkgsrc/mk/haskell/DEINSTALL.in 2022/02/11 01:11:57 1.3
+++ pkgsrc/mk/haskell/DEINSTALL.in 2024/04/28 08:55:37 1.4
@@ -1,26 +1,31 @@ @@ -1,26 +1,31 @@
1# -*- sh -*- 1# -*- sh -*-
2# $NetBSD: DEINSTALL.in,v 1.3 2022/02/11 01:11:57 pho Exp $ 2# $NetBSD: DEINSTALL.in,v 1.4 2024/04/28 08:55:37 pho Exp $
3# 3#
 4HASKELL_GLOBAL_PKG_DB="@HASKELL_GLOBAL_PKG_DB@"
4HASKELL_PKG_BIN="@HASKELL_PKG_BIN@" 5HASKELL_PKG_BIN="@HASKELL_PKG_BIN@"
5HASKELL_PKG_ID_FILE="@HASKELL_PKG_ID_FILE@" 6HASKELL_PKG_ID_FILE="@HASKELL_PKG_ID_FILE@"
6AWK="@AWK@" 7AWK="@AWK@"
7WC="@WC@" 8WC="@WC@"
8 9
9case ${STAGE} in 10case ${STAGE} in
10 DEINSTALL) 11 DEINSTALL)
11 if [ -f "${HASKELL_PKG_ID_FILE}" ]; then 12 if [ -f "${HASKELL_PKG_ID_FILE}" ]; then
12 # The package contains one or more libraries. The order of 13 # The package contains one or more libraries. The order of
13 # unregistration is important here; libraries with higher 14 # unregistration is important here; libraries with higher
14 # indices may depend on those with lower ones so we need to 15 # indices may depend on those with lower ones so we need to
15 # unregister them in the reverse order. 16 # unregister them in the reverse order.
16 ${AWK} 'BEGIN { i = 0 } 17 ${AWK} 'BEGIN { i = 0 }
17 { lines[i++] = $0 } 18 { lines[i++] = $0 }
18 END { for (j=i-1; j>=0; ) 19 END { for (j=i-1; j>=0; )
19 print lines[j--] }' "${HASKELL_PKG_ID_FILE}" | 20 print lines[j--] }' "${HASKELL_PKG_ID_FILE}" |
20 while read pkg_id; do 21 while read pkg_id; do
21 ${ECHO} "Unregistering \`$pkg_id'..." 22 ${ECHO} "Unregistering \`$pkg_id'..."
22 ${HASKELL_PKG_BIN} unregister --force --ipid "$pkg_id" 23 ${HASKELL_PKG_BIN} \
 24 --package-db="${HASKELL_GLOBAL_PKG_DB}" \
 25 --force \
 26 --ipid \
 27 unregister "$pkg_id"
23 done 28 done
24 fi 29 fi
25 ;; 30 ;;
26esac 31esac

cvs diff -r1.3 -r1.4 pkgsrc/mk/haskell/INSTALL.in (expand / switch to unified diff)

--- pkgsrc/mk/haskell/INSTALL.in 2022/02/11 01:11:57 1.3
+++ pkgsrc/mk/haskell/INSTALL.in 2024/04/28 08:55:37 1.4
@@ -1,31 +1,35 @@ @@ -1,31 +1,35 @@
1# -*- sh -*- 1# -*- sh -*-
2# $NetBSD: INSTALL.in,v 1.3 2022/02/11 01:11:57 pho Exp $ 2# $NetBSD: INSTALL.in,v 1.4 2024/04/28 08:55:37 pho Exp $
3# 3#
 4HASKELL_GLOBAL_PKG_DB="@HASKELL_GLOBAL_PKG_DB@"
4HASKELL_PKG_BIN="@HASKELL_PKG_BIN@" 5HASKELL_PKG_BIN="@HASKELL_PKG_BIN@"
5HASKELL_PKG_DESCR_FILE_OR_DIR="@HASKELL_PKG_DESCR_FILE_OR_DIR@" 6HASKELL_PKG_DESCR_FILE_OR_DIR="@HASKELL_PKG_DESCR_FILE_OR_DIR@"
6EXPR="@EXPR@" 7EXPR="@EXPR@"
7TRUE="@TRUE@" 8TRUE="@TRUE@"
8 9
9case ${STAGE} in 10case ${STAGE} in
10 POST-INSTALL) 11 POST-INSTALL)
11 if [ -f "${HASKELL_PKG_DESCR_FILE_OR_DIR}" ]; then 12 if [ -f "${HASKELL_PKG_DESCR_FILE_OR_DIR}" ]; then
12 # The package contains a single library. 13 # The package contains a single library.
13 ${HASKELL_PKG_BIN} register "${HASKELL_PKG_DESCR_FILE_OR_DIR}"; 14 ${HASKELL_PKG_BIN} \
 15 --package-db="${HASKELL_GLOBAL_PKG_DB}" \
 16 register "${HASKELL_PKG_DESCR_FILE_OR_DIR}";
14 17
15 elif [ -d "${HASKELL_PKG_DESCR_FILE_OR_DIR}" ]; then 18 elif [ -d "${HASKELL_PKG_DESCR_FILE_OR_DIR}" ]; then
16 # The package contains two or more libraries. The order of 19 # The package contains two or more libraries. The order of
17 # registration is important here; libraries with higher indices 20 # registration is important here; libraries with higher indices
18 # may depend on those with lower ones. 21 # may depend on those with lower ones.
19 i=1 22 i=1
20 while ${TRUE}; do 23 while ${TRUE}; do
21 if [ -f "${HASKELL_PKG_DESCR_FILE_OR_DIR}/${i}" ]; then 24 if [ -f "${HASKELL_PKG_DESCR_FILE_OR_DIR}/${i}" ]; then
22 ${HASKELL_PKG_BIN} \ 25 ${HASKELL_PKG_BIN} \
 26 --package-db="${HASKELL_GLOBAL_PKG_DB}" \
23 register "${HASKELL_PKG_DESCR_FILE_OR_DIR}/${i}" 27 register "${HASKELL_PKG_DESCR_FILE_OR_DIR}/${i}"
24 i=`${EXPR} $i + 1` 28 i=`${EXPR} $i + 1`
25 else 29 else
26 break 30 break
27 fi 31 fi
28 done 32 done
29 fi 33 fi
30 ;; 34 ;;
31esac 35esac