Compilar e instalar o kernel...

Fórum Geral

O script abaixo serve para automatizar o processo de configurar, compilar, debianizar e instalar uma imagem do kernel e modulos compilados num sistema Debian, e serve como exemplo de como usar programa make-kpkg. the vem com o pacote kernel-package...

#!/bin/sh
#
# Copyright 2005 Rui Damas
#
# This document is released under the Public Domain.
#
# A simple bash script to configure, compile, debianize and install
# a kernel image from source.

###############
# Show warning
echo
echo "This script assumes that you have already instaled and uncompressed"
echo "a kernel and modules (like nvidia-kernel-source) source packages"
echo "inside /usr/src and made a symbolic link named 'linux' to the"
echo "uncompressed kernel directory, also assumes that you have"
echo "kernel-package and bzip2 installed."
echo
echo "You may achieve this with something like:"
echo
echo " apt-get install kernel-source-2.6.8 nvidia-kernel-source kernel-package"
echo " cd /usr/src"
echo " tar -jvxf kernel-source-2.6.8.tar.bz2"
echo " ln -s kernel-source-2.6.8 linux"
echo " tar -zvxf nvidia-kernel-source.tar.gz"
echo

#######################
# Configure the kernel
echo "---------------------------------------"
echo "Press Ctrl-c any time to stop this script..."
cd /usr/src/linux
echo
echo "Configuration method: (m)enuconfig | (x)config | (s)kip"
echo
read -n1 skip
case "$skip" in
"m" ) echo "enuconfig"; make menuconfig || exit ;;
"x" ) echo "config"; make xconfig || exit ;;
"s" ) echo "kipping configuration..." ;;
* ) echo " : unknown option, exiting..." & exit 1 ;;
esac

echo
echo "Press ENTER key to compile and \
make debian kernel image and modules packages"
read

##############################
# list existing kernel images
echo
echo "-----------------------------------------------------------"
echo "Existing deb kernel packages /usr/src/kernel-image*.deb ..."
echo
ls -1 ../kernel-image*.deb

###############
# ask revision
DEFAULT_REVISION="7.0.Custom"
echo
echo "I'm going to compile the kernel and existing modules,"
echo "and make debian packages for them..."
echo
echo "What is the revision of the kernel? [$DEFAULT_REVISION]"
read REVISION

echo $REVISION
[[ "$REVISION" = "" ]] && REVISION="$DEFAULT_REVISION"
echo $REVISION

########################
# compile and debianize
make-kpkg clean && echo -e "\nmake-kpkg clean: ok" &&
make-kpkg --revision=$REVISION kernel-image &&
[ -d ../modules ] && make-kpkg modules-image

#############################
# list generated packages
echo
echo "-------------------------------------------------"
cd ..
DEB_FILES=`ls -1 *$REVISION*.deb 2> /dev/null`
if [[ $DEB_FILES ]]
then
echo "The debian package files to install should be these:"
echo
echo "$DEB_FILES"

#############################
# install generated packages
INSTALL_COMMAND="`find . -name \"*$REVISION*\" -printf \"%f \"`"
INSTALL_COMMAND="dpkg -i $INSTALL_COMMAND"
echo
echo "Press ENTER to run the command bellow or Ctrl-c to abort..."
echo
echo -n "$INSTALL_COMMAND" && read

$INSTALL_COMMAND
fi