-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan-blacklist
executable file
·88 lines (63 loc) · 1.69 KB
/
scan-blacklist
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
83
84
85
86
87
88
#!/usr/bin/env zsh
set -e -u -o pipefail
CURDIR=$(dirname $0)
while getopts "z:b:f:" OPT; do
case $OPT in
z)
PACKAGE_SET=${OPTARG}
;;
b)
BLACKLIST_LIST=${OPTARG}
;;
f)
ORIGIN_LIST=${OPTARG}
;;
esac
done
shift $((${OPTIND} - 1))
# ===========================================================================
_make_conf=$(mktemp)
cat /usr/local/etc/poudriere.d/make.conf \
/usr/local/etc/poudriere.d/default-${PACKAGE_SET}-make.conf > ${_make_conf}
cleanup()
{
rm ${_make_conf}
}
interrupt()
{
cleanup
exit 1
}
trap interrupt INT
export PORTSDIR=/usr/local/poudriere/ports/default
export PORT_DBDIR=/usr/local/etc/poudriere.d/${PACKAGE_SET}-options
typeset -A ports
blacklist=()
scan()
{
_port="$1"
_port="${_port%@*}"
echo "Scanning ${_port}"
[ -d ${PORTSDIR}/${_port} -a "${_port}" != "patch" ] || {
echo "Directory not found: ${_port}"
return 1
}
for _depend in `make __MAKE_CONF=${_make_conf} -VPKG_DEPENDS -VBUILD_DEPENDS -VEXTRACT_DEPENDS -VLIB_DEPENDS -VPATCH_DEPENDS -VFETCH_DEPENDS -VRUN_DEPENDS -C ${PORTSDIR}/${_port}`; do
_depend=$(echo ${_depend} | sed -e "s/.*://")
_depend=${_depend#${PORTSDIR}/}
if [ $blacklist[(i)${_depend}] -le ${#blacklist} ]; then
echo "Found: ${_port} -> ${_depend}."
exit 1
fi
(( $+ports[${_depend}] )) && continue
ports[${_depend}]=1
scan "${_depend}"
done
}
cat ${BLACKLIST_LIST} | grep -v "^#" | while read _path; do
blacklist[(i)${_path}]=${_path}
done
cat ${ORIGIN_LIST} | grep -v "^#" | while read _path; do
scan ${_path}
done
cleanup