epm-clean 2.03 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012,2014,2016  Etersoft
# Copyright (C) 2012,2014,2016  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 22
__remove_alt_apt_cache_file()
{
	sudocmd rm -vf /var/cache/apt/*.bin
23
	sudocmd rm -vf /var/cache/apt/partial/*
24 25 26 27
	sudocmd rm -vf /var/lib/apt/lists/*pkglist*
	sudocmd rm -vf /var/lib/apt/lists/*release*
}

28 29 30
__remove_deb_apt_cache_file()
{
	sudocmd rm -vf /var/cache/apt/*.bin
31
	sudocmd rm -vf /var/cache/apt/archives/partial/*
32 33 34 35 36
	sudocmd rm -vf /var/lib/apt/lists/*Packages*
	sudocmd rm -vf /var/lib/apt/lists/*Release*
	sudocmd rm -vf /var/lib/apt/lists/*Translation*
}

37 38
epm_clean()
{
39 40 41 42

[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"


Vitaly Lipatov's avatar
Vitaly Lipatov committed
43
case $PMTYPE in
44
	apt-rpm)
45
		sudocmd apt-get clean
46
		[ -n "$force" ] && __remove_alt_apt_cache_file
47
		;;
48 49
	apt-dpkg)
		sudocmd apt-get clean
50
		[ -n "$force" ] && __remove_deb_apt_cache_file
51
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
52 53
	aptitude-dpkg)
		sudocmd aptitude clean
54
		[ -n "$force" ] && __remove_deb_apt_cache_file
Vitaly Lipatov's avatar
Vitaly Lipatov committed
55
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
56
	yum-rpm)
57
		sudocmd yum clean all
58
		#sudocmd yum makecache
59
		;;
60 61 62
	dnf-rpm)
		sudocmd dnf clean all
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
63
	urpm-rpm)
64
		sudocmd urpmi --clean
65
		;;
66 67 68
	pacman)
		sudocmd pacman -Sc
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
69
	zypper-rpm)
70
		sudocmd zypper clean
71
		;;
72 73 74 75 76
	nix)
		sudocmd nix-collect-garbage
		;;
	slackpkg)
		;;
77
	pkgng)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
78
		sudocmd pkg clean -a
79
		;;
80 81 82
	xbps)
		sudocmd xbps-remove -O
		;;
83
	*)
84
		fatal "Have no suitable command for $PMTYPE"
85 86
		;;
esac
87
	info "It is recommend to run 'epm autoremove' also"
88 89

}