From d44c45606f6289889cb0f5c12ab5bed61d65330d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 23 Aug 2017 14:13:29 +0200 Subject: bin/build-master-status: make shellcheck-conform --- bin/build-master-status | 199 +++++++++++++++++++++++------------------------- 1 file changed, 97 insertions(+), 102 deletions(-) (limited to 'bin') diff --git a/bin/build-master-status b/bin/build-master-status index 8c36c81..90469f2 100755 --- a/bin/build-master-status +++ b/bin/build-master-status @@ -2,6 +2,7 @@ # report about status of build master +# shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" usage() { @@ -13,7 +14,7 @@ usage() { >&2 echo ' Output to webserver instead of stdout.' >&2 echo ' -h|--help:' >&2 echo ' Show this help and exit.' - [ -z "$1" ] && exit 1 || exit $1 + [ -z "$1" ] && exit 1 || exit "$1" } eval set -- "$( @@ -161,45 +162,41 @@ looped_packages=$( wc -l ) -printf 'The mirror master contains %d stable packages (vs. ca. %d planned).\n' \ - "${stable}" \ - "$((${staging}+${testing}+${pending_packages}))" >> \ - "${tmp_dir}/build-master-status.html" -printf 'The build list contains %d tasks (incl. broken: %d, leading to %d packages), of which %s can be built immediately.\n' \ - "$((${tasks}-${broken}))" \ - "${tasks}" \ - "${pending_packages}" \ - "${next_tasks}" >> \ - "${tmp_dir}/build-master-status.html" -printf 'There are %d testing and %d staging packages.\n' \ - "${testing}" \ - "${staging}" >> \ - "${tmp_dir}/build-master-status.html" -printf 'There are %d broken package builds.\n' \ - "${broken}" >> \ +{ + printf 'The mirror master contains %d stable packages (vs. ca. %d planned).\n' \ + "${stable}" \ + "$((staging+testing+pending_packages))" + printf 'The build list contains %d tasks (incl. broken: %d, leading to %d packages), of which %s can be built immediately.\n' \ + "$((tasks-broken))" \ + "${tasks}" \ + "${pending_packages}" \ + "${next_tasks}" + printf 'There are %d testing and %d staging packages.\n' \ + "${testing}" \ + "${staging}" + printf 'There are %d broken package builds.\n' \ + "${broken}" + if [ "${loops}" -ne 0 ]; then + printf 'There are %d loops containing %d package builds.\n' \ + "${loops}" \ + "${looped_packages}" + fi + if [ $((broken+testing+staging)) -ne 0 ]; then + printf '%.1f%% of all packages are broken.\n' \ + "$( + echo "scale=10; 100*${broken}/(${broken}+${testing}+${staging})" | \ + bc + )" + fi + if [ $((testing+staging+pending_packages-broken)) -ne 0 ]; then + printf '%.1f%% of the planned work has been done.\n' \ + "$( + echo "scale=10; 100*(${testing}+${staging})/(${testing}+${staging}+${pending_packages}-${broken})" | \ + bc + )" + fi +} > \ "${tmp_dir}/build-master-status.html" -if [ "${loops}" -ne 0 ]; then - printf 'There are %d loops containing %d package builds.\n' \ - "${loops}" \ - "${looped_packages}" >> \ - "${tmp_dir}/build-master-status.html" -fi -if [ $((${broken}+${testing}+${staging})) -ne 0 ]; then - printf '%.1f%% of all packages are broken.\n' \ - "$( - echo "scale=10; 100*${broken}/(${broken}+${testing}+${staging})" | \ - bc - )" >> \ - "${tmp_dir}/build-master-status.html" -fi -if [ $((${testing}+${staging}+${pending_packages}-${broken})) -ne 0 ]; then - printf '%.1f%% of the planned work has been done.\n' \ - "$( - echo "scale=10; 100*(${testing}+${staging})/(${testing}+${staging}+${pending_packages}-${broken})" | \ - bc - )" >> \ - "${tmp_dir}/build-master-status.html" -fi if ${web}; then "${base_dir}/bin/calculate-dependent-packages" @@ -237,74 +234,72 @@ if ${web}; then tac > \ "${tmp_dir}/statistics" - printf '\n\nList of broken package builds\n\n\nbuild logs
\n\n' >> \ - "${tmp_dir}/broken-packages.html" - printf '' \ - 'package' \ - 'git revision' \ - 'modification git revision' \ - 'package repository' \ - 'compilations' \ - 'dependent' \ - 'blocked' >> \ - "${tmp_dir}/broken-packages.html" - printf '\n' >> \ - "${tmp_dir}/broken-packages.html" - ls "${work_dir}/package-states" | \ - grep '\.broken$' | \ - sed 's|\.broken$||' | \ - sed 's|^\(\(.\+\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\)$|\1 \2 \3 \4 \5|' | \ - sort -k1,1 | \ - join -1 2 -2 1 -o 1.1,1.2,1.3,1.4,1.5 - "${tmp_dir}/broken-packages-names" | \ - while read -r sf pkg rev mod_rev repo; do - printf '%s ' \ - "${pkg}" \ - "${rev}" \ - "${mod_rev}" \ - "${repo}" \ - "$(wc -l < "${work_dir}/package-states/${sf}.broken")" \ - "$( - ls -t "${webserver_directory}/build-logs" | \ - grep -m1 "^$(str_to_regex "${sf}.")[^.]\+\.build-log\.gz\$" - )" \ - "$( - ( - grep -m1 "^$(str_to_regex "${sf}") " "${work_dir}/dependent-count" || \ - echo 'x  ' - ) | \ - cut -d' ' -f2 - )" - if [ -f "${work_dir}/package-states/${sf}.blocked" ]; then - tr '\n' ' ' < "${work_dir}/package-states/${sf}.blocked" | \ - sed 's|FS#\([0-9]\+\)|FS#\1|' - else - printf ' ' - fi - printf '\n' - done | \ - sort -k5n,5 | \ - while read -r pkg rev mod_rev repo count log_file dependent reason; do - printf '' - printf '' \ - ''"${pkg}"'' \ - "${rev}" \ - "${mod_rev}" \ - "${repo}" \ - ''"${count}"'' \ - "${dependent}" \ - "${reason}" - printf '\n' - done >> \ - "${tmp_dir}/broken-packages.html" - printf '
%s
%s
\n\n\n' >> \ + { + printf '\n\nList of broken package builds\n\n\nbuild logs
\n\n' + printf '' \ + 'package' \ + 'git revision' \ + 'modification git revision' \ + 'package repository' \ + 'compilations' \ + 'dependent' \ + 'blocked' + printf '\n' + ls "${work_dir}/package-states" | \ + grep '\.broken$' | \ + sed 's|\.broken$||' | \ + sed 's|^\(\(.\+\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\)$|\1 \2 \3 \4 \5|' | \ + sort -k1,1 | \ + join -1 2 -2 1 -o 1.1,1.2,1.3,1.4,1.5 - "${tmp_dir}/broken-packages-names" | \ + while read -r sf pkg rev mod_rev repo; do + printf '%s ' \ + "${pkg}" \ + "${rev}" \ + "${mod_rev}" \ + "${repo}" \ + "$(wc -l < "${work_dir}/package-states/${sf}.broken")" \ + "$( + ls -t "${webserver_directory}/build-logs" | \ + grep -m1 "^$(str_to_regex "${sf}.")[^.]\+\.build-log\.gz\$" + )" \ + "$( + ( + grep -m1 "^$(str_to_regex "${sf}") " "${work_dir}/dependent-count" || \ + echo 'x  ' + ) | \ + cut -d' ' -f2 + )" + if [ -f "${work_dir}/package-states/${sf}.blocked" ]; then + tr '\n' ' ' < "${work_dir}/package-states/${sf}.blocked" | \ + sed 's|FS#\([0-9]\+\)|FS#\1|' + else + printf ' ' + fi + printf '\n' + done | \ + sort -k5n,5 | \ + while read -r pkg rev mod_rev repo count log_file dependent reason; do + printf '' + printf '' \ + ''"${pkg}"'' \ + "${rev}" \ + "${mod_rev}" \ + "${repo}" \ + ''"${count}"'' \ + "${dependent}" \ + "${reason}" + printf '\n' + done + printf '
%s
%s
\n\n\n' + } > \ "${tmp_dir}/broken-packages.html" rm -f "${tmp_dir}/broken-packages-names" - ls "${tmp_dir}" | \ + find "${tmp_dir}" -maxdepth 1 | \ while read -r file; do - cat "${tmp_dir}/${file}" > \ - "${webserver_directory}/${file}" + cat "${file}" > \ + "${webserver_directory}/${file##*/}" done else -- cgit v1.2.3-70-g09d2