Bug 55616

Summary: Bugg in bsd.port.mk causes installed packages to be missed
Product: Ports & Packages Reporter: mats
Component: Individual Port(s)Assignee: Port Management Team <portmgr>
Status: Closed FIXED    
Severity: Affects Only Me CC: mats
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
check_fix.patch none

Description mats 2003-08-15 22:40:14 UTC
        
	Code in ports/Mk/bsd.port.mk (ports/Mk/bsd.port.mk,v 1.461) is
	meant to prevent a newer version of a package to be installed
	if an older is already installed. If, say, unzip-5.50
	(archivers/unzip) is  installed, it should not be possible to
	install unzip-5.50_2 (archivers/unzip) without being warned.

	The code starts on line 3006 with target
	"check-already-installed". Between lines 3009 and 3022 the
	installed package is captured and set in the variable
	"found_package". This part of the code is only done for
	OSVERSION > 460102.

	If the packed is already installed package, code on lines 3024
	to 3036 is meant to return an error message. There are two
	cases, the package is installed with the same version or the
	package is installed with an older version. The first case
	works, but not the second.

Fix: 

The control variable "found_package" is set on line 3017
	("found_package=$${p}") and tested on line 3024. The setting
	of the variable is correct, but it does not survive to line
	3024. I guess that the environment varible scope does not
	extend that far. Is the code run in a forked environment?

	I do not how to make the variable survive.


Lines 3008 ti 3036 from the file:


.if ${OSVERSION} >= 460102
  @${ECHO_MSG} "===>  Checking if ${PKGORIGIN} already installed"
  @already_installed=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
  if [ -n "$${already_installed}" ]; then \
    for p in $${already_installed}; do \
    prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${HEAD} -n 1 | ${SED} -ne '1s|^@cwd ||p'`; \
    if [ "x${PREFIX}" = "x$${prfx}" ]; then \
      df=`${PKG_INFO} -q -f $${p} 2> /dev/null | ${GREP} -v "^@" | ${COMM} -12 - ${TMPPLIST}`; \
      if [ -n "$${df}" ]; then \
        found_package=$${p}; \
        break; \
      fi; \
    fi; \
    done; \
  fi;
.endif
  @if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
    if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
      ${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
    else \
      ${ECHO_CMD} "===>   An older version of ${PKGORIGIN} is already installed ($${found_package})"; \
    fi; \
    ${ECHO_CMD} "      You may wish to \`\`make deinstall'' and install this port again"; \
    ${ECHO_CMD} "      by \`\`make reinstall'' to upgrade it properly."; \
    ${ECHO_CMD} "      If you really wish to overwrite the old port of ${PKGORIGIN}"; \
    ${ECHO_CMD} "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
    ${ECHO_CMD} "      in your environment or the \"make install\" command line."; \
    exit 1; \
  fi
How-To-Repeat: 
	Try to do "make install" on a package in the ports tree, which
	already is installed, but with an older version.
Comment 1 Joe Marcus Clarke freebsd_committer freebsd_triage 2003-08-16 04:01:32 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

Over to maintainers.
Comment 2 Joe Marcus Clarke freebsd_committer freebsd_triage 2003-08-16 04:01:47 UTC
State Changed
From-To: open->feedback

I believe this is fixed in revision 1.462 of bsd.port.mk.  Can you cvsup 
your ports tree, and let me know?  Thanks.
Comment 3 Sergey Matveychuk 2003-08-16 23:37:28 UTC
Thanks for reporting.
A patch is bellow.

----
Sem.
Comment 4 Joe Marcus Clarke freebsd_committer freebsd_triage 2003-08-16 23:41:02 UTC
On Sat, 2003-08-16 at 18:37, Sergey Matveychuk wrote:
> Thanks for reporting.
> A patch is bellow.


This is the same patch Mats submitted to me earlier :-).  I agree, this
looks like the fix.

Joe

> 
> ----
> Sem.
> 
> ______________________________________________________________________
> --- bsd.port.mk.local	Sun Aug 17 00:42:37 2003
> +++ bsd.port.mk	Sun Aug 17 02:12:06 2003
> @@ -2939,8 +2939,8 @@
>  								fi; \
>  						fi; \
>  				done; \
> -		fi;
> -		@if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
> +		fi; \
> +		if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
>  				if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
>  						${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
>  				else \

-- 
Joe Marcus Clarke
FreeBSD GNOME Team	::	gnome@FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome
Comment 5 Joe Marcus Clarke freebsd_committer freebsd_triage 2003-08-17 19:48:49 UTC
State Changed
From-To: feedback->analyzed

Patch being tested on bento.
Comment 6 Joe Marcus Clarke freebsd_committer freebsd_triage 2003-08-27 05:48:25 UTC
State Changed
From-To: analyzed->closed

Committed, thanks!