Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37653650
en ru br
Репозитории ALT
S:1.11-alt1
5.1: 0.9.2-alt1
4.1: 0.9.1-alt0.M41.1
4.0: 0.9.1-alt0.M40.1
www.altlinux.org/Changes

Группа :: Система/Ядро и оборудование
Пакет: update-kernel

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064112663011400014504gustar00rootroot0000000000000052 comment=d495b155a752a753998b2cd2151f4b96bcacb8cb
update-kernel-0.9.2/000075500000000000000000000000001126630114000142525ustar00rootroot00000000000000update-kernel-0.9.2/.gear/000075500000000000000000000000001126630114000152465ustar00rootroot00000000000000update-kernel-0.9.2/.gear/rules000064400000000000000000000000071126630114000163200ustar00rootroot00000000000000tar: .
update-kernel-0.9.2/.gear/tags/000075500000000000000000000000001126630114000162045ustar00rootroot00000000000000update-kernel-0.9.2/.gear/tags/list000064400000000000000000000000001126630114000170700ustar00rootroot00000000000000update-kernel-0.9.2/apt-upgrade-kernel000064400000000000000000000163751126630114000177000ustar00rootroot00000000000000#!/bin/sh
#
# apt-upgrade-kernel
#
# Helper for upgrading Linux kernel image and kernel-related modules via APT:
# displays list of packages for passing to 'apt-get install' command.
#
# Works under ordinal account and doesn't requires superuser privileges.
#
# Requires: apt-cache, egrep, sed, awk, xargs, rpmquery, rpmvercmp
#
# Uses packages naming conventions from ALTLinux Kernel Policy 1.2.
#
# Tested on ALTLinux Master 2.4:
# kernel-build-tools-0.7-alt1, apt-0.5.15cnc6-alt6,
# rpm-4.0.4-alt40, rpm-utils-0.8.1-alt1(rpmvercmp).
#
# Todo: how to be with kernel-complete package and empty apt-kernel-images list?
#
# Written at Apr,May 2005 by evseev@altlinux.ru
# Distributed under terms of GNU GPL
#

echo_stderr() {
echo "$@" 1>&2
}

usage() {
echo "\
$fname0 $version
Purpose: Update Linux kernel and installed kernel modules via APT
Usage: [VAR=value] $fname0 [options]

Options:
-V, --version Show version string
-h, --help Show complete usage
-q, --quiet Silent mode (turn off messages)
-v, --verbose Detailed mode (turn on messages)
-k, --keep Dont remove temporary working directory at finish
--debug Enable debugging mode, see below

Variables for explicit selection of currently installed kernel to be upgraded
(by default they are detected automatically via 'uname -r'):
KERNEL_FLAVOUR (examples: std-up, vs-smp, ...)
KERNEL_VERSION (for example, 2.4.33-std-smp-alt9)

Debugging mode:
Use static data directory instead of temporary,
dont overwrite already existing files in data directory
(use previously created if they are not removed manually),
use more verbose output.

Examples:
sudo apt-get update;
export KERNEL_FLAVOUR=std-smp;
$fname0 -q | xargs sudo -H apt-get -y install
"
}

main()
{

local fname0=$(basename $0)
local version="0.1 (May 2005)"

local is_debug
local debug_echo=":"
local info_echo="echo_stderr"
local error_echo="echo_stderr ERROR:"
local echo_passed="echo ...already exists, passed..."
local keepwd

local used_commands="apt-cache egrep sed awk xargs rpmquery rpmvercmp"

while [ "$1" != "" ]; do
case "$1" in
-V | --version ) echo "$fname0 $version"; return 0 ;;
-h | --help ) usage; return 0 ;;
-k | --keep ) keepwd=yes;;
--debug ) is_debug=yes; info_echo="echo_stderr"; debug_echo="echo_stderr DEBUG:" ;;
-v | --verbose ) info_echo="echo_stderr"; debug_echo="echo_stderr DEBUG:" ;;
-q | --quiet | --silent ) info_echo=":"; debug_echo=":"; echo_passed=":" ;;
* ) $error_echo "invalid option $1, run '$0 --help' for usage info"; return 1 ;;
esac
shift
done

#-----------------------------------------------------------------------

for c in $used_commands; do
[ "$(which $c)" = "" ] || continue
$error_echo "Error: missing program: $c"
return 1
done

$debug_echo "Create temprorary directory..."
if [ -z "$is_debug" ]; then
local workdir=$(mktemp -dt $fname0.XXXXXXXX)
$debug_echo "...created $workdir"
else
local workdir=$HOME/tmp/$fname0
mkdir -p $workdir
$debug_echo "...using $workdir"
fi
if [ -z "$workdir" ]; then
$error_echo "mktemp failed, abort"
return 1
fi
[ -n "$is_debug" ] && keepwd=yes
[ -z "$keepwd" ] && trap "rm -rf $workdir" 0 1 2 5 15

#-----------------------------------------------------------------------

$debug_echo "Detect kernel flavour..."
if [ -z "$KERNEL_FLAVOUR" ]; then
[ -z "$KERNEL_VERSION" ] && local KERNEL_VERSION=$(uname -r)
local ktmp=${KERNEL_VERSION#*-}
local KERNEL_FLAVOUR=${ktmp%-*}
$debug_echo "...found $KERNEL_FLAVOUR, KERNEL_VERSION = $KERNEL_VERSION"
else
$debug_echo "...use predefined = $KERNEL_FLAVOUR"
local KERNEL_VERSION="$(rpmquery --qf '%{VERSION}-xxx-%{RELEASE}\n' kernel-image-$KERNEL_FLAVOUR)"
if [ -z "$KERNEL_VERSION" ]; then
$error_echo "Cannot find kernel-image-$KERNEL_FLAVOUR, failed."
return 1
fi
$debug_echo "...found KERNEL_VERSION = $KERNEL_VERSION"
fi
local KERNEL_BASEVER=${KERNEL_VERSION%%-*}
local KERNEL_RELEASE=${KERNEL_VERSION##*-}
$debug_echo "Installed kernel version = $KERNEL_BASEVER, release = $KERNEL_RELEASE, flavour = $KERNEL_FLAVOUR"

#return 0

#-----------------------------------------------------------------------

$info_echo "Get list of kernel images available to install..."
if [ -e $workdir/apt-kernel-images ]; then $echo_passed; else
apt-cache showpkg "kernel-image-$KERNEL_FLAVOUR" \
| egrep "^kernel-image-$KERNEL_FLAVOUR" > $workdir/apt-kernel-images
fi

local kmaxname kmaxver=""
if [ -s $workdir/apt-kernel-images ]; then
while read kname kver; do
$debug_echo "...check $kname ($kver)"
if [ "$(rpmvercmp \"$kmaxver\" $kver)" = "-1" ]; then
kmaxver=$kver
kmaxname=$kname
$debug_echo "....is newest"
fi
done < $workdir/apt-kernel-images
if [ -z "$kmaxver" -o -z "$kmaxname" ]; then
$error_echo "Cannot find any kernel-image-$KERNEL_FLAVOUR in APT repository, failed"
return 1
fi
$info_echo "Found newest kernel version = $kmaxver, name = $kmaxname"
else
$error_echo "??? apt-kernel-images: empty"
return 1
fi

#return 0

#-----------------------------------------------------------------------

$info_echo "Get full list of package depending from kernel to be installed..."
[ -e $workdir/apt-whatdepends ] && $echo_passed "(whatdepends)" || \
apt-cache whatdepends "$kmaxname" \
| egrep '^ [^ ]' | sed -e 's/^ //' \
> $workdir/apt-whatdepends
if [ -e $workdir/apt-whatdepends-vpackages ]; then $echo_passed "(vpackages)"; else
grep '#' $workdir/apt-whatdepends \
| sed -e 's/\(#.*-.*\)-.*-.*$/\1/' \
> $workdir/apt-whatdepends-vpackages
fi
if [ -e $workdir/apt-whatdepends-vnamesonly ]; then $echo_passed "(names only)"; else
sed -e 's/#.*$//' $workdir/apt-whatdepends-vpackages \
> $workdir/apt-whatdepends-vnamesonly
fi
if [ -e $workdir/apt-whatdepends-packages ]; then $echo_passed "(remaining packages)"; else
grep -v '#' $workdir/apt-whatdepends \
> $workdir/apt-whatdepends-packages
fi

#return 0

#-----------------------------------------------------------------------

$info_echo "Get list of packages depending from current kernel..."
if [ -e "$workdir/rpm-whatdepends-namesonly" ]; then $echo_passed; else
# rpmquery --whatrequires "kernel-image-$KERNEL_FLAVOUR" --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' | uniq > $workdir/rpm-whatdepends
rpmquery --whatrequires "kernel-image-$KERNEL_FLAVOUR" --qf '%{NAME}\n' | uniq > $workdir/rpm-whatdepends-namesonly
fi

$info_echo "Build list of package vnames to be installed..."
[ -e "$workdir/apt-toinstall-namesonly" ] && $echo_passed "(vnames)" || \
grep -xf $workdir/rpm-whatdepends-namesonly $workdir/apt-whatdepends-vnamesonly > $workdir/apt-toinstall-namesonly

$info_echo "Build list of vpackages to be installed..."
[ -e "$workdir/apt-toinstall" ] && $echo_passed "(vpackages)" || \
grep -f $workdir/apt-toinstall-namesonly $workdir/apt-whatdepends-vpackages > $workdir/apt-toinstall

$info_echo "Build list of remaining packages to be installed..."
if [ -e "$workdir/apt-toinstall2" ]; then $echo_passed "(packages)"; else
sed -e 's/-[^-]*-[^-]*$//' $workdir/apt-whatdepends-packages \
| xargs rpmquery --qf '%{NAME}\n' 2>/dev/null \
> $workdir/apt-toinstall2
fi

#return 0

$info_echo "This list should be passed to \"apt-get install\" command:"
echo $kmaxname
cat $workdir/apt-toinstall $workdir/apt-toinstall2

[ -z "$keepwd" ] && rm -rf $workdir
return 0

}

main "$@"

## EOF ##
update-kernel-0.9.2/remove-old-kernels000075500000000000000000000024311126630114000177120ustar00rootroot00000000000000#!/bin/sh
# Copyright (C) 2008 Vladimir V. Kamarzin <vvk@altlinux.org>
#
# Remove all kernels except current
#
# 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.

flavour_version_release="$(uname -r | awk -F- '{print $2"-"$3"-"$1"-"$4}')"
old_kernels="$(rpm -qa | fgrep kernel-image | fgrep -v $flavour_version_release | tr '\n' ' ')"

# calculate arguments for apt
for kernel in $old_kernels
do
apt_args_list="$apt_args_list $(rpm -q --queryformat '%{NAME}#%{EPOCH}:%{VERSION}-%{RELEASE}\n' $kernel \
| sed -e "s,(none):,,g")"
done

# use sudo(1) if running as unprivileged user
[ "$UID" = "0" ] && SUDO= || SUDO=sudo

$SUDO apt-get remove $apt_args_list
update-kernel-0.9.2/update-kernel.spec000064400000000000000000000066221126630114000176740ustar00rootroot00000000000000Name: update-kernel
Version: 0.9.2
Release: alt1

Summary: Update kernel and modules
License: GPL
Group: System/Kernel and hardware

Packager: Vladimir V Kamarzin <vvk@altlinux.ru>
Source: %name-%version.tar
BuildArch: noarch

Requires: /usr/bin/rpmevrcmp

%description
This package contains a script to conveniently update
kernel and modules.

It works by installing a new package set along with existing kernel
so that you don't end up without a kernel guaranteed to boot (your
good old one); by default, it will look for the most recent package
of the same flavour (e.g. "std-def") and try to install all the same
modules as already installed for that.

See also:
http://lists.altlinux.org/pipermail/community/2005-November/366618.html
http://lists.altlinux.org/pipermail/sisyphus/2006-November/192226.html

%prep
%setup

%install
install -pDm755 update_kernel_modules_cetus.sh %buildroot%_sbindir/%name
install -pm755 remove-old-kernels %buildroot%_sbindir/

%files
%_sbindir/*

%changelog
* Sat Oct 17 2009 Michael Shigorin <mike@altlinux.org> 0.9.2-alt1
- removed warning on x11setupdrv absence due to its obsolescence
(closes: #21872)

* Mon Aug 31 2009 Michael Shigorin <mike@altlinux.org> 0.9.1-alt1
- added one-liner to fix path to x11presetdrv (closes: #21301)

* Thu Mar 05 2009 Vladimir V. Kamarzin <vvk@altlinux.org> 0.9-alt1
- Add x11presetdrv calling (mike)
- Add ldconfig call after x11setupdrv (mike)
- Remove message about updating kernel-headers and kernel-headers-modules

* Thu Feb 26 2009 Vladimir V. Kamarzin <vvk@altlinux.org> 0.8.1-alt1
- update_kernel: run x11setupdrv only if Xorg present

* Sun Dec 28 2008 Vladimir V. Kamarzin <vvk@altlinux.org> 0.8-alt1
- update_kernel: update kernel-headers and kernel-headers-modules also
(me, kipruss) (Closes: #18259)
- Add new script remove-old-kernels. It removes all kernels except current
(Closes: #14764)

* Mon Nov 24 2008 Vladimir V. Kamarzin <vvk@altlinux.org> 0.7-alt1
- Use rpmevrcmp instead of rpmvercmp
- Use only serial/epoch+version+release when comparing versions

* Mon Sep 22 2008 Vladimir V. Kamarzin <vvk@altlinux.org> 0.6-alt1
- Run x11setupdrv if needed (mike)
- Spelling fixes (mike)

* Mon Sep 01 2008 Vladimir V Kamarzin <vvk@altlinux.org> 0.5-alt1
- Fix module-names calculation (Closes: #16946)

* Tue Apr 22 2008 Vladimir V Kamarzin <vvk@altlinux.ru> 0.4-alt1
- Rewrite modules upgrading procedure (Closes: #15380)

* Tue Apr 15 2008 Vladimir V Kamarzin <vvk@altlinux.ru> 0.3-alt4
- update_kernel: bugfix in options parser

* Fri Apr 11 2008 Vladimir V Kamarzin <vvk@altlinux.ru> 0.3-alt3
- Set dependency on /usr/bin/rpmvercmp instead of rpm-utils

* Thu Mar 13 2008 Vladimir V Kamarzin <vvk@altlinux.ru> 0.3-alt2
- Add dependency on rpm-utils

* Wed Mar 12 2008 Vladimir V Kamarzin <vvk@altlinux.ru> 0.3-alt1
- update-kernel:
+ use rpmvercmp(1) for getting newest kernel package name
+ old code for manual choosing of kernel flavour/release replaced with
options -t/-r

* Mon Mar 03 2008 Vladimir V Kamarzin <vvk@altlinux.ru> 0.2-alt1
- update-kernel:
+ implemented "force" mode
+ recode script to utf8
+ update copyright header

* Mon Feb 18 2008 Michael Shigorin <mike@altlinux.org> 0.1-alt2
- clarified License: (with lav@)
- noarch

* Sun Feb 17 2008 Michael Shigorin <mike@altlinux.org> 0.1-alt1
- initial package
- many thanks to Vitaly Lipatov (lav@) and Anatoly Kitouwaykin (cetus)
for writing and improving the script -- I just had to package it

update-kernel-0.9.2/update_kernel_modules_cetus.sh000075500000000000000000000133121126630114000223660ustar00rootroot00000000000000#!/bin/bash
# Copyright (C) 2004 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2005-2008 Anatoly Kitaykin <cetus@newmail.ru>
# Copyright (C) 2008-2009 Vladimir V. Kamarzin <vvk@altlinux.org>
# Copyright (C) 2008-2009 Michael Shigorin <mike@altlinux.org>
# Copyright (C) 2008 Konstantin Baev <kipruss@altlinux.org>
#
# Update kernel with modules
#
# 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.

. shell-error

show_help()
{
cat <<EOF
Usage: $PROG [options]
Valid options are:
-f, --force force kernel upgrade
-t, --type install kernel with specified flavour (ovz-smp, std-def, etc)
-r, --release install kernel with specified release (alt10, alt22, etc)
-h, --help show this text and exit
EOF
exit 1
}

#parse command line options
TEMP=`getopt -n $PROG -o f,t:,r:,h -l force,type:,release:,help -- "$@"` || show_help
eval set -- "$TEMP"

while :; do
case "$1" in
--) shift; break
;;
-f|--force) force=1
;;
-t|--type) shift ; kernel_flavour="$1"
;;
-r|--release) shift ; release="$1"
;;
-h|--help) show_help
esac
shift
done


###################################################################
# update kernel

# get list of all available kernel packages
KERNEL_PKGS="$(apt-cache pkgnames kernel-image)"

# set kernel flavour. if not defined with -t option, use current
current_kernel_flavour="$(uname -r | cut -d "-" -f2,3)"
kernel_flavour="${kernel_flavour:-$current_kernel_flavour}"

# check that we have at least one kernel with defined kernel_flavour
num_available_kernels="$(echo "$KERNEL_PKGS" | grep -c "$kernel_flavour")"
[ "$num_available_kernels" != 0 ] || fatal "There are no available kernels with kernel flavour $kernel_flavour"

# check that we have at least one kernel with defined kernel package release
[ -z "$release" ] || {
num_available_kernels="$(echo "$KERNEL_PKGS" | grep -c "$release")"
[ "$num_available_kernels" != 0 ] || fatal "There are no available kernels with package release $release"
}

# define how we must select available packages with needed flavour/release
[ -z "$release" ] && pgkgrep="kernel-image-$kernel_flavour#" || pgkgrep="kernel-image-$kernel_flavour#.*$release$"

# get the maximum available kernel package version
kmaxver=
while read version
do
comparever="$(rpmevrcmp "$kmaxver" "$version")"
[ "$comparever" -lt 0 ] && kmaxver="$version" ||:
done < <(echo "$KERNEL_PKGS" | grep "$pgkgrep" | sed -e "s,^kernel-image-$kernel_flavour#,,g")

# ask user
echo -n "Try to install new kernel kernel-image-$kernel_flavour-$kmaxver and update its modules [y]/n? "
[ "$force" = 1 ] && echo "yes" || {
read
case "$REPLY" in
n|no|N|No|NO|0) exit 0
;;
*)
;;
esac
}

# is there kernel-image-$kernel_flavour already installed or not?
# needed for proper modules selection
rpm -q kernel-image-"$kernel_flavour" &>/dev/null && modules_kernel_flavour="$kernel_flavour" \
|| modules_kernel_flavour="$current_kernel_flavour"

# use sudo(1) if running as unprivileged user
[ "$UID" = "0" ] && SUDO= || SUDO=sudo

$SUDO apt-get install -y "kernel-image-$kernel_flavour#$kmaxver" \
|| fatal "failed to install kernel-image-$kernel_flavour-$kmaxver"


###################################################################
# update modules

# strip serial/epoch before installing modules
kmaxver=${kmaxver##*:}

# latest kernel package name
LATESTKERNEL="kernel-image-$kernel_flavour-$kmaxver"

# "version-kernel_flavour-release" for latest kernel package
newkernel_ver_flav_rel="$(rpm -q $LATESTKERNEL --queryformat "%{VERSION}-$kernel_flavour-%{RELEASE}")" \
|| fatal "Cannot get newkernel_ver_flav_rel. Please report \`bash -x sisyphus-mirror' output to bugzilla"

message "Updating modules for kernel: $newkernel_ver_flav_rel"

# get list of all available modules
ALLMODULES="$(apt-cache pkgnames kernel-modules | grep $kernel_flavour | sed -e "s,^kernel-modules-\(.*\)-$kernel_flavour.*,\1,g"| sed -e "s,-[[:digit:]]\.[[:digit:]]\.[[:digit:]].*,,g" | sort -u)"

for module in $ALLMODULES; do
module_pkgname=kernel-modules-$module
if rpm -q $module_pkgname-"$modules_kernel_flavour" &>/dev/null; then
message "$module_pkgname is installed, trying to update..."
$SUDO apt-get install -y "$module_pkgname-$newkernel_ver_flav_rel"
fi
done

# try to run x11setupdrv, x11presetdrv
# if might need that (e.g. for nvidia_glx updates)
# NB: x11setupdrv seems deprecated in Sisyphus as of Oct 2009
X11SETUPDRV=/usr/bin/x11setupdrv
X11PRESETDRV=/usr/sbin/x11presetdrv
XORG=/usr/bin/Xorg

[ ! -x "$XORG" ] || \
case "$ALLMODULES" in
*drm*|*fglrx*|*nvidia*)
[ -x "$X11SETUPDRV" ] \
&& $SUDO "$X11SETUPDRV"
[ -x "$X11PRESETDRV" ] \
&& $SUDO "$X11PRESETDRV" \
|| message "You might need to run x11presetdrv, video drivers updated but it's missing"
$SUDO ldconfig
;;
esac


###################################################################
# update headers

for package in kernel-headers kernel-headers-modules; do
if rpm -q $package-"$kernel_flavour" &>/dev/null; then
message "$package is installed, trying to update..."
$SUDO apt-get install -y "$package-$kernel_flavour"
fi
done
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin