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

. /etc/sisyphus/config

cd "$PREFIX"

make_links()
{
	local source="$1"
	shift
	local target="$1"
	shift

	pushd "$PREFIX/$source" >/dev/null

	local rel=`relative "$PREFIX/$source" "$PREFIX/$target"`

	local f
	for f in *.rpm; do
		[ -f "$f" ] || continue
		ln -s "$rel/$f" "$PREFIX/$target"
	done
	popd >/dev/null
}

update_bin()
{
	find "$DISTRIBUTION"/RPMS.classic/ -type l -delete

	local rep
	for rep in $BIN_REPOSITORIES; do
		case "${rep##*RPMS.}" in
			core)
				continue
				;;
		esac
		make_links "$rep" "$DISTRIBUTION/RPMS.classic/"
	done
}

update_src()
{
	find SRPMS.classic/ -type l -delete

	local rep
	for rep in $SRC_REPOSITORIES; do
		case "${rep##SRPMS.}" in
			core)
				continue
				;;
		esac
		make_links "$rep" "SRPMS.classic/"
	done
}

update_bin
update_src
