From 0be3a1fc97ea1987b5a1435382398f4e3b5862bc Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 11 Jul 2012 22:36:11 +0200 Subject: [PATCH] autodist cgi: lots of improvements in interface output and other fixes --- autodist-cgi | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/autodist-cgi b/autodist-cgi index adb423d..c6f7c92 100755 --- a/autodist-cgi +++ b/autodist-cgi @@ -13,7 +13,7 @@ LINES=`echo "$QUERY_STRING" | sed -n 's/^.*LINES=\([^&]*\).*$/\1/p' | sed "s/%20 echo -e "Content-type: text/html; charset=UTF-8\n\n" -[ ! "$AS_SECONDARY" ] && echo "Show: ALL " +[ ! "$AS_SECONDARY" ] && echo "Build environments: [ALL]
" [ "$SHOWINDEX" -o ! "$AS_SECONDARY" ] && \ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do @@ -34,13 +34,17 @@ done if [ "$SHOWINDEX" ]; then exit 0 else - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWINDEX=1" + curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWINDEX=1" 2>/dev/null fi -[ ! "$AS_SECONDARY" ] && echo "
" +[ ! "$AS_SECONDARY" ] && echo "
" [ ! "$SHOWLOG" -a "$SECONDARY" = "$AS_SECONDARY" ] && echo "

Host: `hostname -s` (`uname -m`, kernel `uname -r`)

" +if [ "$SHOWLOG" -a "$SECONDARY" != "$AS_SECONDARY" ]; then + curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWLOG=$SHOWLOG&NUM=$NUM&LOG=$LOG" 2>/dev/null +else + for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do [ "${AUTOPORT_ARCH[$i]}" ] || continue [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue @@ -64,7 +68,12 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do fi if [ "$SHOWLOG" ]; then if [ "$SECONDARY" = "$AS_SECONDARY" -a "$NUM" = "$i" ]; then - echo "
"
+         echo "

$SHOWLOG log in ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}):

" + cat << _EOF +
+
+_EOF + echo -n "
"
          if [ "$SHOWLOG" = "current" ]; then
             cat $LOGFILE | sed "s|<|\<|g"
          elif [ "$SHOWLOG" = "last" ]; then
@@ -77,11 +86,8 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
             fi
             [ -e $BUILDLOGFILE ] && cat $BUILDLOGFILE | sed "s|<|\<|g"
          fi
-         echo "
" - else - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWLOG=$SHOWLOG&NUM=$i&LOG=$LOG" + echo "
" fi - exit 0 elif [ ! "$SHOWLOG" ]; then [[ "$NUM" && "$NUM" != "$i" ]] && continue [[ "$SECONDARY" = "$AS_SECONDARY" ]] || continue @@ -104,6 +110,10 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do echo "* cross-platform autoport (arch:${AUTOPORT_CROSS[$i]})" echo " [ last ]" fi + cat << _EOF +
+
+_EOF echo "
"
       if [ "${AUTOPORT_UPDATE[$i]}" ]; then
          unset STARTTIME ENDTIME JOBON BUILDNOW BUILDLOG SCHEDULED
@@ -156,7 +166,7 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
                *) [ ! "$AUTODISTON" ] && echo $line ;;
             esac
          done < $LOGFILE
-         BUILDNOWIDX=0
+         BUILDNOWIDX=1
          while read line; do
             line=`echo $line | sed "s|.*\r||"`
             set -- $line
@@ -183,10 +193,10 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
          echo "Start: $STARTTIME"
          echo "Scheduled jobs: $SCHEDULED"
          for b in `seq 1 ${#BUILDNOW[*]}`; do
-            set -- ${BUILDNOW[$b-1]}
-            if [ "${BUILDLOG[$b-1]}" ]; then
-               echo "$1: $2 $3 $4 $5 $6 "
-            else
+            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
@@ -198,13 +208,15 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
       echo 
 #      grep -v "^=" $LOGFILE | tail -n "$LINES" | sed "s|.*\r||"
 #      echo
-      echo "
" + echo "
" fi done if [ "$AUTOPORT_CGI_SECONDARY" -a ! "$SHOWLOG" ]; then if [ "$NUM" -a "$SECONDARY" ]; then - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES&NUM=$NUM&SECONDARY=$SECONDARY" + curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES&NUM=$NUM&SECONDARY=$SECONDARY" 2>/dev/null elif [ ! "$NUM" ]; then - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES" + curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES" 2>/dev/null fi fi +fi +[ ! "$AS_SECONDARY" ] && echo "

Generated by autodist CGI interface. Last update: `date`"