From vd@datamax.bg  Mon Sep 25 06:51:44 2006
Return-Path: <vd@datamax.bg>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1C23C16A403;
	Mon, 25 Sep 2006 06:51:44 +0000 (UTC)
	(envelope-from vd@datamax.bg)
Received: from jengal.datamax.bg (jengal.datamax.bg [82.103.104.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A62EA43D5F;
	Mon, 25 Sep 2006 06:51:43 +0000 (GMT)
	(envelope-from vd@datamax.bg)
Received: from qlovarnika.bg.datamax (qlovarnika.bg.datamax [192.168.10.2])
	by jengal.datamax.bg (Postfix) with SMTP id B58D8B844;
	Mon, 25 Sep 2006 09:51:42 +0300 (EEST)
Received: (nullmailer pid 83020 invoked by uid 1002);
	Mon, 25 Sep 2006 06:51:42 -0000
Message-Id: <20060925065142.GA82828@qlovarnika.bg.datamax>
Date: Mon, 25 Sep 2006 09:51:42 +0300
From: Vasil Dimov <vd@FreeBSD.org>
Reply-To: vd@FreeBSD.org
To: FreeBSD-gnats-submit@freebsd.org
Cc: portmgr@freebsd.org
Subject: [patch] bsd.port.mk: check-already-installed target does not catch old versions of installed packages
X-Send-Pr-Version: 3.113

>Number:         103606
>Category:       ports
>Synopsis:       [patch] bsd.port.mk: check-already-installed target does not catch old versions of installed packages
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 25 07:00:35 GMT 2006
>Closed-Date:    Wed Jan 31 16:14:02 GMT 2007
>Last-Modified:  Wed Jan 31 16:14:02 GMT 2007
>Originator:     Vasil Dimov
>Release:        FreeBSD 6.2-PRERELEASE amd64
>Organization:
N/A
>Environment:

>Description:

bsd.port.mk reads the following:

3783                                  if [ -n "$${df}" ]; then \
3784                                          found_package=$${p}; \
3785                                          break; \
3786                                  fi; \
3787                          fi; \
3788                  done; \
3789          fi ; \
3790          if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; the

Notice the shell started at line 3790 is different from the one which
sets $found_package and thus the variable contents is lost for the
test on 3790 line.

This results in new versions of packages being installed although
the old versions are not deinstalled (e.g. a compleat mess).

>How-To-Repeat:

/usr/ports/security/libgpg-error# make -V PKGNAME
libgpg-error-1.4
/usr/ports/security/libgpg-error# ls -ld /var/db/pkg/libgpg-error-1.3
drwxr-xr-x  2 root  wheel  512 Sep 23 02:46 /var/db/pkg/libgpg-error-1.3
/usr/ports/security/libgpg-error# make check-already-installed
===>  Checking if security/libgpg-error already installed
/usr/ports/security/libgpg-error# echo $?
0
/usr/ports/security/libgpg-error#

>Fix:

--- bsd.port.mk_check-already-installed.diff begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.543
diff -u -r1.543 bsd.port.mk
--- bsd.port.mk	20 Sep 2006 04:04:05 -0000	1.543
+++ bsd.port.mk	25 Sep 2006 06:37:47 -0000
@@ -3786,8 +3786,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 \
 					if [ -z "${DESTDIR}" ] ; then \
 						${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
--- bsd.port.mk_check-already-installed.diff ends here ---


-- 
Vasil Dimov
gro.DSBeerF@dv
%
The man who sets out to carry a cat by its tail learns something that
will always be useful and which never will grow dim or doubtful.
                -- Mark Twain
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Sep 25 07:00:49 UTC 2006 
Responsible-Changed-Why:  
bsd.port.mk is port manager territory 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103606 

From: Vasil Dimov <vd@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/103606: [patch] bsd.port.mk: check-already-installed target does not catch old versions of installed packages
Date: Wed, 18 Oct 2006 10:38:01 +0300

 On Mon, Sep 25, 2006 at 09:51:42AM +0300, Vasil Dimov wrote:
 [...]
 > >Synopsis:	[patch] bsd.port.mk: check-already-installed target does not catch old versions of installed packages
 > >Severity:	critical
 > >Priority:	high
 [...]
 > 
 > bsd.port.mk reads the following:
 > 
 > 3783                                  if [ -n "$${df}" ]; then \
 > 3784                                          found_package=$${p}; \
 > 3785                                          break; \
 > 3786                                  fi; \
 > 3787                          fi; \
 > 3788                  done; \
 > 3789          fi ; \
 > 3790          if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; the
 > 
 > Notice the shell started at line 3790 is different from the one which
 > sets $found_package and thus the variable contents is lost for the
 > test on 3790 line.
 > 
 [...]
 
 Sorry the above code is the fixed one, not the current one, please read
 as:
 
 3789          fi
 3790          @if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; the
 
 Or see the patch I sent - it is correct.
 
 -- 
 Vasil Dimov
 gro.DSBeerF@dv
 %
 The difference between life and the movies is that a script has to
 make sense, and life doesn't.
                 -- Joseph L. Mankiewicz
State-Changed-From-To: open->analyzed 
State-Changed-By: pav 
State-Changed-When: Tue Jan 23 20:01:03 UTC 2007 
State-Changed-Why:  
Accepted for a test build on the cluster. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103606 
State-Changed-From-To: analyzed->closed 
State-Changed-By: pav 
State-Changed-When: Wed Jan 31 16:13:52 UTC 2007 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103606 
>Unformatted:
