You need to sign in or sign up before continuing.
epm-remove_old_kernels 2.18 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 26

	warmup_bases

27
	case $DISTRNAME in
28
	ALTLinux|ALTServer)
29 30 31 32 33 34
		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
35
		sudocmd remove-old-kernels $(subst_option non_interactive -y) "$@"
36 37 38 39 40 41 42 43 44 45

		# remove unused nvidia drivers
		if which nvidia-clean-driver 2>/dev/null ; then
			if [ -n "$non_interactive" ] ; then
				yes | sudocmd nvidia-clean-driver
			else
				sudocmd nvidia-clean-driver
			fi
		fi

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
		return ;;
	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
65
		sudocmd purge-old-kernels "$@"
66 67 68 69
		return ;;
	Gentoo)
		sudocmd emerge -P gentoo-sources
		return ;;
70 71 72
	VoidLinux)
		sudocmd vkpurge rm all
		return ;;
73 74 75 76 77 78 79 80
	esac

	case $PMTYPE in
	*)
		fatal "Have no suitable command for $PMTYPE"
		;;
	esac
}