Subject: pkg/5549: DEPENDS and pre-existence check broken in pkgsrc
To: None <gnats-bugs@gnats.netbsd.org>
From: Charlie Root <root@polaris.garbled.net>
List: netbsd-bugs
Date: 06/06/1998 11:28:54
>Number:         5549
>Category:       pkg
>Synopsis:       DEPENDS and pre-existence check broken in pkgsrc
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun  6 11:20:01 1998
>Last-Modified:
>Originator:     Charlie Root
>Organization:
Tim Rightnour    -  root@garbled.net
http://www.zynetwc.com/~garbled/garbled.html
>Release:        05-28-1998 (date of pkgsrc)<NetBSD-current source date>
>Environment:
	
System: NetBSD polaris 1.3 NetBSD 1.3 (POLARIS) #0: Thu Mar 26 13:17:18 MST 1998 root@polaris:/usr/src/sys/arch/i386/compile/POLARIS i386


>Description:
Was typing make extract in the gmake dir to prepare it for an NFS build 
on my alpha, I allready have gmake and gtexinfo on my i386 box.  it goes, 
builds the gtexinfo pkg, which seemed a bit strange to me.. installed 
it.. and whalla:

pkg_info
gtexinfo-3.11       GNU info file manipulation utilities. 
gtexinfo-3.12       GNU info file manipulation utilities. 

Just what I allways wanted.. two.

	
>How-To-Repeat:

Install an older gtexinfo pkg, then ask to install a new one.. It will 
gleefully do both.

Additionally, it will make it nearly impossible to delete either of them 
with the tools, because now files exist that didn't before, and recursive 
deletes fail.  Grumble and remove everything manually.

	
>Fix:

the diff beflow is against a 05-28-1998 pkgsrc.. So it will have some 
fuzz against the current, but the relevant sections are the same.
This checks if the *root* of the pkg name is installed.. ie instead of 
checking for gtexinfo-3.12 it looks for "gtexinfo".  The second grep in the 
patch is just a convenience to the user, to tell them what version they 
have, when make install explodes.

*** bsd.pkg.mk.orig	Sat Jun  6 09:05:26 1998
--- bsd.pkg.mk	Sat Jun  6 11:19:05 1998
***************
*** 1286,1291 ****
  .if make(real-install)
  .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
! 	@if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
  		${ECHO_MSG} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
  		${ECHO_MSG} "      If so, you may wish to \`\`${MAKE} deinstall'' and install"; \
  		${ECHO_MSG} "      this port again by \`\`${MAKE} reinstall'' to upgrade it properly."; \
--- 1286,1294 ----
  .if make(real-install)
  .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
! 	@pname=`${ECHO} ${PKGNAME} | ${SED} -e 's/[-.0-9].*//'` ; \
! 	if /usr/sbin/pkg_info | grep $$pname >/dev/null; then \
  		${ECHO_MSG} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
+ 		${ECHO} -n  "      ";\
+ 		/usr/sbin/pkg_info | grep $$pname ;\
  		${ECHO_MSG} "      If so, you may wish to \`\`${MAKE} deinstall'' and install"; \
  		${ECHO_MSG} "      this port again by \`\`${MAKE} reinstall'' to upgrade it properly."; \
***************
*** 1809,1815 ****
  .if !defined(NO_DEPENDS)
  	@for dir in ${DEPENDS}; do					\
! 		package=`${ECHO} $$dir | ${SED} -e 's/:.*//'`;		\
  		dir=`${ECHO} $$dir | ${SED} -e 's/.*://'`;		\
! 		if /usr/sbin/pkg_info -e $$package; then		\
  			${ECHO_MSG} "===>  ${PKGNAME} depends on: installed package $$package";	\
  		else							\
--- 1812,1818 ----
  .if !defined(NO_DEPENDS)
  	@for dir in ${DEPENDS}; do					\
! 		package=`${ECHO} $$dir | ${SED} -e 's/[-.0-9].*//'`;		\
  		dir=`${ECHO} $$dir | ${SED} -e 's/.*://'`;		\
! 		if /usr/sbin/pkg_info | grep $$package; then		\
  			${ECHO_MSG} "===>  ${PKGNAME} depends on: installed package $$package";	\
  		else							\



	
>Audit-Trail:
>Unformatted: