summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorpho <pho@pkgsrc.org>2020-01-09 12:29:32 +0000
committerpho <pho@pkgsrc.org>2020-01-09 12:29:32 +0000
commitb8402145b7a91e0a8fbe4fe393dde141cf525707 (patch)
tree66a4324e6027c9f6b89733eb2bd1dea7b737b8d3 /mk
parent902d63982831f5372adabcf0d6595ab05320f911 (diff)
downloadpkgsrc-b8402145b7a91e0a8fbe4fe393dde141cf525707.tar.gz
Use hashed package keys for (un)installing Cabal packages
Starting from somewhere around GHC 7.8, Cabal installs packages with a hashed package key instead of just "{NAME}-{VERSION}". In other words, the pair of the plain package name and the version is no longer unique in the package DB, and using it for uninstallation may also remove packages that we didn't mean to remove. This is paricularly problematic because GHC comes with several bundled Cabal packages. Installing and uninstalling a package with the same name could break GHC itself, if the uninstallation is performed without hashed keys.
Diffstat (limited to 'mk')
-rw-r--r--mk/haskell.mk20
-rw-r--r--mk/haskell/DEINSTALL.in11
-rw-r--r--mk/haskell/INSTALL.in4
3 files changed, 21 insertions, 14 deletions
diff --git a/mk/haskell.mk b/mk/haskell.mk
index 3fcd2ccf9f0..f9bdca4081b 100644
--- a/mk/haskell.mk
+++ b/mk/haskell.mk
@@ -1,4 +1,4 @@
-# $NetBSD: haskell.mk,v 1.10 2020/01/02 16:45:15 pho Exp $
+# $NetBSD: haskell.mk,v 1.11 2020/01/09 12:29:32 pho Exp $
#
# This Makefile fragment handles Haskell Cabal packages.
# See: http://www.haskell.org/cabal/
@@ -107,6 +107,7 @@ _DEF_VARS.haskell= \
_HASKELL_BIN \
_HASKELL_PKG_BIN \
_HASKELL_PKG_DESCR_FILE \
+ _HASKELL_PKG_ID_FILE \
_HASKELL_VERSION
_USER_VARS.haskell= \
HASKELL_ENABLE_SHARED_LIBRARY \
@@ -140,7 +141,7 @@ HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes
# Compiler specific variables and targets.
.if ${HASKELL_COMPILER} == "ghc"
-# Add dependency to the GHC.
+# Add dependency on GHC.
.include "../../lang/ghc7/buildlink3.mk"
# Tools
@@ -241,15 +242,22 @@ do-build:
# for package registration (if any).
_HASKELL_PKG_DESCR_DIR= ${PREFIX}/lib/${DISTNAME}/${_HASKELL_VERSION}
_HASKELL_PKG_DESCR_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-description
+_HASKELL_PKG_ID_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-id
INSTALLATION_DIRS+= ${_HASKELL_PKG_DESCR_DIR}
do-install:
${RUN}cd ${WRKSRC} && \
- ./Setup register ${PKG_VERBOSE:D-v} --gen-pkg-config=dist/package-description && \
+ ./Setup register ${PKG_VERBOSE:D-v} \
+ --gen-pkg-config=dist/package-description \
+ --print-ipid \
+ > dist/package-id && \
./Setup copy ${PKG_VERBOSE:D-v} --destdir=${DESTDIR:Q} && \
if [ -f dist/package-description ]; then \
- ${INSTALL_DATA} dist/package-description ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE:Q}; \
- fi \
+ ${INSTALL_DATA} dist/package-description \
+ ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE:Q}; \
+ ${INSTALL_DATA} dist/package-id \
+ ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \
+ fi
# Define test target.
do-test:
@@ -257,9 +265,9 @@ do-test:
./Setup test ${PKG_VERBOSE:D-v}
# Substitutions for INSTALL and DEINSTALL.
-FILES_SUBST+= DISTNAME=${DISTNAME}
FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN}
FILES_SUBST+= HASKELL_PKG_DESCR_FILE=${_HASKELL_PKG_DESCR_FILE}
+FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE}
INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in
DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in
diff --git a/mk/haskell/DEINSTALL.in b/mk/haskell/DEINSTALL.in
index bd28ce97545..2bde80ecc1b 100644
--- a/mk/haskell/DEINSTALL.in
+++ b/mk/haskell/DEINSTALL.in
@@ -1,14 +1,13 @@
# -*- sh -*-
-# $NetBSD: DEINSTALL.in,v 1.1 2014/02/05 07:02:30 obache Exp $
+# $NetBSD: DEINSTALL.in,v 1.2 2020/01/09 12:29:32 pho Exp $
#
-DISTNAME="@DISTNAME@"
HASKELL_PKG_BIN="@HASKELL_PKG_BIN@"
-HASKELL_PKG_DESCR_FILE="@HASKELL_PKG_DESCR_FILE@"
+HASKELL_PKG_ID_FILE="@HASKELL_PKG_ID_FILE@"
-case ${STAGE} in
+case ${STAGE} in
DEINSTALL)
- if [ -f ${HASKELL_PKG_DESCR_FILE} ]; then
- ${HASKELL_PKG_BIN} unregister --force ${DISTNAME}
+ if [ -f ${HASKELL_PKG_ID_FILE} ]; then
+ ${HASKELL_PKG_BIN} unregister --force --ipid `cat "$HASKELL_PKG_ID_FILE"`
fi
;;
esac
diff --git a/mk/haskell/INSTALL.in b/mk/haskell/INSTALL.in
index 6761b1cb857..2e5087c2764 100644
--- a/mk/haskell/INSTALL.in
+++ b/mk/haskell/INSTALL.in
@@ -1,5 +1,5 @@
# -*- sh -*-
-# $NetBSD: INSTALL.in,v 1.1 2014/02/05 07:02:30 obache Exp $
+# $NetBSD: INSTALL.in,v 1.2 2020/01/09 12:29:32 pho Exp $
#
HASKELL_PKG_BIN="@HASKELL_PKG_BIN@"
HASKELL_PKG_DESCR_FILE="@HASKELL_PKG_DESCR_FILE@"
@@ -7,7 +7,7 @@ HASKELL_PKG_DESCR_FILE="@HASKELL_PKG_DESCR_FILE@"
case ${STAGE} in
POST-INSTALL)
if [ -f ${HASKELL_PKG_DESCR_FILE} ]; then
- ${HASKELL_PKG_BIN} update ${HASKELL_PKG_DESCR_FILE};
+ ${HASKELL_PKG_BIN} register ${HASKELL_PKG_DESCR_FILE};
fi
;;
esac