#!/bin/sh
#=============================================================================#
#              Try to import all packages from some dir to gear repo          #
#=============================================================================#
# (c) Denis Smirnov                                               14 Oct 2006 #
#=============================================================================#
# TODO: sort package by date (or by version)
# TODO: test that packages has name '$1' not '$1-*'
set +e
P=$1
if [ "v$P" == "v" ]; then
    exit -1
fi
if [ -f "$P" ]; then
    echo "File $P exists!"
    exit -1
fi
mkdir $P
pushd $P
if [ ! -d .git ]; then
	git-init-db
	echo "URL: git.alt:packages/$P" > .git/remotes/origin
	echo "Push: refs/heads/master:refs/heads/master" >> .git/remotes/origin
	echo "Pull: refs/heads/master:refs/heads/master" >> .git/remotes/origin
	ssh git.alt git-init-db "$P"
fi
gear-srpmimport ../$P-*.src.rpm
git push --all
popd

