From eikemeier@fillmore-labs.com  Wed Sep  3 17:57:24 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 B017A16A4BF
	for <FreeBSD-gnats-submit@FreeBSD.org>; Wed,  3 Sep 2003 17:57:24 -0700 (PDT)
Received: from mx2.fillmore-labs.com (lima.fillmore-labs.com [62.138.193.83])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7792143FBF
	for <FreeBSD-gnats-submit@FreeBSD.org>; Wed,  3 Sep 2003 17:57:22 -0700 (PDT)
	(envelope-from eikemeier@fillmore-labs.com)
Received: from pd958afb7.dip.t-dialin.net
	([217.88.175.183] helo=fillmore-labs.com ident=rnk330k1o4lqb63u)
	by mx2.fillmore-labs.com with asmtp (TLSv1:AES256-SHA:256)
	(Exim 4.22)
	id 19uiR6-000DUw-Vy
	for FreeBSD-gnats-submit@FreeBSD.org; Thu, 04 Sep 2003 02:57:21 +0200
Message-Id: <3F568DEC.4000403@fillmore-labs.com>
Date: Thu, 04 Sep 2003 02:57:16 +0200
From: Oliver Eikemeier <eikemeier@fillmore-labs.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Subject: [PATCH] port sysutils/pkg_install: fix `make deinstall' and compilation
 on systems <= 4.4

>Number:         56389
>Category:       ports
>Synopsis:       [PATCH] port sysutils/pkg_install: fix `make deinstall' and compilation on systems <= 4.4
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 03 18:00:33 PDT 2003
>Closed-Date:    Sat Jun 19 20:45:49 GMT 2004
>Last-Modified:  Sat Jun 19 20:45:49 GMT 2004
>Originator:     Oliver Eikemeier
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
Fillmore Labs - http://www.fillmore-labs.com
>Environment:
System: FreeBSD nuuk.fillmore-labs.com 4.8-STABLE

>Description:

- fix compilation on systems <= 4.4 (PR ports/56324)
  PERL is in the base system on those systems, REINPLACE_CMD not

- enable `make deinstall' of this port or other ports if this port
  is not installed

- use pkg_info from the port if it is installed on all systems
  (enables 4.7 users to use conflict checking)

- package does not change, so no PORTREVISION bump.

It does not address problems with PACKAGE-DEPENDS-LIST if the
port is not installed, but hey, leave the port in place or
upgrade your system.

>How-To-Repeat:
>Fix:

--- pkg_install.patch begins here ---
--- sysutils/pkg_install/Makefile.orig	Tue Sep  2 04:07:22 2003
+++ sysutils/pkg_install/Makefile	Thu Sep  4 02:38:55 2003
@@ -24,34 +24,15 @@
 
 .include <bsd.port.pre.mk>
 
-.if ${OSVERSION} < 460102
-check-already-installed:
-.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
-	@if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
-		${ECHO_CMD} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
-		${ECHO_CMD} "      If so, you may wish to \`\`make deinstall'' and install"; \
-		${ECHO_CMD} "      this port again by \`\`make reinstall'' to upgrade it properly."; \
-		${ECHO_CMD} "      If you really wish to overwrite the old port of ${PKGNAME}"; \
-		${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
-.else
-	@${DO_NADA}
-.endif
+.if ${OSVERSION} < 440001 || ( ${OSVERSION} >= 500000 && ${OSVERSION} < 500024 )
+post-patch:
+	@${FIND} ${WRKSRC} -name '*.c' \
+		| ${XARGS} ${PERL} -pi.orig -e 's/__FBSDID\(("[^"]*")\)/static const char rcsid[] = $$1/'
 .endif
 
 pre-configure:
 	@${SED} -e 's,%%PREFIX%%,${PREFIX},g' \
 		-e 's,%%MANPREFIX%%,${MANPREFIX},g' \
 		${FILESDIR}/Makefile.inc > ${WRKDIR}/Makefile.inc
-
-deinstall:
-	@if ${PKG_INFO} -e ${PKGNAME}; then \
-		${PKG_DELETE} -f ${PKGNAME}; \
-	else \
-		${ECHO_MSG} "===> ${PKGNAME} not installed; skipping"; \
-	fi
-	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 
 .include <bsd.port.post.mk>
--- pkg_install.patch ends here ---

--- bsd.port.mk.patch begins here ---
--- /usr/ports/Mk/bsd.port.mk.orig	Thu Sep  4 02:05:03 2003
+++ /usr/ports/Mk/bsd.port.mk	Thu Sep  4 02:30:48 2003
@@ -1,7 +1,7 @@
 #-*- mode: makefile; tab-width: 4; -*-
 # ex:ts=4
 #
-# $FreeBSD: ports/Mk/bsd.port.mk,v 1.468 2003/09/03 19:50:24 obrien Exp $
+# $FreeBSD: ports/Mk/bsd.port.mk,v 1.466 2003/08/29 02:26:02 marcus Exp $
 #	$NetBSD: $
 #
 #	bsd.port.mk - 940820 Jordan K. Hubbard.
@@ -1777,24 +1777,26 @@
 PKGORIGIN?=		${PKGCATEGORY}/${PORTDIRNAME}
 .endif
 
-.if ${OSVERSION} < 460102 && ${PKGORIGIN} != "sysutils/pkg_install"
+.if (${OSVERSION} < 460102 || ( ${OSVERSION} >= 500000 && ${OSVERSION} < 500035 )) && ${PKGORIGIN} != "sysutils/pkg_install"
 BUILD_DEPENDS+=	${LOCALBASE}/sbin/pkg_info:${PORTSDIR}/sysutils/pkg_install
+.endif
+
 .if exists(${LOCALBASE}/sbin/pkg_info)
 PKG_CMD?=		${LOCALBASE}/sbin/pkg_create
 PKG_ADD?=		${LOCALBASE}/sbin/pkg_add
-PKG_DELETE?=	${LOCALBASE}/sbin/pkg_delete
+PKG_DELETE?=		${LOCALBASE}/sbin/pkg_delete
 PKG_INFO?=		${LOCALBASE}/sbin/pkg_info
 .else
 PKG_CMD?=		/usr/sbin/pkg_create
 PKG_ADD?=		/usr/sbin/pkg_add
-PKG_DELETE?=	/usr/sbin/pkg_delete
+PKG_DELETE?=		/usr/sbin/pkg_delete
 PKG_INFO?=		/usr/sbin/pkg_info
 .endif
-.else
-PKG_CMD?=		/usr/sbin/pkg_create
-PKG_ADD?=		/usr/sbin/pkg_add
-PKG_DELETE?=	/usr/sbin/pkg_delete
-PKG_INFO?=		/usr/sbin/pkg_info
+
+# Does pkg_info support listing all packages with the same origin?
+_ORIGIN_FAILED!=	${PKG_INFO} -q -O "sysutils/portupgrade" >/dev/null 2>&1 || ${ECHO_CMD} YES
+.if ${_ORIGIN_FAILED:U} == YES
+DISABLE_ORIGIN=		YES
 .endif
 
 # Does the pkg_create tool support conflict checking?
@@ -3108,6 +3110,7 @@
 .if !target(check-already-installed)
 check-already-installed:
 .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
+.if !defined(DISABLE_ORIGIN)
 		@${ECHO_MSG} "===>  Checking if ${PKGORIGIN} already installed"
 		@${MKDIR} ${PKG_DBDIR}
 		@already_installed=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
@@ -3122,7 +3125,8 @@
 								fi; \
 						fi; \
 				done; \
-		fi; \
+		fi
+.endif
 		if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
 				if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
 						${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
@@ -3504,6 +3508,7 @@
 
 .if !target(deinstall)
 deinstall:
+.if !defined(DISABLE_ORIGIN)
 	@${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN}"
 	@found_names=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
 	for p in $${found_names}; do \
@@ -3521,6 +3526,14 @@
 	if [ -z "$${found_names}" ]; then \
 			${ECHO_MSG} "===>   ${PKGBASE} not installed, skipping"; \
 	fi
+.else
+	@${ECHO_MSG} "===>  Deinstalling for ${PKGNAME}"
+	@if ${PKG_INFO} -e ${PKGNAME}; then \
+		${PKG_DELETE} -f ${PKGNAME}; \
+	else \
+		${ECHO_MSG} "===>   ${PKGNAME} not installed, skipping"; \
+	fi
+.endif
 	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
 
--- bsd.port.mk.patch ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: marcus 
Responsible-Changed-When: Wed Sep 3 20:42:17 PDT 2003 
Responsible-Changed-Why:  
This is portmgr's area. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=56389 
State-Changed-From-To: open->analyzed 
State-Changed-By: marcus 
State-Changed-When: Wed Sep 3 20:42:40 PDT 2003 
State-Changed-Why:  
I've committed the pkg_install Perl hack, but I want to think about the  
bsd.port.mk stuff as well as test what needs to be tested on bento after 
4.9 is released. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=56389 
State-Changed-From-To: analyzed->closed 
State-Changed-By: marcus 
State-Changed-When: Sat Jun 19 20:43:56 GMT 2004 
State-Changed-Why:  
Closing this port since this fix would add a call to pkg_info in the default 
case, thus reducing performance.  Plus, we really need to draw the line 
somewhere as to what versions of FreeBSD we will continue to support with 
the ports tree.  Supporting only the versions supported by re@ and/or 
so@ are probably a good enough. 

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