epm-clean 2.56 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
__remove_alt_apt_cache_file()
{
22 23 24 25
    sudocmd rm -vf /var/cache/apt/*.bin
    sudocmd rm -vf /var/cache/apt/partial/*
    sudocmd rm -vf /var/lib/apt/lists/*pkglist*
    sudocmd rm -vf /var/lib/apt/lists/*release*
26 27
}

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

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    apt-rpm)
        sudocmd apt-get clean
        [ -n "$force" ] && __remove_alt_apt_cache_file
        ;;
    apt-dpkg)
        sudocmd apt-get clean
        [ -n "$force" ] && __remove_deb_apt_cache_file
        ;;
    aptitude-dpkg)
        sudocmd aptitude clean
        [ -n "$force" ] && __remove_deb_apt_cache_file
        ;;
    yum-rpm)
        sudocmd yum clean all
        #sudocmd yum makecache
        ;;
    dnf-rpm)
        sudocmd dnf clean all
        ;;
    urpm-rpm)
        sudocmd urpmi --clean
        ;;
    homebrew)
        sudocmd brew cleanup -s
        ;;
    pacman)
        sudocmd pacman -Sc --noconfirm
        ;;
    zypper-rpm)
        sudocmd zypper clean
        ;;
    nix)
        sudocmd nix-collect-garbage
        ;;
    slackpkg)
        ;;
    eopkg)
        sudocmd eopkg delete-cache
        ;;
    pkgng)
        sudocmd pkg clean -a
        ;;
86 87
    appget)
        sudocmd appget clean
88 89 90 91
        ;;
    xbps)
        sudocmd xbps-remove -O
        ;;
92 93 94
    termux-pkg)
        sudocmd pkg clean
        ;;
95 96 97
    *)
        fatal "Have no suitable command for $PMTYPE"
        ;;
98
esac
99
    info "Note: Also you can try (with CAUTION) '# epm autoremove' and '# epm autoorphans' commands to remove obsoleted and unused packages."
100 101

}