epm-removerepo 2.7 KB
Newer Older
1 2
#!/bin/sh
#
Vitaly Lipatov's avatar
Vitaly Lipatov committed
3 4
# Copyright (C) 2012, 2017, 2020  Etersoft
# Copyright (C) 2012, 2017, 2020  Vitaly Lipatov <lav@etersoft.ru>
5
#
6 7 8
# 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
9 10 11 12 13
# (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
14
# GNU Affero General Public License for more details.
15
#
16 17
# 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/>.
18 19
#

20 21
load_helper epm-sh-altlinux

Vitaly Lipatov's avatar
Vitaly Lipatov committed
22 23 24 25 26
# remove grepped lines
__epm_removerepo_alt_grepremove()
{
	local rp
	epm repolist | grep -E "$1" | while read rp ; do
27
		sudocmd apt-repo $dryrun rm "$rp"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
28 29 30 31 32 33
	done
}

__epm_removerepo_alt()
{
	local repo="$*"
34
	[ -n "$repo" ] || fatal "No such repo or task. Use epm repo remove <autoimports|archive|tasks|TASKNUMBER>"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

	assure_exists apt-repo

	if tasknumber "$repo" >/dev/null ; then
		local tn
		for tn in $(tasknumber "$repo") ; do
			__epm_removerepo_alt_grepremove " repo/$tn/"
		done
		return
	fi

	case "$1" in
		autoimports)
			info "remove autoimports repo"
			[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
			repo="autoimports.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
51
			sudocmd apt-repo $dryrun rm "$repo"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65
			;;
		archive)
			info "remove archive repos"
			__epm_removerepo_alt_grepremove "archive/"
			;;
		tasks)
			info "remove task repos"
			__epm_removerepo_alt_grepremove " repo/[0-9]+/"
			;;
		task)
			shift
			__epm_removerepo_alt_grepremove " repo/$1/"
			;;
		*)
66
			sudocmd apt-repo $dryrun rm "$*"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
67 68 69 70 71
			;;
	esac

}

72 73
epm_removerepo()
{
74 75 76

case $DISTRNAME in
	ALTLinux)
77
		__epm_removerepo_alt "$@"
78
		return
79
		;;
80 81 82
esac;

case $PMTYPE in
83 84
	apt-dpkg)
		assure_exists apt-add-repository software-properties-common
85
		sudocmd apt-add-repository --remove "$@"
86 87 88
		info "Check file /etc/apt/sources.list if needed"
		;;
	aptitude-dpkg)
89
		info "You need remove repo from /etc/apt/sources.list"
90 91
		;;
	yum-rpm)
92
		assure_exists yum-utils
93
		sudocmd yum-config-manager --disable "$@"
94 95
		;;
	urpm-rpm)
96
		sudocmd urpmi.removemedia "$@"
97
		;;
98
	zypper-rpm)
99
		sudocmd zypper removerepo "$@"
100 101
		;;
	emerge)
102
		sudocmd layman "-d$@"
103 104
		;;
	pacman)
105
		info "You need remove repo from /etc/pacman.conf"
106
		;;
107
	npackd)
108
		sudocmd npackdcl remove-repo --url="$@"
109
		;;
110 111 112
	winget)
		sudocmd winget source remove "$@"
		;;
113
	slackpkg)
114
		info "You need remove repo from /etc/slackpkg/mirrors"
115 116
		;;
	*)
117
		fatal "Have no suitable command for $PMTYPE"
118 119 120 121
		;;
esac

}