epm-clean 2.24 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
[ -z "$*" ] || fatal "No arguments are allowed here"
41 42


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
	homebrew)
		sudocmd brew cleanup -s
		;;
69
	pacman)
70
		sudocmd pacman -Sc --noconfirm
71
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
72
	zypper-rpm)
73
		sudocmd zypper clean
74
		;;
75 76 77 78 79
	nix)
		sudocmd nix-collect-garbage
		;;
	slackpkg)
		;;
80 81 82
	eopkg)
		sudocmd eopkg delete-cache
		;;
83
	pkgng)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
84
		sudocmd pkg clean -a
85
		;;
86 87 88
	appget|winget)
		sudocmd $PMTYPE clean
		;;
89 90 91
	xbps)
		sudocmd xbps-remove -O
		;;
92
	*)
93
		fatal "Have no suitable command for $PMTYPE"
94 95
		;;
esac
96
	info "Note: Also you can try (with CAUTION) '# epm autoremove' and '# epm autoorphans' commands to remove obsoleted and unused packages."
97 98

}