From 6e2a4ded8c14eafb6d90cb9f138099c62f8ef4c7 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 26 May 2012 13:28:28 +0200 Subject: [PATCH] autodist-cgi: add support for local autodist update and some parsing improvements --- autodist-cgi | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/autodist-cgi b/autodist-cgi index 18114d4..1e341fc 100755 --- a/autodist-cgi +++ b/autodist-cgi @@ -10,17 +10,16 @@ LINES=`echo "$QUERY_STRING" | sed -n 's/^.*LINES=\([^&]*\).*$/\1/p' | sed "s/%20 [ "$LINES" ] || LINES=5 [ "$SECONDARY" ] && SECONDARY_ADD="&SECONDARY=1" -if [ "$SHOWLOG" -o "$SHOWLASTLOG" ]; then - echo -e "Content-type: text/plain; charset=UTF-8\n\n" -else - echo -e "Content-type: text/html; charset=UTF-8\n\n" -fi +echo -e "Content-type: text/html; charset=UTF-8\n\n" for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do [ "${AUTOPORT_ARCH[$i]}" ] || 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" LASTLOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}-last.log" elif [ "${AUTOPORT_NATIVE[$i]}" ]; then @@ -35,14 +34,18 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do if [ "$SHOWLOG" -a "$NUM" = "$i" ]; then if [ ! "$SECONDARY" ]; then + echo "
"
          cat $LOGFILE
+         echo "
" else curl "$AUTOPORT_CGI_SECONDARY?SHOWLOG=1&NUM=$i" fi exit 0 elif [ "$SHOWLASTLOG" -a "$NUM" = "$i" ]; then if [ ! "$SECONDARY" ]; then + echo "
"
          cat $LASTLOGFILE
+         echo "
" else curl "$AUTOPORT_CGI_SECONDARY?SHOWLASTLOG=1&NUM=$i" fi @@ -50,22 +53,27 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do elif [ ! "$SHOWLOG" -a ! "$SHOWLASTLOG" ]; then [[ "$NUM" && "$NUM" != "$i" ]] && continue + if [ "${AUTOPORT_UPDATE[$i]}" ]; then + echo "* autodist update (host:`hostname -s`,arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]})" + echo " [ last ]" + fi + if [ "${AUTOPORT_CHROOT[$i]}" ]; then - echo "* chroot autoport (arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]},chroot:${AUTOPORT_CHROOT[$i]})" + echo "* chroot autoport (host:`hostname -s`,arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]},chroot:${AUTOPORT_CHROOT[$i]})" echo " [ last ]" fi if [ "${AUTOPORT_NATIVE[$i]}" ]; then - echo "* native autoport (arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]})" + echo "* native autoport (host:`hostname -s`,arch:${AUTOPORT_ARCH[$i]},channels:${AUTOPORT_REPOSITORIES[$i]})" echo " [ last ]" fi if [ "${AUTOPORT_CROSS[$i]}" ]; then - echo "* cross-platform autoport (${AUTOPORT_CROSS[$i]})" + echo "* cross-platform autoport (host:`hostname -s`,arch:${AUTOPORT_CROSS[$i]})" echo " [ last ]" fi echo "
"
-      grep -v "^=" $LOGFILE | tail -n "$LINES"
+      grep -v "^=" $LOGFILE | tail -n "$LINES" | sed "s|.*\r||"
       echo
       echo "
" fi