#!/bin/sh
set -x
BASEDIR=$(dirname $0)
FILE=$BASEDIR/failed.txt
echo "$BASEDIR/$1"
rpmbuild -ba $BASEDIR/$1 2> $FILE
ERNR=$(awk '$1 == "error:"{print NR}' $FILE)
echo "$ERNR"
for rpm in $(awk 'NR > $ERNR{print $1}' $FILE)
do
dnf install "$rpm"
done