Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Apr 2014 20:48:04 +0000 (UTC)
From:      Antoine Brodin <antoine@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r351132 - head/Mk/Scripts
Message-ID:  <201404122048.s3CKm4l7034694@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: antoine
Date: Sat Apr 12 20:48:04 2014
New Revision: 351132
URL: http://svnweb.freebsd.org/changeset/ports/351132
QAT: https://qat.redports.org/buildarchive/r351132/

Log:
  Reduce the number of false positives reported by the shebang qa check
  by looking only at files and symlinks in bin, sbin and libexec
  
  Reviewed by:	bdrewery
  With hat:	portmgr

Modified:
  head/Mk/Scripts/qa.sh

Modified: head/Mk/Scripts/qa.sh
==============================================================================
--- head/Mk/Scripts/qa.sh	Sat Apr 12 20:38:39 2014	(r351131)
+++ head/Mk/Scripts/qa.sh	Sat Apr 12 20:48:04 2014	(r351132)
@@ -18,30 +18,56 @@ err() {
 	echo "Error: $@" >&2
 }
 
+shebangonefile() {
+	local f interp rc
+
+	f="$@"
+	rc=0
+	interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p;2q' "$f")
+	case "$interp" in
+	"") ;;
+	/usr/bin/env) ;;
+	${LOCALBASE}/*) ;;
+	${PREFIX}/*) ;;
+	/usr/bin/awk) ;;
+	/usr/bin/sed) ;;
+	/usr/bin/nawk) ;;
+	/bin/csh) ;;
+	/bin/sh) ;;
+	*)
+		err "${interp} is an invalid shebang you need USES=shebangfix for ${f#${STAGEDIR}${PREFIX}/}"
+		rc=1
+		;;
+	esac
+
+	return ${rc}
+}
+
 shebang() {
-	local IFS rc
+	local f l link rc
 
 	rc=0
-	IFS="$LF"
 	
-	for f in `find ${STAGEDIR} -type f -perm +111`; do
-		interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p;2q' $f)
-		case "$interp" in
-		"") ;;
-		/usr/bin/env) ;;
-		${LOCALBASE}/*) ;;
-		${PREFIX}/*) ;;
-		/usr/bin/awk) ;;
-		/usr/bin/sed) ;;
-		/usr/bin/nawk) ;;
-		/bin/csh) ;;
-		/bin/sh) ;;
-		*)
-			warn "${interp} is an invalid shebang you need USES=shebangfix for ${f#${STAGEDIR}${PREFIX}/}"
-			rc=0
-			;;
+	while read f; do
+		[ -z "${f}" ] && continue
+		shebangonefile "${f}" || rc=1
+	# Use heredoc to avoid losing rc from find|while subshell
+	done << EOF
+$(find ${STAGEDIR}${PREFIX}/bin ${STAGEDIR}${PREFIX}/sbin ${STAGEDIR}${PREFIX}/libexec -type f -perm +111 2>/dev/null)
+EOF
+	while read l link; do
+		[ -z "${l}" ] && continue
+		case "${link}" in
+		/*) f="${STAGEDIR}${link}" ;;
+		*) f="${l%/*}/${link}" ;;
 		esac
-	done
+		if [ -f "${f}" ]; then
+			shebangonefile "${f}" || rc=1
+		fi
+	# Use heredoc to avoid losing rc from find|while subshell
+	done << EOF
+$(find ${STAGEDIR}${PREFIX}/bin ${STAGEDIR}${PREFIX}/sbin ${STAGEDIR}${PREFIX}/libexec -type l -exec stat -f "%N %Y" {} + 2>/dev/null)
+EOF
 
 	return ${rc}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404122048.s3CKm4l7034694>