autoport: generate an operation state file for better parsing by autodist cgi

This commit is contained in:
Silvan Calarco 2012-10-18 00:57:43 +02:00
parent 76032ddcb4
commit d3705b31c7

View File

@ -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 # for webbuild message
function cgi_encodevar() { function cgi_encodevar() {
@ -340,6 +349,8 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
fi fi
fi fi
done 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 fi
step=0 step=0
@ -347,12 +358,12 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
tmpfile1=`mktemp` tmpfile1=`mktemp`
[ -e $DATAARCHDIR/sentjobs ] || > $DATAARCHDIR/sentjobs [ -e $DATAARCHDIR/sentjobs ] || > $DATAARCHDIR/sentjobs
find $DATAARCHDIR/sentjobs -cmin 120 && { find $DATAARCHDIR/sentjobs -cmin 120 >/dev/null && {
> $DATAARCHDIR/sentjobs > $DATAARCHDIR/sentjobs
} }
[ -e $DATAARCHDIR/preparedjobs ] || > $DATAARCHDIR/preparedjobs [ -e $DATAARCHDIR/preparedjobs ] || > $DATAARCHDIR/preparedjobs
find $DATAARCHDIR/preparedjobs -ctime 1 && { find $DATAARCHDIR/preparedjobs -ctime 1 >/dev/null && {
> $DATAARCHDIR/preparedjobs > $DATAARCHDIR/preparedjobs
} }
@ -435,10 +446,12 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo "(FAILED) " echo "(FAILED) "
fi fi
JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT) JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT)
autoport_log ${JOB_CURRENT} prepare failed
continue continue
} || { } || {
echo $JOB_CURRENT >> $DATAARCHDIR/preparedjobs echo $JOB_CURRENT >> $DATAARCHDIR/preparedjobs
echo -n "(OK) " echo -n "(OK) "
autoport_log ${JOB_CURRENT} prepare ok
} }
if [ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ]; then if [ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ]; then
echo -n "update" 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 LANG=C LC_ALL=C autodist -u -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"automatic port from $PORT_REPOSITORY\" &>>$logfile
[ $? -gt 0 ] && { [ $? -gt 0 ] && {
echo "(FAILED) " echo "(FAILED) "
autoport_log ${JOB_CURRENT} update failed
continue continue
} || { } || {
autoport_log ${JOB_CURRENT} update ok
echo -n "(OK) " echo -n "(OK) "
} }
elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then
@ -474,16 +489,19 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo "(FAILED)" echo "(FAILED)"
JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'` JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'`
[ "$JOB_LOG" ] || JOB_LOG=$tmpfile [ "$JOB_LOG" ] || JOB_LOG=$tmpfile
autoport_log ${JOB_CURRENT} update failed $tmpfile
continue continue
} || { } || {
cat $tmpfile >> $logfile cat $tmpfile >> $logfile
echo -n "(OK) " echo -n "(OK) "
autoport_log ${JOB_CURRENT} update ok $tmpfile
} }
fi fi
} }
echo -n "port" echo -n "port"
if [ ! "$pkg_repository" -a "$DONT_PREPARE_THIS" != "1" ]; then if [ ! "$pkg_repository" -a "$DONT_PREPARE_THIS" != "1" ]; then
echo "(FAILED) [can't get repository information for this package]" echo "(FAILED) [can't get repository information for this package]"
autoport_log ${JOB_CURRENT} port failed
continue continue
fi fi
if [ "$DONT_PREPARE_THIS" = "1" -a "$pkg_repository" != "$PORT_REPOSITORY" ]; then 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=`grep "^?= See " $tmpfile | awk '{ print $3 }'`
[ "$JOB_LOG" ] || JOB_LOG=$tmpfile [ "$JOB_LOG" ] || JOB_LOG=$tmpfile
[ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG [ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG
autoport_log ${JOB_CURRENT} port failed $tmpfile
continue continue
} || { } || {
cat $tmpfile >> $logfile cat $tmpfile >> $logfile
JOB_SENT=(${JOB_SENT[*]} $JOB_CURRENT) JOB_SENT=(${JOB_SENT[*]} $JOB_CURRENT)
echo $JOB_CURRENT >> $DATAARCHDIR/sentjobs echo $JOB_CURRENT >> $DATAARCHDIR/sentjobs
echo -n "(OK) " echo -n "(OK) "
autoport_log ${JOB_CURRENT} port ok $tmpfile
if [ "$BATCH_MODE" -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then 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&\ curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$pkg_repository</b>\"`" >/dev/null MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$pkg_repository</b>\"`" >/dev/null
@ -542,6 +562,7 @@ MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and s
JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'` JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'`
[ "$JOB_LOG" ] || JOB_LOG=$tmpfile [ "$JOB_LOG" ] || JOB_LOG=$tmpfile
[ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG [ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG
autoport_log ${JOB_CURRENT} install failed $tmpfile
continue continue
} || { } || {
cat $tmpfile >> $logfile cat $tmpfile >> $logfile
@ -549,6 +570,7 @@ MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and s
JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT) JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT)
JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT) JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT)
echo -n "(OK)" echo -n "(OK)"
autoport_log ${JOB_CURRENT} install ok $tmpfile
} }
echo echo
done done
@ -595,6 +617,7 @@ MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and s
JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT) JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT)
JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT) JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT)
echo -n "(OK)" echo -n "(OK)"
autoport_log ${JOB_CURRENT} retryinstall ok $tmpfile
} }
echo echo
done done