config/functions: remove non-mt support in update_dashboard()

This commit is contained in:
MilhouseVH 2019-04-24 04:56:39 +01:00
parent b272bcb999
commit c3913ab9ae

View File

@ -1312,11 +1312,13 @@ pkg_lock_status() {
}
update_dashboard() {
[ "${MTWITHLOCKS}" != "yes" ] && return 0
local status="$1" pkg="$2" task="$3" msg="$4"
local line sedline preamble num elapsed projdevarch
local boldred boldgreen boldyellow endcolor
[ -n "${MTJOBID}" ] && sedline=$((MTJOBID + 2)) || sedline=1
sedline=$((MTJOBID + 2))
num=$(cat "${THREAD_CONTROL}/status" | wc -l)
while [ ${num} -lt ${sedline} ]; do echo "" >>"${THREAD_CONTROL}/status"; num=$((num + 1)); done
@ -1329,30 +1331,26 @@ update_dashboard() {
printf -v preamble "%s Dashboard (%s) - %d of %d jobs completed, %s elapsed" "${DISTRONAME}" "${projdevarch}" ${num} ${MTMAXJOBS} "${elapsed}"
printf -v preamble "%b%-105s %s" "\e[2J\e[0;0H" "${preamble//\//\\/}" "$(date "+%Y-%m-%d %H:%M:%S")"
# Only update the header when caller is not a worker thread
if [ -z "${MTJOBID}" ]; then
sed -e "1s/.*/${preamble}/" -i "${THREAD_CONTROL}/status"
else
if [ "${DISABLE_COLORS}" != "yes" ]; then
boldred="\e[1;31m"
boldgreen="\e[1;32m"
boldyellow="\e[1;33m"
white="\e[0;37m"
endcolor="\e[0m"
if [ "${DISABLE_COLORS}" != "yes" ]; then
boldred="\e[1;31m"
boldgreen="\e[1;32m"
boldyellow="\e[1;33m"
white="\e[0;37m"
endcolor="\e[0m"
case "${status}" in
IDLE) color="${white}";;
STALLED) color="${boldyellow}";;
MUTEX/W) color="${boldyellow}";;
FAILED ) color="${boldred}";;
*) color="${boldgreen}";;
esac
fi
printf -v line "[%02d\/%0*d] %b%-7s%b %-7s %-35s" ${MTJOBID} ${#MTMAXJOBS} ${PARALLEL_SEQ:-0} "${color}" "${status//\//\\/}" "${endcolor}" "${task}" "${pkg}"
[ -n "${msg}" ] && line+=" ${msg//\//\\/}"
sed -e "1s/.*/${preamble}/;${sedline}s/.*/${line}/" -i "${THREAD_CONTROL}/status"
case "${status}" in
IDLE) color="${white}";;
STALLED) color="${boldyellow}";;
MUTEX/W) color="${boldyellow}";;
FAILED ) color="${boldred}";;
*) color="${boldgreen}";;
esac
fi
printf -v line "[%02d\/%0*d] %b%-7s%b %-7s %-35s" ${MTJOBID} ${#MTMAXJOBS} ${PARALLEL_SEQ:-0} "${color}" "${status//\//\\/}" "${endcolor}" "${task}" "${pkg}"
[ -n "${msg}" ] && line+=" ${msg//\//\\/}"
sed -e "1s/.*/${preamble}/;${sedline}s/.*/${line}/" -i "${THREAD_CONTROL}/status"
}
# Thread concurrency helpers to avoid concurrency issues with some code,