summaryrefslogtreecommitdiff
path: root/Mk/Scripts/qa.sh
diff options
context:
space:
mode:
authorAntoine Brodin <antoine@FreeBSD.org>2014-04-12 20:48:04 +0000
committerAntoine Brodin <antoine@FreeBSD.org>2014-04-12 20:48:04 +0000
commit32d4470be870e6772b3069598a28f25d4c024674 (patch)
tree6c4d2598ca46fe937a17cf99e893fa5f86b01f7a /Mk/Scripts/qa.sh
parentDo not add 4.1.2/docbook.cat to catalog (diff)
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
Notes
Notes: svn path=/head/; revision=351132
Diffstat (limited to 'Mk/Scripts/qa.sh')
-rw-r--r--Mk/Scripts/qa.sh64
1 files changed, 45 insertions, 19 deletions
diff --git a/Mk/Scripts/qa.sh b/Mk/Scripts/qa.sh
index a941d3c21a6d..ad3e91d38e09 100644
--- a/Mk/Scripts/qa.sh
+++ b/Mk/Scripts/qa.sh
@@ -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}
}