Date: Tue, 04 Oct 2011 23:07:23 +0200 From: Matthias Andree <mandree@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Cc: portmgr@FreeBSD.org Subject: ports/161287: [PATCH] Mk/bsd.port.mk: fix check-already-installed target Message-ID: <E1RBCCx-000EHv-Tu@apollo.emma.line.org> Resent-Message-ID: <201110042110.p94LA7BJ068762@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1RBCCx-000EHv-Tu>