blob: bc7c5bc3773fedea227ecff5d4fabd7ff79259fe (
plain)
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
|
#!/bin/sh
# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"
# shellcheck disable=SC2016
usage() {
>&2 echo ''
>&2 echo 'manage-fail-reasons $action [parameters]: manage the list of fail reasons'
>&2 echo ''
>&2 echo 'possible actions:'
>&2 echo ' list list installed fail reasons'
>&2 echo ' check <build-log> check a build log for fail reasons'
exit 1
}
if [ $# -eq 0 ]; then
usage
fi
case "$1" in
'list')
# shellcheck disable=SC2016
fail_reason_identifiers=$(
{
printf 'SELECT `fail_reasons`.`id`,`fail_reasons`.`severity`,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")'
printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity` ASC, `fail_reasons`.id ASC'
} | \
mysql_run_query
)
printf '%s\n' "${fail_reason_identifiers}" | \
while read -r reason_id severity identifier; do
ident=$(printf '%s' "${identifier}" | base64 -d -)
printf "%02s %03s %s\n" "$reason_id" "$severity" "$ident"
done
;;
'check')
shift
filelog="$1"
if [ $# -ne 1 ]; then
>&2 printf '"check" expects 1 parameter (a path to a build log), %s were given\n' "$#"
usage
fi
fail_reason_identifiers=$(
{
printf 'SELECT id,severity,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")'
printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity` ASC, `fail_reasons`.id ASC'
} | \
mysql_run_query
)
printf '%s\n' "${fail_reason_identifiers}" | \
while read -r id severity identifier; do
if zgrep -qx "\s*$(
printf '%s' "${identifier}" | \
base64 -d
)\s*" \
"$filelog"; then
echo 'match'
ident=$(printf '%s' "${identifier}" | base64 -d -)
printf "$id ($ident) matches with severity $severity\n"
fi
done
;;
*)
>&2 printf 'unknown action "%s"\n' "$1"
usage
;;
esac
|