#!/bin/sh

branch_name="$(git branch --show-current)"

if [ $# = 0 ]; then
	rsync -P -r "${XBPS_DISTDIR}/hostdir/binpkgs/${branch_name}" daybreak:
	rsync -P -r "${XBPS_DISTDIR}/hostdir/binpkgs/${branch_name}" epoch:
elif [ "$1" = "repo" ]; then
	cd "${XBPS_DISTDIR}/hostdir/binpkgs/${branch_name}"
	for p in *.xbps; do
		rsync -P $p daybreak:/srv/repo
		ssh daybreak "xbps-rindex --add /srv/repo/$p;
		xbps-rindex --privkey /srv/repo/private.pem --sign-pkg /srv/repo/*.xbps"
	done
else
	rsync -P -r "${XBPS_DISTDIR}/hostdir/binpkgs/${branch_name}" "$1":
fi