#!/bin/bash

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

if [ x"$1" = x"-a" ]; then
	dists=$(find dists -mindepth 1 -maxdepth 1 -type d -printf %P\\n | grep -v upstream-sources | grep -v testing)
else
	for dist in $(distro-info --all) $(ubuntu-distro-info --all); do
		[ -d dists/$dist ] && dists="$dists $dist"
	done
fi

for dist in $dists; do
    reprepro build-needing $dist any | sed s/^/$dist\ /
done | while read dist package version dscpath architecture; do
    echo ${dist} ${architecture} $PWD/$dscpath
done

popd >/dev/null
