Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Apr 2017 15:21:25 +0000 (UTC)
From:      Dmitry Marakasov <amdmi3@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r438176 - head/Mk/Scripts
Message-ID:  <201704101521.v3AFLPbb096929@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: amdmi3
Date: Mon Apr 10 15:21:25 2017
New Revision: 438176
URL: https://svnweb.freebsd.org/changeset/ports/438176

Log:
  Treat python shebangs without version specified (e.g. `/usr/local/bin/python'
  and `/usr/bin/env python') as invalid, because ports always depend on specific
  version of python (e.g. python2 or python3), and generic `python'
  which is link to either of them may point to incorrect version or
  be not available at all (since it's installed by separate optional
  python metaport)
  
  Approved by:	portmgr (mat), python (sunpoet)
  Differential Revision:	D9332

Modified:
  head/Mk/Scripts/qa.sh

Modified: head/Mk/Scripts/qa.sh
==============================================================================
--- head/Mk/Scripts/qa.sh	Mon Apr 10 15:08:47 2017	(r438175)
+++ head/Mk/Scripts/qa.sh	Mon Apr 10 15:21:25 2017	(r438176)
@@ -29,7 +29,7 @@ list_stagedir_elfs() {
 }
 
 shebangonefile() {
-	local f interp rc
+	local f interp interparg badinterp rc
 
 	f="$@"
 	rc=0
@@ -42,8 +42,12 @@ shebangonefile() {
 	esac
 
 	interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p;2q' "${f}")
+	badinterp=""
 	case "${interp}" in
 	"") ;;
+	${LOCALBASE}/bin/python|${PREFIX}/bin/python)
+		badinterp="${interp}"
+		;;
 	${LINUXBASE}/*) ;;
 	${LOCALBASE}/bin/perl5.* | ${PREFIX}/bin/perl5.*)
 		# lang/perl5* are allowed to have these shebangs.
@@ -59,16 +63,27 @@ shebangonefile() {
 	/bin/sh) ;;
 	/bin/tcsh) ;;
 	/usr/bin/awk) ;;
-	/usr/bin/env) ;;
+	/usr/bin/env)
+		interparg=$(sed -n -e '1s/^#![[:space:]]*[^[:space:]]*[[:space:]]*\([^[:space:]]*\).*/\1/p;2q' "${f}")
+		case "${interparg}" in
+		python)
+			badinterp="${interp} ${interparg}"
+			;;
+		esac
+		;;
 	/usr/bin/nawk) ;;
 	/usr/bin/sed) ;;
 	/usr/sbin/dtrace) ;;
 	*)
-		err "'${interp}' is an invalid shebang you need USES=shebangfix for '${f#${STAGEDIR}${PREFIX}/}'"
-		rc=1
+		badinterp="${interp}"
 		;;
 	esac
 
+	if [ -n "${badinterp}" ]; then
+		err "'${badinterp}' is an invalid shebang you need USES=shebangfix for '${f#${STAGEDIR}${PREFIX}/}'"
+		rc=1
+	fi
+
 	return ${rc}
 }
 



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