From b7ca5efac9a1a21c0361ea964f870c2f4ada257c Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 28 Apr 2014 10:53:13 -0700 Subject: [PATCH] make buildd sign handle attempted builds and default to giving back --- buildd_sign | 89 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 18 deletions(-) diff --git a/buildd_sign b/buildd_sign index f202716..24fd610 100755 --- a/buildd_sign +++ b/buildd_sign @@ -1,26 +1,79 @@ -#!/bin/sh +#!/bin/bash +function mark_read { + if echo "$1"|grep -q 'RS$'; then + # do nothing + true; + elif echo "$1"|grep -q 'S$'; then + mv "${1}" "${1%%S}RS"; + else + mv "${1}" "${1}RS"; + if echo "$1"|grep -q 'new/'; then + rename 's{new/}{cur/}' "${1}RS"; + elif echo "$1"|grep -q 'cur' || pwd|egrep -q 'cur/?$'; then + # do nothing + true; + else + mv "${1}RS" ../cur/"${1}RS"; + fi; + fi; +} + #set -x; set -e; for a in "$@"; do - if egrep -q '^Subject: Log.+successful' "$a"; then RETURN_PATH=$(awk -F': ' '/^Return-Path:/{print $2}' "$a") SUBJECT=$(awk -F': ' '/^Subject:/{print $2}' "$a") KEY=9D05D0BE - TEMPDIR=$(mktemp -d) - cp "$a" "$TEMPDIR/reply" - buildd_script "$TEMPDIR/reply" - gpg --no-verbose --batch --quiet --default-key $KEY --armor --output $TEMPDIR/reply.signed --clearsign $TEMPDIR/reply >/dev/null 2>&1 - mutt -e 'set content_type="text/plain; charset=utf-8; x-action=pgp-signed"' -s "Re: $SUBJECT" "$RETURN_PATH" < $TEMPDIR/reply.signed - rm -f $TEMPDIR/reply $TEMPDIR/reply.signed - rmdir $TEMPDIR - mv "${a}" "${a}RS"; - if echo "$a"|grep -q 'new/'; then - rename 's{new/}{cur/}' "${a}RS"; - else - mv "${a}RS" ../cur/"${a}RS"; - fi; - echo "Handled '${SUBJECT}'"; - fi -done; \ No newline at end of file + if egrep -q '^Subject: Log.+successful' "$a"; then + TEMPDIR=$(mktemp -d) + cp "$a" "$TEMPDIR/reply" + buildd_script "$TEMPDIR/reply" + gpg --no-verbose --batch --quiet --default-key $KEY --armor --output $TEMPDIR/reply.signed --clearsign $TEMPDIR/reply >/dev/null 2>&1 + mutt -e 'set content_type="text/plain; charset=utf-8; x-action=pgp-signed"' -s "Re: $SUBJECT" "$RETURN_PATH" < $TEMPDIR/reply.signed + rm -f $TEMPDIR/reply $TEMPDIR/reply.signed + rmdir $TEMPDIR + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + elif egrep -q '^Subject: Log.+attempted' "$a" && + egrep -q "ERROR: a 'NAMESPACE' file is required" "$a"; then + echo 'fail no namespace'| \ + mutt -e 'set content_type="text/plain; charset=utf-8"' -s "Re: $SUBJECT" "$RETURN_PATH"; + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + elif egrep -q '^Subject: Log.+attempted' "$a" && + egrep -q "ERROR: dependency .* is not available for package .*" "$a"; then + (echo -n 'fail '; egrep "ERROR: dependency .* is not available for package .*" "$a")| \ + mutt -e 'set content_type="text/plain; charset=utf-8"' -s "Re: $SUBJECT" "$RETURN_PATH"; + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + elif egrep -q '^Subject: Log.+attempted' "$a" && + egrep -q "ERROR: compilation failed for package .*" "$a"; then + (echo -n 'fail '; grep "error|fail" "$a"|sed 's/\n//g')| \ + mutt -e 'set content_type="text/plain; charset=utf-8"' -s "Re: $SUBJECT" "$RETURN_PATH"; + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + elif egrep -q '^Subject: Log.+attempted' "$a" && + egrep -q "ERROR: configuration failed for package .*" "$a"; then + (echo -n 'fail '; grep "error|fail" "$a"|sed 's/\n//g')| \ + mutt -e 'set content_type="text/plain; charset=utf-8"' -s "Re: $SUBJECT" "$RETURN_PATH"; + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + elif egrep -q '^Subject: Log.+attempted' "$a" && + (egrep -q "Error *: package .* was found, but .* is required" "$a" || + egrep -q "Error *: package .* was built before R" "$a" + ); then + echo 'give back'| \ + mutt -e 'set content_type="text/plain; charset=utf-8"' -s "Re: $SUBJECT" "$RETURN_PATH"; + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + elif egrep -q '^Subject: Log.+attempted' "$a"; then + echo "Unsure about '$SUBJECT'; giving back"; + tail -n 30 "$a"; + echo 'give back'| \ + mutt -e 'set content_type="text/plain; charset=utf-8"' -s "Re: $SUBJECT" "$RETURN_PATH"; + mark_read "${a}"; + echo "Handled '${SUBJECT}'"; + fi; +done; -- 2.39.5