#!/bin/sh # report about status of build master # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" # TODO: replace by build-master-status-from-mysql usage() { >&2 echo '' >&2 echo 'build-master-status: report about status of build master' >&2 echo '' >&2 echo 'possible options:' >&2 echo ' -h|--help:' >&2 echo ' Show this help and exit.' [ -z "$1" ] && exit 1 || exit "$1" } eval set -- "$( getopt -o h \ --long help \ -n "$(basename "$0")" -- "$@" || \ echo usage )" while true do case "$1" in -h|--help) usage 0 ;; --) shift break ;; *) >&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.' exit 42 ;; esac shift done if [ $# -ne 0 ]; then >&2 echo 'Too many arguments.' usage fi if [ -s "${work_dir}/build-master-sanity" ]; then >&2 echo 'Build master is not sane.' exit fi tmp_dir=$(mktemp -d 'tmp.build-master-status.XXXXXXXXXX' --tmpdir) trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT { printf '%s\n' \ '' \ '' \ 'Todos in the build scripts' \ '' \ '' find "${base_dir}/bin/" "${base_dir}/conf/" -type f \ -exec grep -nHF '' '{}' \; | \ awk ' { print $0 } /^[^:]+:[0-9]+:\s*#\s*TODO:/{print ++i} ' | \ sed -n ' s/^\([^:]\+\):\([0-9]\+\):\s*#\s*TODO:\s*/\1\n\2\n/ T N s/\n\(.*\)\n\([0-9]\+\)$/\n\2\n\1/ :a N s/\n[^:\n]\+:[0-9]\+:[ \t]*#[ \t]*\(\S[^\n]*\)$/\n\1/ ta s/\n[^:\n]\+:[0-9]\+:[^\n]*$/\n/ p ' | \ tee "${tmp_dir}/todos" | \ sed ' :a N /\n$/!ba s|^[^\n]*/\([^/\n]\+/[^/\n]\+\)\n\([0-9]\+\)\n\([0-9]\+\)\n|TODO #\2 - \1 (line \3):\n| ' | \ sed ' s|$|
| ' printf '%s\n' \ '' \ '' } > \ "${tmp_dir}/todos.html" if [ -s "${tmp_dir}/todos" ]; then sed ' :a N /\n$/!ba s|^[^\n]*/\([^/\n]\+/[^/\n]\+\)\n\([0-9]\+\)\n\([0-9]\+\)\n|\1 \3 | s/\n$// s/\n/\\n/g ' -i "${tmp_dir}/todos" while read -r file line desc; do printf '%s %s %s\n' \ "$(printf '%s' "${file}" | base64 -w0)" \ "$(printf '%s' "${line}" | base64 -w0)" \ "$(printf '%s' "${desc}" | base64 -w0)" done < \ "${tmp_dir}/todos" | \ sponge "${tmp_dir}/todos" # update todos # shellcheck disable=SC2016 while read -r file line desc; do printf 'UPDATE IGNORE `todos`' printf ' SET `todos`.`line`=from_base64("%s")' \ "${line}" printf ' WHERE `todos`.`file`=from_base64("%s")' \ "${file}" printf ' AND `todos`.`description`=from_base64("%s");\n' \ "${desc}" printf 'UPDATE IGNORE `todos`' printf ' SET `todos`.`description`=from_base64("%s")' \ "${desc}" printf ' WHERE `todos`.`file`=from_base64("%s")' \ "${file}" printf ' AND `todos`.`line`=from_base64("%s");\n' \ "${line}" done < \ "${tmp_dir}/todos" | \ mysql_run_query # insert unfound todos # shellcheck disable=SC2016 { printf 'SHOW CREATE TABLE `todos`' | \ mysql_run_query | \ sed ' 1s/^\S\+\s\+CREATE TABLE `todos` /CREATE TEMPORARY TABLE `td` / ' printf ';\n' printf 'INSERT INTO `td` (`file`,`line`,`description`) VALUES ' while read -r file line desc; do printf '(' printf 'from_base64("%s"),' \ "${file}" \ "${line}" \ "${desc}" | \ sed 's/,$/),/' done < \ "${tmp_dir}/todos" | \ sed ' s/,$// ' printf ';\n' printf 'INSERT IGNORE INTO `todos` (`file`,`line`,`description`) ' printf 'SELECT `td`.`file`,`td`.`line`,`td`.`description` ' printf 'FROM `td` ' printf 'WHERE NOT EXISTS (' printf 'SELECT * FROM `todos`' printf ' AND `td`.`%s`=`todos`.`%s`' \ 'file' 'file' \ 'line' 'line' \ 'description' 'description' | \ sed 's/^ AND / WHERE /' printf ');\n' printf 'DELETE FROM `todos` WHERE NOT EXISTS (' printf 'SELECT * FROM `td`' printf ' AND `td`.`%s`=`todos`.`%s`' \ 'file' 'file' \ 'line' 'line' \ 'description' 'description' | \ sed 's/^ AND / WHERE /' printf ');' printf 'DROP TABLE `td`;\n' printf 'DELETE FROM `todo_links` WHERE NOT EXISTS (' printf 'SELECT * FROM `todos` ' printf 'WHERE `todos`.`id`=`todo_links`.`depending_on`' printf ') OR NOT EXISTS (' printf 'SELECT * FROM `todos` ' printf 'WHERE `todos`.`id`=`todo_links`.`dependent`' printf ');\n' } | \ mysql_run_query rm -f "${tmp_dir}/todos" fi { printf '%s\n' \ '' \ '' \ 'Blacklisted packages' \ '' \ '' \ '' \ '' printf '' printf '' \ 'package' \ 'reason' printf '\n' git -C "${repo_paths__archlinux32}" archive "$(cat "${work_dir}/archlinux32.revision")" -- 'blacklist' | \ tar -Ox | \ sed ' s@FS#\([0-9]\+\)@\0@ s@FS32#\([0-9]\+\)@\0@ /.#/!s/$/#/ s|\(.\)#|\1| ' printf '%s\n' \ '
%s
| /^\s*#/{ s/^\s*#\s*// s|\s*\(\)|\1| s/^// } s|^|
| s|$|
' \ '' \ '' } > \ "${tmp_dir}/blacklist.html" { printf '%s\n' \ '' \ '' \ 'log of ssh connections from build slaves' \ '' \ '' \ '' printf '' printf '' \ 'time' \ 'build slave' \ 'command' \ 'arguments' printf '\n' if [ -r "${work_dir}/ssh-log" ]; then tac "${work_dir}/ssh-log" | \ while read -r date time slave command arguments; do printf '' printf '' \ "${date} ${time}" \ "${slave}" \ "${command}" \ "${arguments}" printf '\n' done fi printf '%s\n' \ '
%s
%s
' \ '' \ '' } > \ "${tmp_dir}/ssh-log.html" find "${tmp_dir}" -maxdepth 1 -type f | \ while read -r file; do cat "${file}" > \ "${webserver_directory}/${file##*/}" done