#!/bin/sh
#
# Copyright (C) 2012, 2017  Etersoft
# Copyright (C) 2012, 2017  Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

epm_removerepo()
{
local repo="$(eval echo $quoted_args)"

case $DISTRNAME in
	ALTLinux)
		case "$repo" in
			autoimports)
				info "remove autoimports repo"
				[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
				repo="$repo.$(echo "$DISTRVERSION" | tr "[A-Z]" "[a-z]")"
				;;
		esac

		assure_exists apt-repo
		sudocmd apt-repo rm "$repo"
		return
		;;
esac;

case $PMTYPE in
	apt-dpkg|aptitude-dpkg)
		info "You need remove repo from /etc/apt/sources.list"
		;;
	yum-rpm)
		assure_exists yum-utils
		sudocmd yum-config-manager --disable "$repo"
		;;
	urpm-rpm)
		sudocmd urpmi.removemedia "$repo"
		;;
	zypper-rpm)
		sudocmd zypper removerepo "$repo"
		;;
	emerge)
		sudocmd layman "-d$repo"
		;;
	pacman)
		info "You need remove repo from /etc/pacman.conf"
		;;
	npackd)
		sudocmd npackdcl remove-repo --url="$repo"
		;;
	slackpkg)
		info "You need remove repo from /etc/slackpkg/mirrors"
		;;
	*)
		fatal "Have no suitable command for $PMTYPE"
		;;
esac

}