index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2017-10-30 09:41:47 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-10-30 09:41:47 +0100 |
commit | dc8b4dc460e699b65ef2d5aca9d3fe4a88431bd6 (patch) | |
tree | 8dc79aef48e9844d1008294717657cd0b34ab938 | |
parent | 92333c45b0a5fdf4894a8cf706c2066070ccb28b (diff) |
-rwxr-xr-x | bin/block-package | 56 |
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} + } |