#!/usr/pkg/bin/bash # rebuild specified kernel which is already configured in /etc/lilo.conf die() { [ "$@" ] && echo "$@" >&2 exit 1 } [ -w "/" ] || die "Must be root" version=$1 kernelversion=`echo $version | sed -e 's/-.*//'` # chop extraversion if any extraversion=`echo $version | sed -e 's/^[^-]*//'` extension=`echo $extraversion | sed -e 's/^-//'` if ! cd /usr/src/linux-$kernelversion; then echo "Must specify valid version, e. g. 2.6.6" >&2 exit 1 fi if [ "$version" != "$kernelversion" -a ! -L "../$version" \ -a ! -d "../$version" ]; then ln -sf . ../$version fi if [ -f "Makefile.$extension" ]; then ln -sf Makefile.$extension Makefile fi if [ -f "config.$extension" ]; then ln -sf config.$extension .config else die "No configfile for $version kernel!" fi if ! grep -q "^EXTRAVERSION = $extraversion\$" Makefile; then echo This makefile is wrong for $version exit 1 fi if ! make menuconfig; then die else # the old .config was renamed to .config.old, and a new file written... rm .config.old # remove the link mv -f .config config.$extension # overwrite with new configuration ln -s config.$extension .config # now link to it fi if ! make dep clean bzImage; then exit; fi if grep -q 'CONFIG_MODULES=y' .config; then if ! make modules modules_install; then die "Failed module build"; fi if ! grep -iq 'advanced linux sound architecture' .config; then if which rebuild_alsa; then if ! rebuild_alsa $version; then die "Failed rebuilding sound drivers"; fi fi fi fi cp System.map /boot/System.map-$version cp arch/i386/boot/bzImage /boot/vmlinuz-$version cp .config /boot/config-$version lilo