#!/bin/bash -e
# $Id: sisyphus_add_new,v 1.2 2003/11/02 12:04:05 ldv Exp $

. /etc/sisyphus/functions
. /etc/sisyphus/config

lock_incoming()
{
	cd "$START_DIR"
	chmod g-rw RPMS SRPMS
}

unlock_incoming()
{
	cd "$START_DIR"
	chmod g+rw RPMS SRPMS
}

exit_handler()
{
	local rc=$?
	trap - EXIT
	unlock_incoming
	exit $rc
}


lock_incoming
trap exit_handler EXIT HUP INT PIPE TERM QUIT

if ! cleanup_incoming RPMS/*.rpm SRPMS/*.rpm; then
	echo "ERROR: you have problems with your incoming files" >&2
	exit 1
fi

echo -n "Verifying repositories: "
check_incoming RPMS SRPMS
echo "done."

upload_bin_new RPMS
upload_src_new SRPMS

if ! cleanup_incoming RPMS/*.rpm SRPMS/*.rpm; then
	echo "ERROR: you have problems with your incoming files" >&2
	exit 1
fi

echo -n "Verifying repositories: "
check_incoming RPMS SRPMS
echo "done."

sisyphus_prepare
