Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-10-30 09:41:47 +0100
committerErich Eckner <git@eckner.net>2017-10-30 09:41:47 +0100
commitdc8b4dc460e699b65ef2d5aca9d3fe4a88431bd6 (patch)
tree8dc79aef48e9844d1008294717657cd0b34ab938
parent92333c45b0a5fdf4894a8cf706c2066070ccb28b (diff)
bin/block-package: remove obsolete lines from input-file
-rwxr-xr-xbin/block-package56
1 files changed, 32 insertions, 24 deletions
diff --git a/bin/block-package b/bin/block-package
index dd51318..d71858b 100755
--- a/bin/block-package
+++ b/bin/block-package
@@ -53,34 +53,42 @@ fi
input_file="$1"
-if ! [ -r "${input_file}" ]; then
+if ! [ -r "${input_file}" ] || \
+ ! [ -w "${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}"
+sponge "${input_file}" | \
+ {
+ 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"
+ printf '%s %s\n' "${package}" "${reason}"
+ fi
+ else
+ if [ -f "${work_dir}/package-states/${package}.blocked" ]; then
+ rm "${work_dir}/package-states/${package}.blocked"
+ printf '%s\n' "${package}"
+ fi
+ fi
+ done > \
+ "${input_file}"
-exit ${err}
+ exit ${err}
+ }