From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Oct 4 21:10:08 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07F261065673 for ; Tue, 4 Oct 2011 21:10:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id DFE3D8FC1A for ; Tue, 4 Oct 2011 21:10:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p94LA7Pg068764 for ; Tue, 4 Oct 2011 21:10:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p94LA7BJ068762; Tue, 4 Oct 2011 21:10:07 GMT (envelope-from gnats) Resent-Date: Tue, 4 Oct 2011 21:10:07 GMT Resent-Message-Id: <201110042110.p94LA7BJ068762@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Matthias Andree Received: from apollo.emma.line.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id D0631106564A; Tue, 4 Oct 2011 21:07:24 +0000 (UTC) (envelope-from mandree@FreeBSD.org) Received: from mandree by apollo.emma.line.org with local (Exim 4.76 (FreeBSD)) (envelope-from ) id 1RBCCx-000EHv-Tu; Tue, 04 Oct 2011 23:07:23 +0200 Message-Id: Date: Tue, 04 Oct 2011 23:07:23 +0200 From: Matthias Andree To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: portmgr@FreeBSD.org Subject: ports/161287: [PATCH] Mk/bsd.port.mk: fix check-already-installed target X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthias Andree List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 21:10:08 -0000 >Number: 161287 >Category: ports >Synopsis: [PATCH] Mk/bsd.port.mk: fix check-already-installed target >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Oct 04 21:10:07 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Matthias Andree >Release: FreeBSD 8.2-STABLE amd64 >Organization: >Environment: System: FreeBSD apollo.emma.line.org 8.2-STABLE FreeBSD 8.2-STABLE #18: Wed Sep 28 22:02:18 CEST 2011 toor@apollo.emma.line.org:/usr/obj/usr/src/sys/GENERIC amd64 >Description: The bsd.port.mk "check-already-installed" target has two bugs that jeopardize the effectiveness. The current version fails to detect security/openvpn-devel updates, as noted by Eric F. Crist. The reason is that the freshly generated ${TMPPLIST} and the pkg-plist of the previously installed same-origin same-prefix port are compared in an inadequate way: - the plists aren't sorted, which, however, is a requisite for comm to work properly. - TMPPLIST doesn't get lines starting with @ removed While plists are more-or-less sorted already along a porter's handbook recommendation in chapter 3, with the automatic addition of various other lines to the TMPPLIST, the assumption "plist is sorted" no longer holds - especially in context with the LICENSE framework which adds files up front into PORTVERSIONed directories. Fix this by: - factoring out the normalization code - identically normalizing package lists - only then feeding them to the comm(1) command. The patch below has been lightly tested and corrects the problem for security/openvpn-devel and does not regress on news/leafnode. >How-To-Repeat: >Fix: Index: Mk/bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.696 diff -u -r1.696 bsd.port.mk --- Mk/bsd.port.mk 23 Sep 2011 22:20:46 -0000 1.696 +++ Mk/bsd.port.mk 4 Oct 2011 20:57:42 -0000 @@ -3940,6 +3940,7 @@ # Utility targets follow .if !target(check-already-installed) +_normalize_c_a_i_plists:= ${GREP} -v "^@" | ${SORT} check-already-installed: .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER) @${ECHO_MSG} "===> Checking if ${PKGORIGIN} already installed"; \ @@ -3949,7 +3950,9 @@ for p in $${already_installed}; do \ prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${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}`; \ + ${CAT} ${TMPPLIST} | ${_normalize_c_a_i_plists} >${TMPPLIST}.sorted; \ + df=`${PKG_INFO} -q -f $${p} 2> /dev/null | ${_normalize_c_a_i_plists} | ${COMM} -12 - ${TMPPLIST}.sorted`; \ + ${RM} -f ${TMPPLIST}.sorted; \ if [ -n "$${df}" ]; then \ found_package=$${p}; \ break; \ >Release-Note: >Audit-Trail: >Unformatted: