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

20 21
load_helper epm-sh-warmup

22 23
epm_remove_old_kernels()
{
24

25
    warmup_bases
26

27 28 29 30 31 32 33 34 35
    case $BASEDISTRNAME in
    "alt")
        load_helper epm-query_package
        if ! __epm_query_package kernel-image >/dev/null ; then
            info "No installed kernel packages, skipping cleaning"
            return
        fi
        assure_exists update-kernel update-kernel 0.9.9
        sudocmd remove-old-kernels $dryrun $(subst_option non_interactive -y) "$@"
36

37
        [ -n "$dryrun" ] && return
38

39 40 41 42 43 44 45 46
        # remove unused nvidia drivers
        if is_command nvidia-clean-driver ; then
            if [ -n "$non_interactive" ] ; then
                yes | sudocmd nvidia-clean-driver
            else
                sudocmd nvidia-clean-driver
            fi
        fi
47

48 49
        return ;;
    esac
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
    case $DISTRNAME in
    Ubuntu)
        load_helper epm-query_package
        if ! __epm_query_package linux-image >/dev/null ; then
            info "No installed kernel packages, skipping cleaning"
            return
        fi
        info "Note: it is enough to use eepm autoremove for old kernel removing..."
        info "Check also http://ubuntuhandbook.org/index.php/2016/05/remove-old-kernels-ubuntu-16-04/"
        # http://www.opennet.ru/tips/2980_ubuntu_apt_clean_kernel_packet.shtml
        case $DISTRVERSION in
        10.04|12.04|14.04|15.04|15.10)
            assure_exists purge-old-kernels bikeshed
            ;;
        *)
            # since Ubuntu 16.04
            assure_exists purge-old-kernels byobu
            ;;
        esac
        sudocmd purge-old-kernels "$@"
        return ;;
    Gentoo)
        sudocmd emerge -P gentoo-sources
        return ;;
    VoidLinux)
        sudocmd vkpurge rm all
        return ;;
    esac
79

80 81
    case $PMTYPE in
    *)
82
        fatal 'Have no suitable command for $PMTYPE'
83 84
        ;;
    esac
85
}