#!/bin/bash

tmp="$(mktemp /tmp/updates.XXXXXX)"

/usr/sbin/zypp-checkpatches-wrapper | xsltproc patch2mail.xsl - > "$tmp"
grep "ERROR\|^__TOTAL__[^0][^0]" "$tmp" >/dev/null || {
	rm -f "$tmp"
	exit 0 # no updates, no errors
}

# mail -s "$(hostname) updates" root < "$tmp"
echo "*** $(hostname) updates ***"; cat "$tmp"
rm -f "$tmp" 
