Обновление ядра (ALT Linux)

Материал из Lblss.ru
Перейти к: навигация, поиск

Скрипт обновления ядра и модулей

Ядро не обновляется через менеджер пакетов. Собственно, вполне нормальное явление. Для этого есть несколько скриптов. Один из простых и удобных был найден на страничке Анатолия Китайкина.

Копия на момент использования:

#!/bin/sh
# Copyright (C) 2004 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2005-2008 Anatoly Kitaykin <cetus@newmail.ru>
# Copyright (C) 2008 Vladimir V. Kamarzin <vvk@altlinux.org>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
. /bin/shell-error
 
show_help()
{
 
	cat <<EOF
 
$@
 
To install selected kernel-image and/or update kernel-modules infrastructure for it:
 
$PROG [options][flavour][release]
	flavour is one of well-known like std-smp or std-def or ovz-wks etc.
	release is more flexible, somewhat like alt6 or 2.6.22 or so
		Both are patterns to filter full kernel list
 
Valid options are:
 
	-y | --yes | --assume-yes
		to force apt-get
	-h | --help
 
EOF
	exit
}
 
yes=
RELEASE=.
FLAVOUR=.
FLAVOURS=`apt-cache pkgnames kernel-image | sed -e "s/kernel-image-//g" | sed -e "s/#.*$//" | sort -u`
while [ -n "$1" ]; do
	if [ "$1" = "-y" ] || [ "$1" = "--yes" ] || [ "$1" = "--assume-yes" ]; then
		yes=$1
	elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
		show_help
		exit
	elif echo $FLAVOURS | grep $1 &>/dev/null; then
		FLAVOUR=$1
	else
		RELEASE=$1
	fi
	shift
done
 
# use sudo(1) if running as unprivileged user
[ "$UID" = "0" ] && SUDO= || SUDO=sudo
 
KERNELS=`$SUDO apt-get install kernel 2>&1 | grep '#' | grep $FLAVOUR | grep $RELEASE |\
	sed -e 's/^  //' | sort -k2 | while read n v s ; do echo $n ${s:-[+]} ; done`
[ -z "$KERNELS" ] && show_help "Error: kernel list with filter ($FLAVOUR,$RELEASE) is empty"
 
TYPEofCURRENT=`uname -r | cut -d "-" -f2,3`
VERSofCURRENT=`uname -r | cut -d "-" -f1`
RELSofCURRENT=`uname -r | cut -d "-" -f4`
NAMEofCURRENT=kernel-image-$TYPEofCURRENT#$VERSofCURRENT-$RELSofCURRENT
 
KERNEL=`dialog --stdout --clear --default-item "$NAMEofCURRENT" --menu "Choose a kernel:" "" "" "" $KERNELS`
 
if [ -z $KERNEL ]; then
	clear
	fatal No kernel selected
	exit
fi
 
TYPEforINSTALL=`echo $KERNEL | sed -e 's/#/-/' | cut -d '-' -f3,4`
VERSforINSTALL=`echo $KERNEL | sed -e 's/#/-/' | cut -d '-' -f5`
RELSforINSTALL=`echo $KERNEL | sed -e 's/#/-/' | cut -d '-' -f6`
INSTVER=$VERSforINSTALL-$TYPEforINSTALL-$RELSforINSTALL
 
if rpm -q `echo $KERNEL | sed -e 's/#/-/'`; then
	VERB=`dialog --stdout --clear --menu "$KERNEL" "" "" ""\
		"switch to"	"$KERNEL"\
		"reinstall"	"$KERNEL"\
		"upgrade modules for"	"$KERNEL"\
		"remove"	"$KERNEL"\
	`
	case $VERB in
		"switch to")
			$SUDO installkernel $INSTVER
			exit
			;;
		"reinstall")
			$SUDO apt-get install --reinstall $KERNEL
			exit
			# or not exit?
			;;
		"upgrade modules for")
			message please wait
			;;
		"remove")
			dialog --stdout --clear --yesno "Try to remove $KERNEL and modules? Are you sure?" "" "" || exit
			$SUDO apt-get remove $KERNEL
			exit
			;;
		"")
			clear
			fatal Nothing to do
			exit
			;;
		*)
			fatal Bug: menu and case mismatch
			exit
			;;
	esac
else
	dialog --stdout --clear --yesno "Try to install $KERNEL with modules?" "" "" || exit
	$SUDO apt-get install $KERNEL
fi
 
ALLMODULES=`rpm -qa | grep ^kernel-modules- | cut -d '-' -f1,2,3 | sort -u`
for PKGNAME in $ALLMODULES; do
	message try update $PKGNAME
	$SUDO apt-get install $yes "$PKGNAME-$INSTVER"
done
Персональные инструменты