From d3705b31c73e913b5b94d39e5ecb86481dc243c4 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Thu, 18 Oct 2012 00:57:43 +0200 Subject: [PATCH] autoport: generate an operation state file for better parsing by autodist cgi --- autoport | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/autoport b/autoport index 74015fd..04d6786 100755 --- a/autoport +++ b/autoport @@ -43,6 +43,15 @@ ${me[0]} ${me[1]} } +function autoport_log() { + local pkg=$1 + local operation=$2 + local result=$3 + local logfile=$4 + + [ "$pkg" -a "$operation" -a "$result" ] || return + echo "$pkg $operation $result $logfile" >> /var/autodist/log/autoport-$PORT_REPOSITORY-current +} # for webbuild message function cgi_encodevar() { @@ -340,6 +349,8 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do fi fi done + [ -e /var/autodist/log/autoport-$PORT_REPOSITORY-current ] && \ + mv /var/autodist/log/autoport-$PORT_REPOSITORY-current /var/autodist/log/autoport-$PORT_REPOSITORY-last fi step=0 @@ -347,12 +358,12 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do tmpfile1=`mktemp` [ -e $DATAARCHDIR/sentjobs ] || > $DATAARCHDIR/sentjobs - find $DATAARCHDIR/sentjobs -cmin 120 && { + find $DATAARCHDIR/sentjobs -cmin 120 >/dev/null && { > $DATAARCHDIR/sentjobs } [ -e $DATAARCHDIR/preparedjobs ] || > $DATAARCHDIR/preparedjobs - find $DATAARCHDIR/preparedjobs -ctime 1 && { + find $DATAARCHDIR/preparedjobs -ctime 1 >/dev/null && { > $DATAARCHDIR/preparedjobs } @@ -435,10 +446,12 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do echo "(FAILED) " fi JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT) + autoport_log ${JOB_CURRENT} prepare failed continue } || { echo $JOB_CURRENT >> $DATAARCHDIR/preparedjobs echo -n "(OK) " + autoport_log ${JOB_CURRENT} prepare ok } if [ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ]; then echo -n "update" @@ -447,8 +460,10 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do LANG=C LC_ALL=C autodist -u -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"automatic port from $PORT_REPOSITORY\" &>>$logfile [ $? -gt 0 ] && { echo "(FAILED) " + autoport_log ${JOB_CURRENT} update failed continue } || { + autoport_log ${JOB_CURRENT} update ok echo -n "(OK) " } elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then @@ -474,16 +489,19 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do echo "(FAILED)" JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'` [ "$JOB_LOG" ] || JOB_LOG=$tmpfile + autoport_log ${JOB_CURRENT} update failed $tmpfile continue } || { cat $tmpfile >> $logfile echo -n "(OK) " + autoport_log ${JOB_CURRENT} update ok $tmpfile } fi } echo -n "port" if [ ! "$pkg_repository" -a "$DONT_PREPARE_THIS" != "1" ]; then echo "(FAILED) [can't get repository information for this package]" + autoport_log ${JOB_CURRENT} port failed continue fi if [ "$DONT_PREPARE_THIS" = "1" -a "$pkg_repository" != "$PORT_REPOSITORY" ]; then @@ -508,12 +526,14 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'` [ "$JOB_LOG" ] || JOB_LOG=$tmpfile [ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG + autoport_log ${JOB_CURRENT} port failed $tmpfile continue } || { cat $tmpfile >> $logfile JOB_SENT=(${JOB_SENT[*]} $JOB_CURRENT) echo $JOB_CURRENT >> $DATAARCHDIR/sentjobs echo -n "(OK) " + autoport_log ${JOB_CURRENT} port ok $tmpfile if [ "$BATCH_MODE" -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\ MESSAGE=`cgi_encodevar \"ported $JOB_CURRENT to $TARGET_ARCH and sent it to $pkg_repository\"`" >/dev/null @@ -542,6 +562,7 @@ MESSAGE=`cgi_encodevar \"ported $JOB_CURRENT to $TARGET_ARCH and s JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'` [ "$JOB_LOG" ] || JOB_LOG=$tmpfile [ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG + autoport_log ${JOB_CURRENT} install failed $tmpfile continue } || { cat $tmpfile >> $logfile @@ -549,6 +570,7 @@ MESSAGE=`cgi_encodevar \"ported $JOB_CURRENT to $TARGET_ARCH and s JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT) JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT) echo -n "(OK)" + autoport_log ${JOB_CURRENT} install ok $tmpfile } echo done @@ -595,6 +617,7 @@ MESSAGE=`cgi_encodevar \"ported $JOB_CURRENT to $TARGET_ARCH and s JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT) JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT) echo -n "(OK)" + autoport_log ${JOB_CURRENT} retryinstall ok $tmpfile } echo done