blob: dd513180a023df9a450da1e9896ff9f58c6a070d (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/sh
# shellcheck source=conf/default.conf
. "${0%/*}/../conf/default.conf"
# shellcheck disable=SC2016
usage() {
>&2 echo ''
>&2 echo 'block-package [options] packages-file:'
>&2 echo ' [un]block packages in packages-file from being built.'
>&2 echo ''
>&2 echo 'possible options:'
>&2 echo ' -h|--help: Show this help and exit.'
>&2 echo ' -u|--unblock: Unblock package instead of blocking it.'
[ -z "$1" ] && exit 1 || exit "$1"
}
eval set -- "$(
getopt -o hu \
--long help \
--long unblock \
-n "$(basename "$0")" -- "$@" || \
echo usage
)"
block=true
while true
do
case "$1" in
-h|--help)
usage 0
;;
-u|--unblock)
block=false
;;
--)
shift
break
;;
*)
>&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
exit 42
;;
esac
shift
done
if [ $# -ne 1 ]; then
>&2 echo 'Too few or too many arguments.'
usage
fi
input_file="$1"
if ! [ -r "${input_file}" ]; then
>&2 printf \
'Cannot open input file "%s".' \
"${input_file}"
exit 2
fi
err=0
while read -r package reason; do
if ! tr ' ' '.' < \
"${work_dir}/build-list" | \
grep -qxF "${package}"; then
>&2 printf 'Package "%s" is not on the build-list.\n' "${package}"
err=2
continue
fi
if ${block}; then
if [ -z "${reason}" ]; then
>&2 printf 'No reason is given for blocking package "%s".\n' "${package}"
err=2
else
echo "${reason}" > \
"${work_dir}/package-states/${package}.blocked"
fi
else
rm -f "${work_dir}/package-states/${package}.blocked"
fi
done < \
"${input_file}"
exit ${err}
|