Subject: Revised fix for PR 19218
To: None <tech-pkg@NetBSD.org>
From: Alistair Crooks <agc@pkgsrc.org>
List: tech-pkg
Date: 10/20/2003 15:59:42
--gKMricLos+KVdGMg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

The attached diff fixes PR 19218 for me ("make replace" fails if the
package is not already installed) with 1.6ZD and -current pkgsrc. 

With a bit more positive feedback, it would be nice to get this in
before the new branch.

Thanks,
Alistair
--
Alistair Crooks <agc@pkgsrc.org>

--gKMricLos+KVdGMg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="19218.diff"

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1297
diff -u -r1.1297 bsd.pkg.mk
--- bsd.pkg.mk	18 Oct 2003 12:29:26 -0000	1.1297
+++ bsd.pkg.mk	20 Oct 2003 13:55:46 -0000
@@ -1685,7 +1685,7 @@
 # Please do not modify the leading "@" here
 .PHONY: check-vulnerable
 check-vulnerable:
-	@if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then			\
+	@if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then		\
 		${SETENV} PKGNAME="${PKGNAME}"				\
 			  PKGBASE="${PKGBASE}"				\
 			${AWK} '/^$$/ { next }				\
@@ -3214,8 +3214,12 @@
 do-su-replace:
 	@${ECHO_MSG} "${_PKGSRC_IN}> Replacing ${PKGNAME}"
 	${_PKG_SILENT}${_PKG_DEBUG}					\
-	realtarget="real-su-replace";					\
-	action="replace";						\
+	found="`${PKG_INFO} -e \"${PKGWILDCARD}\" || ${TRUE}`";		\
+	case "$$found" in						\
+	"") 	action="install" ;;					\
+	*)	action="replace" ;;					\
+	esac;								\
+	realtarget="real-su-$$action";					\
 	${_SU_TARGET}
 
 .PHONY: do-su-undo-replace

--gKMricLos+KVdGMg--