#! /bin/sh

PROJECT=${PWD##*/}
: ${DISTRO:=openSUSE_10.3}
: ${ARCH:=x86_64}

for PACKAGE in $(osc ls $PROJECT) ; do
    # Read only first platform listed
    osc results $PACKAGE |
    while read XDISTRO XARCH STATUS ; do
	if test "$DISTRO" != "$XDISTRO" ; then
	    continue
	fi
	if test "$ARCH" != "$XARCH" ; then
	    continue
	fi
	LEAVE=true
	if test "${STATUS%: *}" = "failed" ; then
	    cd $PACKAGE
	    pkg-buildrequires-osc-update
	    cd ..
	fi
    done
done
