diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2013-10-09 15:11:32 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2013-10-09 15:11:32 +0000 |
commit | aa40865de14426f892bcdae8ddd716b03a58636e (patch) | |
tree | 2b308aa81f8f91513d04cb0cf319755b7d03e8bd /Mk/Scripts/qa.sh | |
parent | - Add staging support (diff) |
First set of Q/A for staged ports.
A couple of Q/A tests are done if the DEVELOPER macros is set in make.conf
Right now the tests are:
- Check if the symlinks are properly created
- Check if the binaries are stripped (just warn)
- Check if the STAGEDIR or the WORKDIR are referenced in the final files
- Check if the ports provide script with bad shebangs.
Notes
Notes:
svn path=/head/; revision=329902
Diffstat (limited to 'Mk/Scripts/qa.sh')
-rw-r--r-- | Mk/Scripts/qa.sh | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Mk/Scripts/qa.sh b/Mk/Scripts/qa.sh new file mode 100644 index 000000000000..c9a3915bc9f3 --- /dev/null +++ b/Mk/Scripts/qa.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# MAINTAINER: portmgr@FreeBSD.org +# $FreeBSD$ + +if [ -z "${STAGEDIR}" -o -z "${PREFIX}" -o -z "${LOCALBASE}" ]; then + echo "STAGEDIR, PREFIX, LOCALBASE required in environment." >&2 + exit 1 +fi + +warn() { + echo "Warning: $@" >&2 +} + +err() { + echo "Error: $@" >&2 +} + +shebang() { + rc=0 + for f in `find ${STAGEDIR} -type f`; do + interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p' $f) + case "$interp" in + "") ;; + /usr/bin/env) ;; + ${LOCALBASE}/*) ;; + ${PREFIX}/*) ;; + /usr/bin/awk) ;; + /usr/bin/sed) ;; + /bin/sh) ;; + *) + err "${interp} is an invalid shebang you need USES=shebangfix for ${f#${STAGEDIR}${PREFIX}/}" + rc=1 + ;; + esac + done +} + +symlinks() { + rc=0 + for l in `find ${STAGEDIR} -type l`; do + link=$(readlink ${l}) + case "${link}" in + ${STAGEDIR}*) err "Bad symlinks ${l} pointing inside the stage directory" + rc=1 + ;; + esac + done +} + +paths() { + rc=0 + dirs="${STAGEDIR} ${WRKDIR}" + 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}" + rc=1 + fi + done + done +} + +# For now do not raise an error, just warnings +stripped() { + [ -x /usr/bin/file ] || return + for f in `find ${STAGEDIR} -type f`; do + output=`/usr/bin/file ${f}` + case "${output}" in + *:*\ ELF\ *,\ not\ stripped*) warn "${f} is not stripped";; + esac + done +} + +checks="shebang symlinks paths stripped" + +ret=0 +cd ${STAGEDIR} +for check in ${checks}; do + ${check} || ret=1 +done + +exit $ret |