Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/block-package94
-rwxr-xr-xbin/interpret-mail19
-rwxr-xr-xbin/modify-package-state177
3 files changed, 185 insertions, 105 deletions
diff --git a/bin/block-package b/bin/block-package
deleted file mode 100755
index d71858b..0000000
--- a/bin/block-package
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/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}" ] || \
- ! [ -w "${input_file}" ]; then
- >&2 printf \
- 'Cannot open input file "%s".' \
- "${input_file}"
- exit 2
-fi
-
-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}
- }
diff --git a/bin/interpret-mail b/bin/interpret-mail
index b754e59..5ddf69a 100755
--- a/bin/interpret-mail
+++ b/bin/interpret-mail
@@ -180,7 +180,7 @@ sed -n "$(
)" "${tmp_dir}/raw-content"
if [ -s "${tmp_dir}/block" ]; then
- if run_and_log_on_error "${base_dir}/bin/block-package" "${tmp_dir}/block"; then
+ if run_and_log_on_error "${base_dir}/bin/modify-package-state" --block "${tmp_dir}/block"; then
if [ -s "${tmp_dir}/block" ]; then
log 'Successfully blocked %s packages.\n' "$(wc -l < "${tmp_dir}/block")"
fi
@@ -193,20 +193,17 @@ if [ -s "${tmp_dir}/stabilize" ]; then
sed -i '
/\.pkg\.tar\.xz$/!s/$/.pkg.tar.xz/
' "${tmp_dir}/stabilize"
- find "${work_dir}/package-states" -maxdepth 1 -type f -name '*.testing' \
- -exec grep -qxF -f "${tmp_dir}/stabilize" '{}' \; \
- -printf '%p\n' | \
- tee "${tmp_dir}/stabilized" | \
- while read -r sf; do
- mv "${sf}" "${sf%.testing}.tested"
- done
- if [ -s "${tmp_dir}/stabilized" ]; then
- log 'Successfully stabilized %s packages.\n' "$(wc -l < "${tmp_dir}/stabilized")"
+ if run_and_log_on_error "${base_dir}/bin/modify-package-state" --tested "${tmp_dir}/stabilize"; then
+ if [ -s "${tmp_dir}/stabilize" ]; then
+ log 'Successfully marked %s packages as tested.\n' "$(wc -l < "${tmp_dir}/stabilize")"
+ fi
+ else
+ log 'There was an error while marking the packages as tested - ignoring this message.\n'
fi
fi
if [ -s "${tmp_dir}/unblock" ]; then
- if run_and_log_on_error "${base_dir}/bin/block-package" -u "${tmp_dir}/unblock"; then
+ if run_and_log_on_error "${base_dir}/bin/modify-package-state" --unblock "${tmp_dir}/unblock"; then
if [ -s "${tmp_dir}/unblock" ]; then
log 'Successfully unblocked %s packages.\n' "$(wc -l < "${tmp_dir}/unblock")"
fi
diff --git a/bin/modify-package-state b/bin/modify-package-state
new file mode 100755
index 0000000..9a2c2c7
--- /dev/null
+++ b/bin/modify-package-state
@@ -0,0 +1,177 @@
+#!/bin/sh
+
+# shellcheck source=conf/default.conf
+. "${0%/*}/../conf/default.conf"
+
+# shellcheck disable=SC2016
+usage() {
+ >&2 echo ''
+ >&2 echo 'modify-package-state [options] packages-file:'
+ >&2 echo ' modify state (file) of package(s).'
+ >&2 echo ''
+ >&2 echo 'possible options:'
+ >&2 echo ' -b|--block: Block package(s).'
+ >&2 echo ' -h|--help: Show this help and exit.'
+ >&2 echo ' -n|--no-report: Do not report what packages were modified.'
+ >&2 echo ' -t|--tested: Mark package(s) as tested.'
+ >&2 echo ' -u|--unblock: Unblock package(s).'
+ >&2 echo ''
+ >&2 echo 'Exactly one of -b|-t|-u is needed for actual operation.'
+ [ -z "$1" ] && exit 1 || exit "$1"
+}
+
+eval set -- "$(
+ getopt -o bhntu \
+ --long block \
+ --long help \
+ --long no-report \
+ --long tested \
+ --long unblock \
+ -n "$(basename "$0")" -- "$@" || \
+ echo usage
+)"
+
+action=''
+report=true
+
+while true
+do
+ case "$1" in
+ -b|--block)
+ if [ -n "${action}" ]; then
+ >&2 echo 'Conflicting/redundand arguments.'
+ usage
+ fi
+ action='block'
+ ;;
+ -h|--help)
+ usage 0
+ ;;
+ -n|--no-report)
+ report=false
+ ;;
+ -t|--tested)
+ if [ -n "${action}" ]; then
+ >&2 echo 'Conflicting/redundand arguments.'
+ usage
+ fi
+ action='tested'
+ ;;
+ -u|--unblock)
+ if [ -n "${action}" ]; then
+ >&2 echo 'Conflicting/redundand arguments.'
+ usage
+ fi
+ action='unblock'
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ >&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
+ exit 42
+ ;;
+ esac
+ shift
+done
+
+if [ -z "${action}" ]; then
+ >&2 echo 'Expected -b|-t|-u.'
+ usage
+fi
+
+if [ $# -ne 1 ]; then
+ >&2 echo 'Too few or too many arguments.'
+ usage
+fi
+
+input_file="$1"
+if ${report}; then
+ if ! [ -w "${output_file}" ]; then
+ >&2 printf \
+ 'Cannot open file "%s" for writing.' \
+ "${output_file}"
+ exit 2
+ fi
+ move_output() {
+ cat "${output_file}" > "${input_file}"
+ rm "${output_file}"
+ }
+ output_file=$(mktemp)
+ trap 'move_output' EXIT
+else
+ output_file='/dev/null'
+fi
+
+if ! [ -r "${input_file}" ]; then
+ >&2 printf \
+ 'Cannot open file "%s" for reading.' \
+ "${input_file}"
+ exit 2
+fi
+
+{
+ err=0
+ while read -r package reason; do
+ if echo "${package}" | \
+ grep -q '\.pkg\.tar\.xz$'; then
+ echo "'$package'" >&2
+ package=$(
+ find "${work_dir}/package-states" -maxdepth 1 \( -name '*.tested' -o -name '*.testing' \) \
+ -exec grep -qxF "${package}" '{}' \; \
+ -printf '%f\n' | \
+ sed 's|\.[^.]\+$||' | \
+ sort -u
+ )
+ echo "'$package'" >&2
+ if [ -z "${package}" ]; then
+ continue
+ fi
+ fi
+ if [ "${action}" = 'block' ] || \
+ [ "${action}" = 'unblock' ]; then
+ # these packages need to be on the build list
+ 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
+ fi
+ case "${action}" in
+ 'block')
+ 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
+ ;;
+ 'tested')
+ if [ -f "${work_dir}/package-states/${package}.testing" ]; then
+ mv \
+ "${work_dir}/package-states/${package}.testing" \
+ "${work_dir}/package-states/${package}.tested"
+ fi
+ ;;
+ 'unblock')
+ if [ -f "${work_dir}/package-states/${package}.blocked" ]; then
+ rm "${work_dir}/package-states/${package}.blocked"
+ printf '%s\n' "${package}"
+ fi
+ ;;
+ *)
+ >&2 printf 'Whooops, action "%s" not implemented yet.\n' "${action}"
+ exit 42
+ ;;
+ esac
+ done > \
+ "${output_file}"
+
+ exit ${err}
+} < \
+ "${input_file}"