blob: c9a3915bc9f31cda9edb7a59afe1181e2d5475b1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
|