#!/bin/sh # $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 } checks="shebang symlinks paths" ret=0 cd ${STAGEDIR} for check in ${checks}; do ${check} || ret=1 done exit $ret