autodist-cgi: add support for local autodist update and some parsing improvements

This commit is contained in:
Silvan Calarco 2012-05-26 13:28:28 +02:00
parent ada79d6f76
commit 6e2a4ded8c

View File

@ -10,17 +10,16 @@ LINES=`echo "$QUERY_STRING" | sed -n 's/^.*LINES=\([^&]*\).*$/\1/p' | sed "s/%20
[ "$LINES" ] || LINES=5 [ "$LINES" ] || LINES=5
[ "$SECONDARY" ] && SECONDARY_ADD="&SECONDARY=1" [ "$SECONDARY" ] && SECONDARY_ADD="&SECONDARY=1"
if [ "$SHOWLOG" -o "$SHOWLASTLOG" ]; then echo -e "Content-type: text/html; charset=UTF-8\n\n"
echo -e "Content-type: text/plain; charset=UTF-8\n\n"
else
echo -e "Content-type: text/html; charset=UTF-8\n\n"
fi
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "${AUTOPORT_ARCH[$i]}" ] || continue [ "${AUTOPORT_ARCH[$i]}" ] || continue
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
if [ "${AUTOPORT_CHROOT[$i]}" ]; then if [ "${AUTOPORT_UPDATE[$i]}" ]; then
LOGFILE="/var/autodist/log/autodist.log"
LASTLOGFILE="/var/autodist/log/autodist-last.log"
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
LOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}.log" LOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}.log"
LASTLOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}-last.log" LASTLOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}-last.log"
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
@ -35,14 +34,18 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
if [ "$SHOWLOG" -a "$NUM" = "$i" ]; then if [ "$SHOWLOG" -a "$NUM" = "$i" ]; then
if [ ! "$SECONDARY" ]; then if [ ! "$SECONDARY" ]; then
echo "<pre>"
cat $LOGFILE cat $LOGFILE
echo "</pre>"
else else
curl "$AUTOPORT_CGI_SECONDARY?SHOWLOG=1&NUM=$i" curl "$AUTOPORT_CGI_SECONDARY?SHOWLOG=1&NUM=$i"
fi fi
exit 0 exit 0
elif [ "$SHOWLASTLOG" -a "$NUM" = "$i" ]; then elif [ "$SHOWLASTLOG" -a "$NUM" = "$i" ]; then
if [ ! "$SECONDARY" ]; then if [ ! "$SECONDARY" ]; then
echo "<pre>"
cat $LASTLOGFILE cat $LASTLOGFILE
echo "</pre>"
else else
curl "$AUTOPORT_CGI_SECONDARY?SHOWLASTLOG=1&NUM=$i" curl "$AUTOPORT_CGI_SECONDARY?SHOWLASTLOG=1&NUM=$i"
fi fi
@ -50,22 +53,27 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
elif [ ! "$SHOWLOG" -a ! "$SHOWLASTLOG" ]; then elif [ ! "$SHOWLOG" -a ! "$SHOWLASTLOG" ]; then
[[ "$NUM" && "$NUM" != "$i" ]] && continue [[ "$NUM" && "$NUM" != "$i" ]] && continue
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">autodist update</a> (host:`hostname -s`,arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]})"
echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
fi
if [ "${AUTOPORT_CHROOT[$i]}" ]; then if [ "${AUTOPORT_CHROOT[$i]}" ]; then
echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">chroot autoport</a> (arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]},chroot:${AUTOPORT_CHROOT[$i]})" echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">chroot autoport</a> (host:`hostname -s`,arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]},chroot:${AUTOPORT_CHROOT[$i]})"
echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>" echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
fi fi
if [ "${AUTOPORT_NATIVE[$i]}" ]; then if [ "${AUTOPORT_NATIVE[$i]}" ]; then
echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">native autoport</a> (arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]})</b>" echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">native autoport</a> (host:`hostname -s`,arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]})"
echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>" echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
fi fi
if [ "${AUTOPORT_CROSS[$i]}" ]; then if [ "${AUTOPORT_CROSS[$i]}" ]; then
echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">cross-platform</a> autoport (${AUTOPORT_CROSS[$i]})</b>" echo "<b>* <a href=\"?SHOWLOG=1&NUM=$i$SECONDARY_ADD\">cross-platform</a> autoport (host:`hostname -s`,arch:${AUTOPORT_CROSS[$i]})</b>"
echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>" echo " [ <a href=\"?SHOWLASTLOG=1&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
fi fi
echo "<br><pre>" echo "<br><pre>"
grep -v "^=" $LOGFILE | tail -n "$LINES" grep -v "^=" $LOGFILE | tail -n "$LINES" | sed "s|.*\r||"
echo echo
echo "</pre>" echo "</pre>"
fi fi