From eikemeier@fillmore-labs.com  Mon Oct  6 10:25:36 2003
Return-Path: <eikemeier@fillmore-labs.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D57D716A4B3
	for <FreeBSD-gnats-submit@FreeBSD.org>; Mon,  6 Oct 2003 10:25:12 -0700 (PDT)
Received: from mx2.fillmore-labs.com (lima.fillmore-labs.com [62.138.193.83])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6950D43F93
	for <FreeBSD-gnats-submit@FreeBSD.org>; Mon,  6 Oct 2003 10:25:11 -0700 (PDT)
	(envelope-from eikemeier@fillmore-labs.com)
Received: from pd958a39d.dip.t-dialin.net
	([217.88.163.157] helo=fillmore-labs.com ident=33va3kvmtiwh2rof)
	by mx2.fillmore-labs.com with asmtp (TLSv1:AES256-SHA:256)
	(Exim 4.24; FreeBSD 4.9)
	id 1A6Z6c-0003ij-4D
	for FreeBSD-gnats-submit@FreeBSD.org; Mon, 06 Oct 2003 19:25:10 +0200
Message-Id: <3F81A574.80209@fillmore-labs.com>
Date: Mon, 06 Oct 2003 19:25:08 +0200
From: Oliver Eikemeier <eikemeier@fillmore-labs.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Subject: [PATCH] bsd.port.mk: LIB_DEPENDS should not use libraries in ${LOCALBASE}/lib/compat/pkg

>Number:         57653
>Category:       bin
>Synopsis:       [PATCH] bsd.port.mk: LIB_DEPENDS should not use libraries in ${LOCALBASE}/lib/compat/pkg
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 06 10:30:09 PDT 2003
>Closed-Date:    Mon Oct 06 13:16:38 PDT 2003
>Last-Modified:  Mon Oct 06 13:16:38 PDT 2003
>Originator:     Oliver Eikemeier
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
Fillmore Labs - http://www.fillmore-labs.com
>Environment:
System: FreeBSD nuuk.fillmore-labs.com 5.1-CURRENT

>Description:

When using port sysutils/portupgrade to manage port installation, it is possible
for stale libraries to end up in ${LOCALBASE}/lib/compat/pkg. Even though
portupgrade does its best to clean them up, they can persist when the library
changes its version number (libintl.so.4 => libintl.so.5), or the upgrade process
is interrupted by ctrl-C.

ldconfig -r (and bsd.port.mk) finds these libraries, assuming the whole port
needed for LIB_DEPENDS (including headers) is installed, which it isn't.

This patch aborts building if a needed library is found only in
${LOCALBASE}/lib/compat/pkg.

The initial bug report came from Thomas Fritz <tf@slash10.com>, thanks for the
help in tracking it down.

>How-To-Repeat:

# portinstall net/openldap21-client
[...]

# pkg_deinstall -P 'openldap-*'
[...]
--->  Preserving /usr/local/lib/libldap.so.2 as /usr/local/lib/compat/pkg/libldap.so.2
[...]

# portinstall net/openldap21-server
[...]
===>   openldap-server-2.1.22_2 depends on shared library: ldap.2 - found
[...]

# pkg_glob 'openldap-*'
Stale dependency: openldap-server-2.1.22_2 --> openldap-client-2.1.22 -- manually run 'pkgdb -F' to fix, or specify -O to force.

The usage of `pkg_deinstall -P' may seem artificial, but this is exactly the
command used by portupgrade if used without the `-u' option.

>Fix:

--- bsd.port.mk.patch begins here ---
--- bsd.port.mk.orig	3 Sep 2003 19:50:24 -0000
+++ bsd.port.mk	6 Oct 2003 16:51:09 -0000
@@ -1009,6 +1009,8 @@
 PREFIX?=		${LOCALBASE}
 .endif
 
+PKGCOMPATDIR?=		${LOCALBASE}/lib/compat/pkg
+
 .if !defined(PERL_LEVEL) && defined(PERL_VERSION)
 perl_major=		${PERL_VERSION:C|^([1-9]+).*|\1|}
 _perl_minor=	00${PERL_VERSION:C|^([1-9]+)\.([0-9]+).*|\2|}
@@ -3894,9 +3896,9 @@
 	@for i in ${LIB_DEPENDS}; do \
 		lib=$${i%%:*}; \
 		case $$lib in \
-			*.*.*)	pattern=$$lib ;;\
+			*.*.*)	pattern="`${ECHO_CMD} $$lib | ${SED} -e 's/\./\\./g'`" ;;\
 			*.*)	pattern="$${lib%%.*}\.$${lib#*.}" ;;\
-			*)		pattern=$$lib ;;\
+			*)		pattern="$$lib" ;;\
 		esac; \
 		dir=$${i#*:}; \
 		target=$${i##*:}; \
@@ -3941,6 +3943,11 @@
 					${FALSE}; \
 				fi; \
 			fi; \
+		fi; \
+		if ${LDCONFIG} -r | ${GREP} -wE -e "-l$$pattern" | ${HEAD} -n 1 | grep -qwF -e "${PKGCOMPATDIR}"; then \
+			${ECHO_MSG} "Error: stale library \"$$lib\" found in ${PKGCOMPATDIR}."; \
+			${ECHO_MSG} "Please clean out ${PKGCOMPATDIR} manually."; \
+			${FALSE}; \
 		fi; \
 	done
 .endif
--- bsd.port.mk.patch ends here ---


>Release-Note:
>Audit-Trail:

From: Oliver Eikemeier <eikemeier@fillmore-labs.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/57653: [PATCH] bsd.port.mk: LIB_DEPENDS should not use libraries
 in ${LOCALBASE}/lib/compat/pkg
Date: Mon, 06 Oct 2003 20:02:08 +0200

 Sorry, accidentially misfiled to category `bin',
 resubmitted to `ports' as PR 57665
 
 Please close this PR.
 
 
State-Changed-From-To: open->closed 
State-Changed-By: simon 
State-Changed-When: Mon Oct 6 13:15:22 PDT 2003 
State-Changed-Why:  
Closed at submitters request. 

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