#!/bin/bash

set -e

which rename > /dev/null

pushd $(dirname $0) >/dev/null

pushd incoming
for i in *.changes; do
	[ -e $i ] && /afs/sur5r.net/pub/scripts/addbuildlog2changes $i
done
popd

reprepro processincoming incoming

pushd incoming
for log in $(find . -type f -name \*.build -printf %f\\n); do
  (find . -type l -name \*.build |xargs -r readlink )| grep -q $log && continue
  rm $log
done
popd

