#!/bin/sh
#===========================================================================#
# Cleanup pockets and buffers -- remove packets that already in ALT repos   #
#===========================================================================#

getname()
{
	echo ${1##*/}
}

in_sisyphus()
{
	if [ -f /var/lib/altlinux/sisyphus/files/SRPMS/"$1" ]; then
		return 0
	fi
	return 1
}
in_branch()
{
	if [ -f /var/lib/altlinux/4.0/branch/files/SRPMS/"$1" ]; then
		return 0
	fi
	return 1
}

for s in ~/development/repo/SRPMS.hasher/*.rpm; do
	N=`getname "$s"`
	E=""
	in_sisyphus $N && E="$E Sisyphus"
	[ -z "$E" ] || rm -f $s
done

for s in ~/development/pockets/backport/SRPMS.hasher/*.rpm; do
	N=`getname "$s"`
	E=""
	in_branch $N   && E="$E branch4.0"
	[ -z "$E" ] || rm -f $s
done

for s in ~/RPM/SRPMS/sent/*.src.rpm; do
	N=`getname "$s"`
	E=""
	in_sisyphus $N && E="$E Sisyphus"
	in_branch $N   && E="$E branch4.0"
	[ -z "$E" ] || rm -f $s
done
