From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 20:59:24 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B55B1065677; Fri, 1 Apr 2011 20:59:24 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3BE088FC1A; Fri, 1 Apr 2011 20:59:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31KxO6c058933; Fri, 1 Apr 2011 20:59:24 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31KxOA0058931; Fri, 1 Apr 2011 20:59:24 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201104012059.p31KxOA0058931@svn.freebsd.org> From: Ulrich Spoerlein Date: Fri, 1 Apr 2011 20:59:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220255 - head X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 20:59:24 -0000 Author: uqs Date: Fri Apr 1 20:59:23 2011 New Revision: 220255 URL: http://svn.freebsd.org/changeset/base/220255 Log: Fix the delete-old/check-old targets to work with arbitrarily long OLD_FILES/OLD_DIRS/OLD_LIBS lists. If you specify enough WITHOUT_FOO flags, the argument list passed to the shell will be too long. Using .for/.endfor make(1) "loop" will make the parser of the Makefile explode. Hack around this with good old pipes. No objections: netchild Reported by: b.f. Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Apr 1 20:24:51 2011 (r220254) +++ head/Makefile.inc1 Fri Apr 1 20:59:23 2011 (r220255) @@ -1355,10 +1355,16 @@ delete-old-files: @echo ">>> Removing old files (only deletes safe to delete libs)" # Ask for every old file if the user really wants to remove it. # It's annoying, but better safe than sorry. - @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ +# NB: We cannot pass the list of OLD_FILES as a parameter because the +# argument list will get too long. Using .for/.endfor make "loops" will make +# the Makefile parser segfault. + @exec 3<&0; \ + ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ - rm ${RM_I} "${DESTDIR}/$${file}"; \ + rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done # Remove catpages without corresponding manpages. @@ -1368,14 +1374,16 @@ delete-old-files: while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ - rm ${RM_I} $${catpage} <&3 ; \ + rm ${RM_I} $${catpage} <&3; \ fi; \ done @echo ">>> Old files removed" check-old-files: @echo ">>> Checking for old files" - @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ @@ -1386,24 +1394,29 @@ check-old-files: while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ - echo $${catpage} ; \ + echo $${catpage}; \ fi; \ done delete-old-libs: @echo ">>> Removing old libraries" @echo "${OLD_LIBS_MESSAGE}" | fmt - @for file in ${OLD_LIBS}; do \ + @exec 3<&0; \ + ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_LIBS | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ - rm ${RM_I} "${DESTDIR}/$${file}"; \ + rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done @echo ">>> Old libraries removed" check-old-libs: @echo ">>> Checking for old libraries" - @for file in ${OLD_LIBS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_LIBS | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ @@ -1411,7 +1424,9 @@ check-old-libs: delete-old-dirs: @echo ">>> Removing old directories" - @for dir in ${OLD_DIRS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_DIRS | xargs -n1 | \ + while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ rmdir -v "${DESTDIR}/$${dir}" || true; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ @@ -1422,7 +1437,9 @@ delete-old-dirs: check-old-dirs: @echo ">>> Checking for old directories" - @for dir in ${OLD_DIRS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_DIRS | xargs -n1 | \ + while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ echo "${DESTDIR}/$${dir}"; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \