Subject: pkg/27149: use install on non-installed packages when targeting "replace"
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <pancake@phreaker.net>
List: pkgsrc-bugs
Date: 10/05/2004 16:12:23
>Number:         27149
>Category:       pkg
>Synopsis:       bmake replace fails on non-installed packages.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 05 14:13:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        Linux 2.6.8.1
>Organization:
	
>Environment:
	
	
System: Linux bare 2.6.8.1 #5 Wed Sep 29 12:02:32 VET 2004 i686 GNU/Linux
Architecture: i686
Machine: i686
>Description:
	bmake replace on non-installed package, sometimes is useful to alias
	replace->install when you'r mantaining software, By this way you don't have
	to check if a pkg is installed or not. bmake update can cause a lot of problems
	because it deinstalls a lot of packages (inverse deps)
	
>How-To-Repeat:
	defining UPDATE_TARGET=replace on mk.conf and applying this patch you can
	upgrade/install software just typiing "bmake update" without fear of loss
	half system
	
>Fix:
--- mk/bsd.pkg.mk.orig     2004-10-05 03:03:41.000000000 -0400
+++ mk/bsd.pkg.mk  2004-10-05 03:25:31.000000000 -0400
@@ -3257,11 +3257,16 @@
 
 .PHONY: do-su-replace
 do-su-replace:
-       @${ECHO_MSG} "${_PKGSRC_IN}> Replacing ${PKGNAME}"
+       @found="`${PKG_INFO} -e \"${PKGNAME}\" || ${TRUE}`"; \
+       case "$$found" in  \
+       "") realtarget="real-su-install"; action="install"; ${_SU_TARGET} ;; \
+       *) \
+       ${ECHO_MSG} "${_PKGSRC_IN}> Replacing ${PKGNAME}" \
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
        realtarget="real-su-replace";                                   \
        action="replace";                                               \
-       ${_SU_TARGET}
+       ${_SU_TARGET} ;\
+       esac
 
 .PHONY: do-su-undo-replace
 do-su-undo-replace:

	
>Release-Note:
>Audit-Trail:
>Unformatted: