From owner-svn-ports-all@FreeBSD.ORG Thu Jan 8 04:04:56 2015 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AA610E85; Thu, 8 Jan 2015 04:04:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 96093FEE; Thu, 8 Jan 2015 04:04:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0844uFn011405; Thu, 8 Jan 2015 04:04:56 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0844uAD011403; Thu, 8 Jan 2015 04:04:56 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201501080404.t0844uAD011403@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Thu, 8 Jan 2015 04:04:56 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r376512 - head/Mk/Scripts X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2015 04:04:56 -0000 Author: bdrewery Date: Thu Jan 8 04:04:55 2015 New Revision: 376512 URL: https://svnweb.freebsd.org/changeset/ports/376512 QAT: https://qat.redports.org/buildarchive/r376512/ Log: - Move parse_plist() into a new file, functions.sh. With hat: portmgr Added: head/Mk/Scripts/functions.sh (contents, props changed) Modified: head/Mk/Scripts/check-stagedir.sh Modified: head/Mk/Scripts/check-stagedir.sh ============================================================================== --- head/Mk/Scripts/check-stagedir.sh Thu Jan 8 03:55:00 2015 (r376511) +++ head/Mk/Scripts/check-stagedir.sh Thu Jan 8 04:04:55 2015 (r376512) @@ -14,143 +14,7 @@ set -e export LC_ALL=C -#### EXPAND TMPPLIST TO ABSOLUTE PATHS, SPLITTING FILES AND DIRS TO -# Use file descriptors 1 and 3 so that the while loop can write -# files to the pipe and dirs to a separate file. -parse_plist() { - local cwd cwd_save commented_cwd comment line newcwd parse_comments - - parse_comments="${1:-1}" - - echo "===> Parsing plist" - cwd=${PREFIX} - cwd_save= - commented_cwd= - while read line; do - # Handle deactivated OPTIONS. Treat "@comment file" as being in - # the plist so it does not show up as an orphan. PLIST_SUB uses - # a @comment to deactive files. XXX: It would be better to - # make all ports use @ignore instead of @comment. - comment= - if [ ${parse_comments} -eq 1 -a -z "${line%%@comment *}" ]; then - line="${line##*@comment }" - # Remove @comment so it can be parsed as a file, - # but later prepend it again to create a list of - # all files commented and uncommented. - comment="@comment " - # Only consider comment @cwd for commented lines - if [ -n "${commented_cwd}" ]; then - [ -z "${cwd_save}" ] && cwd_save=${cwd} - cwd=${commented_cwd} - fi - else - # On first uncommented line, forget about commented - # @cwd - if [ -n "${cwd_save}" ]; then - cwd=${cwd_save} - cwd_save= - commented_cwd= - fi - fi - - # Strip (owner,group,perm) from keywords - line="$(printf %s "$line" \ - | sed -Ee 's/^@\([^)]*\)[[:space:]]+//' \ - -e 's/^(@[[:alpha:]]+)\([^)]*\)[[:space:]]+/\1 /')" - case $line in - @dir*|'@unexec rmdir'*|'@unexec /bin/rmdir'*) - line="$(printf %s "$line" \ - | sed -Ee 's/\|\|.*//;s|[[:space:]]+[0-9]*[[:space:]]*>[&]?[[:space:]]*[^[:space:]]+||g' \ - -e "/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|([^%])%D([^%])|\1${cwd}\2|g" \ - -e '/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|"(.*)"[[:space:]]*|\1|g' \ - -e 's/@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?[[:space:]]+//' \ - -e 's/@dir(rm|rmtry)?[[:space:]]+//' \ - -e 's/[[:space:]]+$//')" - case "$line" in - /*) echo >&3 "${comment}${line%/}" ;; - *) echo >&3 "${comment}${cwd}/${line%/}" ;; - esac - ;; - # Handle [file] Keywords - @info\ *|@shell\ *) - set -- $line - shift - case "$@" in - /*) echo "${comment}$@" ;; - *) echo "${comment}${cwd}/$@" ;; - esac - ;; - @sample\ *) - set -- $line - shift - # Ignore the actual file if it is in stagedir - case "$@" in - /*) - echo "@comment ${@%.sample}" - echo "${comment}$@" - ;; - *) - echo "@comment ${cwd}/${@%.sample}" - echo "${comment}${cwd}/$@" - ;; - esac - ;; - # Handle [dir] Keywords - @fc\ *|@fcfontsdir\ *|@fontsdir\ *) - set -- $line - shift - case "$@" in - /*) - echo >&3 "${comment}$@" - ;; - *) - echo >&3 "${comment}${cwd}/$@" - ;; - esac - ;; - - # order matters here - we must check @cwd first because - # otherwise the @cwd* would also match it first, shadowing the - # @cwd) line. - @cwd|@cd) - # Don't actually reset cwd for commented @cwd - if [ -n "${comment}" ]; then - commented_cwd=${PREFIX} - else - cwd=${PREFIX} - fi - ;; - @cwd*|@cd*) - set -- $line - newcwd=$2 - # Don't set cwd=/ as it causes // in plist and - # won't match later. - [ "${newcwd}" = "/" ] && newcwd= - # Don't actually reset cwd for commented @cwd - if [ -n "${comment}" ]; then - commented_cwd=${newcwd} - else - cwd=${newcwd} - fi - unset newcwd - ;; - @*) ;; - /*) echo "${comment}${line}" ;; - *) echo "${comment}${cwd}/${line}" ;; - esac - done < ${TMPPLIST} 3>${WRKDIR}/.plist-dirs-unsorted \ - >${WRKDIR}/.plist-files-unsorted - unset TMPPLIST - # Create the -no-comments files and trim out @comment from the plists. - # This is used for various tests later. - sed -e '/^@comment/d' ${WRKDIR}/.plist-dirs-unsorted \ - >${WRKDIR}/.plist-dirs-unsorted-no-comments - sed -i '' -e 's/^@comment //' ${WRKDIR}/.plist-dirs-unsorted - sed -e '/^@comment/d' ${WRKDIR}/.plist-files-unsorted | sort \ - >${WRKDIR}/.plist-files-no-comments - sed -e 's/^@comment //' ${WRKDIR}/.plist-files-unsorted | sort \ - >${WRKDIR}/.plist-files -} +. ${SCRIPTSDIR}/functions.sh # lists an mtree file's contents, prefixed to dir. listmtree() { # mtreefile prefix @@ -378,7 +242,20 @@ fi set -u if [ $makeplist = 0 ] ; then - parse_plist + echo "===> Parsing plist" + parse_plist "${PREFIX}" 1 < ${TMPPLIST} \ + 3>${WRKDIR}/.plist-dirs-unsorted \ + >${WRKDIR}/.plist-files-unsorted + unset TMPPLIST + # Create the -no-comments files and trim out @comment from the plists. + # This is used for various tests later. + sed -e '/^@comment/d' ${WRKDIR}/.plist-dirs-unsorted \ + >${WRKDIR}/.plist-dirs-unsorted-no-comments + sed -i '' -e 's/^@comment //' ${WRKDIR}/.plist-dirs-unsorted + sed -e '/^@comment/d' ${WRKDIR}/.plist-files-unsorted | sort \ + >${WRKDIR}/.plist-files-no-comments + sed -e 's/^@comment //' ${WRKDIR}/.plist-files-unsorted | sort \ + >${WRKDIR}/.plist-files else # generate plist - pretend the plist had been empty : >${WRKDIR}/.plist-dirs-unsorted Added: head/Mk/Scripts/functions.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/Mk/Scripts/functions.sh Thu Jan 8 04:04:55 2015 (r376512) @@ -0,0 +1,141 @@ +#!/bin/sh +# $FreeBSD$ +# This file for common functions used for port scripts. +# +# MAINTAINER: portmgr@FreeBSD.org + +# Expand TMPPLIST to absolute paths, splitting files and dirs into separate +# descriptors. +# Input: +# fd:0 - plist to parse +# Required params: +# PREFIX +# parse_comments: Whether to parse and include commented files. +# Output: +# fd:1 - list of files +# fd:2 - stderr +# fd:3 - list of directories +parse_plist() { + local cwd cwd_save commented_cwd comment line newcwd parse_comments \ + PREFIX + + PREFIX="${1}" + parse_comments="${2:-1}" + + cwd=${PREFIX} + cwd_save= + commented_cwd= + while read line; do + # Handle deactivated OPTIONS. Treat "@comment file" as being in + # the plist so it does not show up as an orphan. PLIST_SUB uses + # a @comment to deactive files. XXX: It would be better to + # make all ports use @ignore instead of @comment. + if [ ${parse_comments} -eq 1 -a -z "${line%%@comment *}" ]; then + line="${line##*@comment }" + # Remove @comment so it can be parsed as a file, + # but later prepend it again to create a list of + # all files commented and uncommented. + comment="@comment " + # Only consider comment @cwd for commented lines + if [ -n "${commented_cwd}" ]; then + [ -z "${cwd_save}" ] && cwd_save=${cwd} + cwd=${commented_cwd} + fi + else + comment= + # On first uncommented line, forget about commented + # @cwd + if [ -n "${cwd_save}" ]; then + cwd=${cwd_save} + cwd_save= + commented_cwd= + fi + fi + + # Strip (owner,group,perm) from keywords + line="$(printf %s "$line" \ + | sed -Ee 's/^@\([^)]*\)[[:space:]]+//' \ + -e 's/^(@[[:alpha:]]+)\([^)]*\)[[:space:]]+/\1 /')" + case $line in + @dir*|'@unexec rmdir'*|'@unexec /bin/rmdir'*) + line="$(printf %s "$line" \ + | sed -Ee 's/\|\|.*//;s|[[:space:]]+[0-9]*[[:space:]]*>[&]?[[:space:]]*[^[:space:]]+||g' \ + -e "/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|([^%])%D([^%])|\1${cwd}\2|g" \ + -e '/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|"(.*)"[[:space:]]*|\1|g' \ + -e 's/@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?[[:space:]]+//' \ + -e 's/@dir(rm|rmtry)?[[:space:]]+//' \ + -e 's/[[:space:]]+$//')" + case "$line" in + /*) echo >&3 "${comment}${line%/}" ;; + *) echo >&3 "${comment}${cwd}/${line%/}" ;; + esac + ;; + # Handle [file] Keywords + @info\ *|@shell\ *) + set -- $line + shift + case "$@" in + /*) echo "${comment}$@" ;; + *) echo "${comment}${cwd}/$@" ;; + esac + ;; + @sample\ *) + set -- $line + shift + # Ignore the actual file if it is in stagedir + case "$@" in + /*) + echo "@comment ${@%.sample}" + echo "${comment}$@" + ;; + *) + echo "@comment ${cwd}/${@%.sample}" + echo "${comment}${cwd}/$@" + ;; + esac + ;; + # Handle [dir] Keywords + @fc\ *|@fcfontsdir\ *|@fontsdir\ *) + set -- $line + shift + case "$@" in + /*) + echo >&3 "${comment}$@" + ;; + *) + echo >&3 "${comment}${cwd}/$@" + ;; + esac + ;; + + # order matters here - we must check @cwd first because + # otherwise the @cwd* would also match it first, shadowing the + # @cwd) line. + @cwd|@cd) + # Don't actually reset cwd for commented @cwd + if [ -n "${comment}" ]; then + commented_cwd=${PREFIX} + else + cwd=${PREFIX} + fi + ;; + @cwd*|@cd*) + set -- $line + newcwd=$2 + # Don't set cwd=/ as it causes // in plist and + # won't match later. + [ "${newcwd}" = "/" ] && newcwd= + # Don't actually reset cwd for commented @cwd + if [ -n "${comment}" ]; then + commented_cwd=${newcwd} + else + cwd=${newcwd} + fi + unset newcwd + ;; + @*) ;; + /*) echo "${comment}${line}" ;; + *) echo "${comment}${cwd}/${line}" ;; + esac + done +}