autodist cgi: lots of changes following webbuild development

This commit is contained in:
Silvan Calarco 2012-11-20 00:04:33 +01:00
parent 2f6984ed3b
commit 87a184e585

View File

@ -93,7 +93,7 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
LOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}.log"
LASTLOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}-last.log"
AUTODISTLOGFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log"
AUTODISTSTATEFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/var/autodist/autoport-$r-current"
AUTODISTSTATEFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/var/autodist/log/autoport-$r-current"
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
LOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}.log"
LASTLOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}-last.log"
@ -122,24 +122,15 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
echo -n ":</h2>"
cat << _EOF
<div class=downloadbox align=center>
<div align=left style="height: 550px; width: 850px;overflow:auto;font-size:8pt;border:1px solid #2b6600;margin:4px;padding:2px;color:lightgray;background-color:black;">
<div class=output align=left style="height:550px;width:850px;">
<!--overflow:auto;font-size:8pt;border:1px solid #2b6600;margin:4px;padding:2px;color:lightgray;background-color:black;"-->
_EOF
echo -n "<pre><code>"
if [ "$SHOWLOG" = "current" ]; then
RELOADTIME=3600000
cat $LOGFILE | parse_build_output
# sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
# s|^\([\+#] .*\)|<font style=\"color:gray\">\1</font>|;
# s|\(.*error[[:space:]]*:.*\)|<font style=\"background-color:red;color:white\">\1</font>|i;
# s|^\(== =.*\)|<font style=\"background-color:green;color:white\">\1</font>|;
# s|^\([%?=][!=>] .*\)|<font style=\"color:white\">\1</font>|;"
elif [ "$SHOWLOG" = "last" ]; then
cat $LASTLOGFILE | parse_build_output
# sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
# s|^\([\+#] .*\)|<font style=\"color:gray\">\1</font>|;
# s|\(.*error[[:space:]]*:.*\)|<font style=\"background-color:red;color:white\">\1</font>|i;
# s|^\(== =.*\)|<font style=\"background-color:green;color:white\">\1</font>|;
# s|^\([%?=][!=>] .*\)|<font style=\"color:white\">\1</font>|;"
else
# Security check
[ "${SHOWLOG/\/\.}" != "${SHOWLOG}" ] && continue
@ -154,19 +145,14 @@ _EOF
echo "<table style=\"color:black\"><tr><td colspan=3>Last ${SHOWLOGPKG} logs:</td>"
for t in prepare update build install send; do
echo -n "<tr><td>$t:</td><td>"
[ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$HOST_ADD&SHOWLOG=${t}/ok/${SHOWLOGPKG}\">OK</a></td>" || echo "<td></td>"
[ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$HOST_ADD&SHOWLOG=${t}/failed/${SHOWLOGPKG}\">FAILED</a></td>" || echo "<td></td>"
[ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "<td><a style=\"color:green;text-decoration:none\" target=_autodist href=\"?NUM=$i$HOST_ADD&SHOWLOG=${t}/ok/${SHOWLOGPKG}\">OK</a></td>" || echo "<td></td>"
[ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "<td><a style=\"color:green;text-decoration:none\" target=_autodist href=\"?NUM=$i$HOST_ADD&SHOWLOG=${t}/failed/${SHOWLOGPKG}\">FAILED</a></td>" || echo "<td></td>"
echo "</tr>"
done
echo "</table>"
fi
[ -e ${BUILDLOGDIR}${SHOWLOG} ] && \
cat ${BUILDLOGDIR}${SHOWLOG} | parse_build_output
# sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
# s|^\([\+#] .*\)|<font style=\"color:gray\">\1</font>|;
# s|\(.*error:.*\)|<font style=\"background-color:red;color:white\">\1</font>|i;
# s|^\(== =.*\)|<font style=\"background-color:green;color:white\">\1</font>|;
# s|^\([%?=][!=>] .*\)|<font style=\"color:white\">\1</font>|;"
fi
echo -n "</pre></code>"
echo -n "</div></div>"
@ -178,29 +164,30 @@ _EOF
[[ "$NUM" && "$NUM" != "$i" ]] && continue
[[ "$HOST" = "$AS_HOST" ]] || continue
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:autodist update)"
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
echo "<b>* <a target=_autodist href=\"?NUM=$i&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:autodist update)"
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a target=_autodist href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
fi
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:chroot autoport</a> chroot:${AUTOPORT_CHROOT[$i]})"
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
echo "<b>* <a target=_autodist href=\"?NUM=$i&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:chroot autoport</a> chroot:${AUTOPORT_CHROOT[$i]})"
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a target=_autodist href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
fi
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:native autoport)"
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
echo "<b>* <a target=_autodist href=\"?NUM=$i&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:native autoport)"
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a target=_autodist href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
fi
if [ "${AUTOPORT_CROSS[$i]}" ]; then
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">cross-platform</a> autoport (arch:${AUTOPORT_CROSS[$i]})</b>"
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">last</a> ]</b>"
echo "<b>* <a target=_autodist href=\"?NUM=$i&HOST=$AS_HOST\">cross-platform</a> autoport (arch:${AUTOPORT_CROSS[$i]})</b>"
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">last</a> ]</b>"
fi
cat << _EOF
<div class=downloadbox align=center>
<div align=left style="background-color: white; height: 250px; width: 850px; overflow: auto; font-size: 8pt; border:1px solid #2b6600; margin: 4px; padding:4; background-color: #e0f2d0;">
_EOF
echo "<pre>"
unset BUILDNOWIDX BUILDLOG BUILDNOW BUILDNOWSTATUS SCHEDULED STARTTIME AUTODIST_PID ENDTIME
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
BUILDNOWIDX=0
STARTTIME=`head $LOGFILE | grep "%% Autodist started" | sed "s|.* @ ||"`
@ -223,83 +210,43 @@ _EOF
BUILDNOWSTATUS[$BUILDNOWIDX]=
BUILDNOWIDX=`expr $BUILDNOWIDX + 1`
done < $STATEFILE
elif [ -e $AUTODISTSTATEFILE ]; then
BUILDNOWIDX=0
else
STARTTIME=`head $LOGFILE | grep "^+ .*start at " | sed "s|.*start at ||"`
# AUTODIST_PID=`head $LOGFILE | grep "%% Autodist started" | sed "s|.*PID \([0-9]*\) .*|\1|"`
SCHEDULED=`head -n 40 $LOGFILE | grep -m 1 "^> .*Scheduled jobs: " | sed "s|.*Scheduled jobs: ||"`
ENDTIME=`tail $LOGFILE | grep "^- .*end at " | sed "s|.*end at ||"`
while read line; do
set -- $line
for c in `seq 0 ${#BUILDNOW[*]}`; do
if [ "${BUILDNOW[c]}" = "$1" ]; then
BUILDNOWIDX=$c
break
if [ -e "$AUTODISTSTATEFILE" ]; then
while read line; do
set -- $line
for c in `seq 0 ${#BUILDNOW[*]}`; do
if [ "${BUILDNOW[c]}" = "$1" ]; then
BUILDNOWIDX=$c
break
else
BUILDNOWIDX=$c
fi
done
BUILDNOW[$BUILDNOWIDX]="$1"
if [ "$2" = "port" ]; then
CURRLOGFILE=build/$3/$1.${AUTOPORT_ARCH[$i]}
else
BUILDNOWIDX=$c
CURRLOGFILE=$2/$3/$1.${AUTOPORT_ARCH[$i]}
fi
BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $CURRLOGFILE"
# BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $2/$3/$1.i586"
BUILDNOWSTATUS[$BUILDNOWIDX]=
BUILDNOWIDX=`expr $BUILDNOWIDX + 1`
done < $AUTODISTSTATEFILE
for p in `dirname $LOGFILE`/current.*; do
CURRENT_FILE=`basename $p`
AUTODIST_PID=${p/*.}
[ -e /proc/$AUTODIST_PID ] && break
AUTODIST_PID=
done
BUILDNOW[$BUILDNOWIDX]="$1"
if [ "$2" = "port" ]; then
CURRLOGFILE=build/$3/$1.${AUTOPORT_ARCH[$i]}
else
CURRLOGFILE=$2/$3/$1.${AUTOPORT_ARCH[$i]}
fi
BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $CURRLOGFILE"
# BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $2/$3/$1.i586"
BUILDNOWSTATUS[$BUILDNOWIDX]=
BUILDNOWIDX=`expr $BUILDNOWIDX + 1`
done < $AUTODISTSTATEFILE
else
unset STARTTIME ENDTIME BUILDNOW BUILDLOG AUTODISTON LASTLINE SCHEDULED
while read line; do
line=`echo $line | sed "s|.*\r||"`
set -- $line
case $1 in
"%%" ) AUTODISTON=1 ;;
"^"|"="*|""|"!"|"|"|"#"|"->") ;; #comment
"+") [ "$STARTTIME" ] || STARTTIME=`echo $line | sed "s|.*start at ||"` ;;
"-") ENDTIME=`echo $line | sed "s|.*end at ||"` ;;
[A-Za-z0-9]*) ;;
">") [ "$SCHEDULED" ] || SCHEDULED=`echo $line | sed "s|.*Scheduled jobs: ||"` ;;
*) [ ! "$AUTODISTON" ] && echo $line ;;
esac
done < $LOGFILE
BUILDNOWIDX=1
while read line; do
line=`echo $line | sed "s|.*\r||"`
set -- $line
case $1 in
"%%" ) 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]="${BUILDLOG[$BUILDNOWIDX-1]} `echo $line | sed 's|.*autodist/log/||'`"
# BUILDLOG[$BUILDNOWIDX-1]=`echo $line | sed "s|.*autodist/log/||"`
fi ;;
"=>") JOBON=1 ;;
"%!"|"!!") BUILDNOWSTATUS[$BUILDNOWIDX-1]="$line"; JOBON= ;;
"==") [ "${2:0:2}" == "==" ] && JOBON= ;;
"Hunk"|"") ;;
*) [ "$JOBON" ] || echo $line ;;
esac
done < $AUTODISTLOGFILE
for p in `dirname $LOGFILE`/current.*; do
CURRENT_FILE=`basename $p`
AUTODIST_PID=${p/*.}
[ -e /proc/$AUTODIST_PID ] && break
AUTODIST_PID=
done
LASTLINE=$line
fi
fi
echo "<b>Start:</b> $STARTTIME"
echo "<b>Scheduled jobs:</b> $SCHEDULED"
[ "$STARTTIME" ] && echo "<b>Start:</b> $STARTTIME"
[ "$SCHEDULED" ] && echo "<b>Scheduled jobs:</b> $SCHEDULED"
LASTJOBNAME=
for b in `seq 0 ${#BUILDNOW[*]}`; do
# set -- ${BUILDNOW[$b]}
@ -307,7 +254,7 @@ _EOF
[ "$JOBNAME" ] || continue
if [ "$JOBNAME" != "$LASTJOBNAME" ]; then
[ "$LASTJOBNAME" -a "$JOBNAME" ] && echo ""
echo -n "<a href=\"/distribution/webbuild.php?ENVIRONMENT=$i&PACKAGE=$JOBNAME\" target=\"webbuild\"><b>$JOBNAME</b></a>: "
echo -n "<a target=_webbuild href=\"/distribution/webbuild.php?ENVIRONMENT=$i&PACKAGE=$JOBNAME\"><b>$JOBNAME</b></a>: "
fi
rowcnt=0
if [ "${BUILDLOG[$b]}" ]; then
@ -324,16 +271,17 @@ _EOF
# echo
# rowcnt=0
# fi
if [ "$OPERATIONNAME" = "send" -a "$OPERATIONSTATUS" = "ok" ]; then
echo -n "<a href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\">$OPERATIONNAME:$OPERATIONSTATUS</a>"
elif [ "$OPERATIONNAME" = "install" -a "$OPERATIONSTATUS" = "ok" ]; then
echo -n "<a href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\">$OPERATIONNAME:$OPERATIONSTATUS</a>"
elif [ "$OPERATIONSTATUS" = "ok" ]; then
echo -n "<a href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\"><font color=black>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
else
echo -n "<a href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\"><font color=red>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
fi
[ "$SUBJOBNAME" != "$JOBNAME" ] && echo -en "(<a href=\"/distribution/webbuild.php?ENVIRONMENT=$i&PACKAGE=$SUBJOBNAME\" target=\"webbuild\">$SUBJOBNAME</a>)"
case $OPERATIONNAME-$OPERATIONSTATUS in
build-ok|send-ok|install-ok|retryinstall-ok)
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\">$OPERATIONNAME:$OPERATIONSTATUS</a>"
;;
*-failed)
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\"><font color=red>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
;;
*) echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i$HOST_ADD\"><font color=black>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
;;
esac
# [ "$SUBJOBNAME" != "$JOBNAME" ] && echo -en "(<a href=\"/distribution/webbuild.php?ENVIRONMENT=$i&PACKAGE=$SUBJOBNAME\" target=\"webbuild\">$SUBJOBNAME</a>)"
echo -n " "
rowcnt=`expr $rowcnt + 1`
done
@ -342,13 +290,11 @@ _EOF
LASTJOBNAME=$JOBNAME
done
[ "$LASTJOBNAME" ] && echo
if [ "$LASTLINE" ]; then
set -- $LASTLINE
[ "$1" = "^" ] && echo "<font color=red><b>${2}</b> ${3} ${4} ${5} ${6} ${7}</font>"
if [ "$ENDTIME" ]; then
echo "<b>End:</b> $ENDTIME"
elif [ "$AUTODIST_PID" ]; then
echo "<b>End: <a target=_autodist href=\"?SHOWLOG=current.$AUTODIST_PID&NUM=$i$HOST_ADD\">in progress</a></b>"
fi
[ "$ENDTIME" ] && \
echo "<b>End:</b> $ENDTIME" || \
echo "<b>End: <a href=\"?SHOWLOG=current.$AUTODIST_PID&NUM=$i$HOST_ADD\">in progress</a></b>"
echo
# grep -v "^=" $LOGFILE | tail -n "$LINES" | sed "s|.*\r||"
# echo