epm-clean 2.8 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
    return 0
27 28
}

29 30
__remove_deb_apt_cache_file()
{
31 32 33 34 35
    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*
36
    return 0
37 38
}

39 40
epm_clean()
{
41

42
[ -z "$*" ] || fatal "No arguments are allowed here"
43 44


Vitaly Lipatov's avatar
Vitaly Lipatov committed
45
case $PMTYPE in
46
    apt-rpm)
47
        sudocmd apt-get clean $dryrun
48
        [ -n "$direct" ] && __remove_alt_apt_cache_file || info "Use epm clean --direct to remove all downloaded indexes."
49 50
        ;;
    apt-dpkg)
51
        sudocmd apt-get clean $dryrun
52
        [ -n "$direct" ] && __remove_deb_apt_cache_file || info "Use epm clean --direct to remove all downloaded indexes."
53 54 55
        ;;
    aptitude-dpkg)
        sudocmd aptitude clean
56
        [ -n "$direct" ] && __remove_deb_apt_cache_file || info "Use epm clean --direct to remove all downloaded indexes."
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 86 87
        ;;
    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
        ;;
88 89
    appget)
        sudocmd appget clean
90 91 92 93
        ;;
    xbps)
        sudocmd xbps-remove -O
        ;;
94 95 96
    termux-pkg)
        sudocmd pkg clean
        ;;
97 98 99
    *)
        fatal "Have no suitable command for $PMTYPE"
        ;;
100
esac
101
    info "Note: Also you can try (with CAUTION) '# epm autoremove' and '# epm autoorphans' commands to remove obsoleted and unused packages."
102 103

}