Date: Sun, 17 Nov 2013 21:19:11 +0100 From: Matthias Andree <mandree@FreeBSD.org> To: FreeBSD-gnats-submit@freebsd.org Cc: portmgr@freebsd.org Subject: ports/184039: Mk/Scripts: fix working with blanks in filenames, handle missing variables Message-ID: <E1Vi8oJ-000C4k-Q3@apollo.emma.line.org> Resent-Message-ID: <201311172020.rAHKK0dt093612@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 184039 >Category: ports >Synopsis: Mk/Scripts: fix working with blanks in filenames, handle missing variables >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Nov 17 20:20:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Matthias Andree >Release: FreeBSD 9.2-RELEASE amd64 >Organization: >Environment: System: FreeBSD apollo.emma.line.org 9.2-RELEASE FreeBSD 9.2-RELEASE #4: Thu Oct 17 06:54:18 CEST 2013 root@apollo.emma.line.org:/usr/obj/usr/src/sys/GENERIC amd64 >Description: Request permission to commit the patch below. It fixes these issues: - in qa.sh, properly work with filenames containing blank or tab, by setting IFS to just LF - in check-stagedir.sh, properly detect unset environmental variables, and list them all - in check-stagedir.sh, also list the full prefix as known, not just its parents >How-To-Repeat: >Fix: Apply this patch in ports/Mk/Scripts/: Index: check-stagedir.sh =================================================================== --- check-stagedir.sh (revision 333870) +++ check-stagedir.sh (working copy) @@ -1,5 +1,6 @@ #!/bin/sh # ports/Mk/Scripts/check-stagedir.sh - called from ports/Mk/bsd.stage.mk +# $FreeBSD$ set -e export LC_ALL=C @@ -21,16 +22,17 @@ esac # validate environment -envfault=0 +envfault= for i in STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE \ TMPPLIST DATADIR DOCSDIR EXAMPLESDIR do - if eval test -z "\$$i" ; then - echo >&2 "Environment variable $i undefined. Aborting." - envfault=1 + if ! ( eval ": \${${i}?}" ) 2>/dev/null ; then + envfault="${envfault}${envfault:+" "}${i}" fi done -if [ $envfault -ne 0 ] ; then +if [ -n "$envfault" ] ; then + echo "Environment variables $envfault undefined. Aborting." \ + | fmt >&2 exit 1 fi @@ -85,9 +87,9 @@ a=${PREFIX} while :; do + echo ${a} a=${a%/*} [ -z "${a}" ] && break - echo ${a} done } > ${WRKDIR}/.mtree Index: qa.sh =================================================================== --- qa.sh (revision 333870) +++ qa.sh (working copy) @@ -7,6 +7,9 @@ exit 1 fi +LF=$(printf '\nX') +LF=${LF%X} + warn() { echo "Warning: $@" >&2 } @@ -17,7 +20,7 @@ shebang() { rc=0 - for f in `find ${STAGEDIR} -type f`; do + IFS="$LF" ; for f in `find ${STAGEDIR} -type f`; do interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p;2q' $f) case "$interp" in "") ;; @@ -37,7 +40,7 @@ symlinks() { rc=0 - for l in `find ${STAGEDIR} -type l`; do + IFS="$LF" ; for l in `find ${STAGEDIR} -type l`; do link=$(readlink ${l}) case "${link}" in ${STAGEDIR}*) err "Bad symlinks ${l} pointing inside the stage directory" @@ -50,7 +53,7 @@ paths() { rc=0 dirs="${STAGEDIR} ${WRKDIR}" - for f in `find ${STAGEDIR} -type f`;do + IFS="$LF" ; for f in `find ${STAGEDIR} -type f`;do for d in ${dirs}; do if grep -q ${d} ${f} ; then err "${f} is referring to ${d}" @@ -64,7 +67,7 @@ stripped() { [ -x /usr/bin/file ] || return # this is fatal [ -n "${STRIP}" ] || return 0 - for f in `find ${STAGEDIR} -type f`; do + IFS="$LF" ; for f in `find ${STAGEDIR} -type f`; do output=`/usr/bin/file ${f}` case "${output}" in *:*\ ELF\ *,\ not\ stripped*) warn "${f} is not stripped consider using \${STRIP_CMD}";; ### END OF PATCH ### >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1Vi8oJ-000C4k-Q3>