From 61a6f72850e4ecff3a3202910e201ad66197501e Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Thu, 16 Aug 2012 11:38:14 +0200 Subject: [PATCH] autodist-cgi: support for multiple packages jobs with link available for each operation performed (prepare,update,build,install) --- autodist-cgi | 82 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/autodist-cgi b/autodist-cgi index 3dd72d7..abf2626 100755 --- a/autodist-cgi +++ b/autodist-cgi @@ -94,7 +94,7 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do [ "${line:0:6}" = "listcs" ] && printon=1 done echo "
" - RELOADTIME=5000 + RELOADTIME=15000 break elif [ "$SHOWLOG" ]; then if [ "$HOST" = "$AS_HOST" -a "$NUM" = "$i" ]; then @@ -174,22 +174,36 @@ _EOF case $PREF in "%%" ) if [ "$2 $3" == "Autodist started" ]; then STARTTIME=`echo $line | sed "s|.* @ ||"` + AUTODIST_PID=`echo $line | sed "s|.*PID \([0-9]*\) .*|\1|"` elif [ "$2 $3 $4" == "All jobs done" ]; then ENDTIME=`echo $line | sed "s|.* @ ||"` elif [ "$2 $3" == "autoupdate jobs:" ]; then SCHEDULED=`echo $line | sed "s|.*autoupdate jobs: ||"` elif [ "$2" == "Doing" ]; then BUILDNOW[$BUILDNOWIDX]="$3" + BUILDLOG[$BUILDNOWIDX]= + BUILDNOWSTATUS[$BUILDNOWIDX]= BUILDNOWIDX=`expr $BUILDNOWIDX + 1` +# elif [ "$2" == "Starting" ]; then +# case $3 in +# "PREPARE"|"UPDATE"|"BUILD"|"SEND") BUILDNOW[$BUILDNOWIDX-1]="${BUILDNOW[$BUILDNOWIDX-1]} $3" ;; +# esac #elif [ "$2" != "Starting" -a "$2" != "Updating" ]; then # [ "$JOBON" ] || echo $line fi ;; "?=") if [ "$2" == "See" ]; then - BUILDLOG[$BUILDNOWIDX-1]=`echo $line | sed "s|.*autodist/log/||"` + BUILDLOG[$BUILDNOWIDX-1]="${BUILDLOG[$BUILDNOWIDX-1]} `echo $line | sed 's|.*autodist/log/||'`" fi ;; "=>") JOBON=1 ;; - "%!"|"!!") BUILDNOW[$BUILDNOWIDX-1]="${BUILDNOW[$BUILDNOWIDX-1]} $line"; JOBON= ;; - "==") [ "${2:0:2}" == "==" ] && JOBON= ;; + "%!"|"!!") BUILDNOWSTATUS[$BUILDNOWIDX-1]="$line"; JOBON= ;; + "==") if [ "${2:0:2}" == "==" ]; then + JOBON= +# else +# if [ "$2" != "${BUILDNOW[$BUILDNOWIDX-1]}" ]; then +# BUILDNOW[$BUILDNOWIDX]="$2" +# BUILDNOWIDX=`expr $BUILDNOWIDX + 1` +# fi + fi ;; "Hunk"|"") ;; *) [ "$JOBON" ] || { line=`echo $line | sed "s|.*\r||"` @@ -220,15 +234,18 @@ _EOF "%%" ) if [ "$2" == "Doing" ]; then if [ "$3" != "${BUILDNOW[$BUILDNOWIDX-1]}" ]; then BUILDNOW[$BUILDNOWIDX]="$3" + BUILDLOG[$BUILDNOWIDX]= + BUILDNOWSTATUS[$BUILDNOWIDX]= BUILDNOWIDX=`expr $BUILDNOWIDX + 1` fi JOBON=1 fi ;; "?=") if [ "$2" == "See" ]; then - BUILDLOG[$BUILDNOWIDX-1]=`echo $line | sed "s|.*autodist/log/||"` + BUILDLOG[$BUILDNOWIDX-1]="${BUILDLOG[$BUILDNOWIDX-1]} `echo $line | sed 's|.*autodist/log/||'`" +# BUILDLOG[$BUILDNOWIDX-1]=`echo $line | sed "s|.*autodist/log/||"` fi ;; "=>") JOBON=1 ;; - "%!"|"!!") BUILDNOW[$BUILDNOWIDX-1]="${BUILDNOW[$BUILDNOWIDX-1]} $line"; JOBON= ;; + "%!"|"!!") BUILDNOWSTATUS[$BUILDNOWIDX-1]="$line"; JOBON= ;; "==") [ "${2:0:2}" == "==" ] && JOBON= ;; "Hunk"|"") ;; *) [ "$JOBON" ] || echo $line ;; @@ -236,21 +253,46 @@ _EOF done < $AUTODISTLOGFILE LASTLINE=$line fi - echo "Start: $STARTTIME" - echo "Scheduled jobs: $SCHEDULED" - for b in `seq 1 ${#BUILDNOW[*]}`; do - set -- ${BUILDNOW[$b]} - if [ "${BUILDLOG[$b]}" ]; then - echo "$1: $2 $3 $4 $5 $6 " - elif [ "$1" ]; then - echo "$1: $2 $3 $4 $5 $6 " - fi - done - if [ "$LASTLINE" ]; then - set -- $LASTLINE - [ "$1" = "^" ] && echo "${2} ${3} ${4} ${5} ${6} ${7}" + echo "Start: $STARTTIME" + echo "Scheduled jobs: $SCHEDULED" + for b in `seq 0 ${#BUILDNOW[*]}`; do +# set -- ${BUILDNOW[$b]} + JOBNAME=${BUILDNOW[$b]} + [ "$JOBNAME" ] || continue + echo -n "$JOBNAME: " + rowcnt=0 + if [ "${BUILDLOG[$b]}" ]; then + for l in ${BUILDLOG[$b]}; do + SUBJOBNAME=`echo $l | sed "s|.*/${JOBNAME}_\(.*\)\..*|\1|"` + [ "${SUBJOBNAME:0:1}" = "_" ] && SUBJOBNAME=$l + [ "$SUBJOBNAME" = "$l" ] && SUBJOBNAME=`echo $l | sed "s|.*/\(.*\)\..*|\1|"` + OPERATIONNAME=`echo $l | sed "s|\(.*\)/.*/.*|\1|"` + OPERATIONSTATUS=`echo $l | sed "s|.*/\(.*\)/.*|\1|"` + if [ $rowcnt -ge 4 ]; then + echo + rowcnt=0 + fi + if [ "$OPERATIONNAME" = "send" -a "$OPERATIONSTATUS" = "ok" ]; then + echo -n "$OPERATIONNAME/$OPERATIONSTATUS" + elif [ "$OPERATIONNAME" = "install" -a "$OPERATIONSTATUS" = "ok" ]; then + echo -n "$OPERATIONNAME/$OPERATIONSTATUS" + elif [ "$OPERATIONSTATUS" = "ok" ]; then + echo -n "$OPERATIONNAME/$OPERATIONSTATUS" + else + echo -n "$OPERATIONNAME/$OPERATIONSTATUS" + fi + [ "$SUBJOBNAME" != "$JOBNAME" ] && echo -en "($SUBJOBNAME)" + echo -n " " + rowcnt=`expr $rowcnt + 1` + done fi - [ "$ENDTIME" ] && echo "End: $ENDTIME" || echo "End: in progress" + [ "${BUILDNOWSTATUS[$b]}" ] && echo "(${BUILDNOWSTATUS[$b]})" || echo + done + if [ "$LASTLINE" ]; then + set -- $LASTLINE + [ "$1" = "^" ] && echo "${2} ${3} ${4} ${5} ${6} ${7}" + fi + [ "$ENDTIME" ] && echo "End: $ENDTIME" || echo "End: in progress" echo # grep -v "^=" $LOGFILE | tail -n "$LINES" | sed "s|.*\r||" # echo