#!/bin/bash

set -e

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

pushd incoming
/afs/sur5r.net/pub/scripts/addbuildlog2changes *.changes
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

