-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkbroken
111 lines (101 loc) · 2.33 KB
/
checkbroken
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
versionFile=versionCheck.txt
brokenFile=broken_quiet.txt
url=http://users.pacbsd.org/~repo/repo-report/current
fetch -q ${url}/${brokenFile} -o /tmp/${brokenFile}
fetch -q ${url}/${versionFile} -o /tmp/${versionFile}
show_help() {
cat << EOF
-q quiet Return nothing but 1 or 0 as output
EOF
}
while getopts q args; do
case ${args} in
q)
return_quiet="0"
;;
*)
show_help
;;
esac
done
check_broken() {
local _pkg="$1"
local _prov="$1"
unset broken_found
if (is_a_provide -v "$_prov"); then
_prov=$(is_a_provide -p "$_prov" | head -1)
if ( grep -q "^${_prov}$" /tmp/${brokenFile} ); then
broken_found=0
if [ -z "${return_quiet}" ]; then
echo "${_pkg} is provided by ${_prov} which is broken"
fi
fi
else
if ( grep -q "^${_pkg}$" /tmp/${brokenFile} ); then
broken_found=0
if [ -z "${return_quiet}" ]; then
echo "${_pkg} is broken."
fi
fi
fi
}
check_version() {
local _pkg="$1"
local _prov="$1"
unset outdated_found
if (is_a_provide -v "$_prov"); then
_prov=$(is_a_provide -p "$_prov" | head -1)
if ( grep -q "/${_prov}$" /tmp/${versionFile} ); then
outdated_found="0"
if [ -z "${return_quiet}" ]; then
echo "${_pkg} is provided by ${_prov} which is outdated"
fi
fi
else
if ( grep -q "/${_pkg} " /tmp/${versionFile} ); then
outdated_found="0"
if [ -z "${return_quiet}" ]; then
echo "${_pkg} is outdated."
fi
fi
fi
}
if [ ! -f PKGBUILD ];then
echo "No PKGBUILD found" && exit 1
else
source PKGBUILD
for x in "depends" "makedepends" "checkdepends"; do
for z in "check_broken" "check_version"; do
if [ -z "${return_quiet}" ]; then
echo "Checking ${x} with ${z}"
fi
case "${x}" in
depends)
for dep in "${depends[@]}"; do
"${z}" "${dep%%[<>=]*}"
if [ -n "${outdated_found}" ] || [ -n "${broken_found}" ];then
return_val=1
fi
done
;;
makedepends)
for dep in "${makedepends[@]}"; do
"${z}" "${dep%%[<>=]*}"
if [ -n "${outdated_found}" ] || [ -n "${broken_found}" ];then
return_val=1
fi
done
;;
optdepends)
for dep in "${optdepends[@]}"; do
"${z}" "${dep%%[<>=]*}"
done
;;
esac
done
done
fi
if [ -n "${return_val}" ];then
exit 1
fi