#!/bin/bash source /etc/functions.magic ### # kernel installation script # Copyright (C) Thomas "ShALLaX" Pedley (gentoox@shallax.com) # # This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ### export drive="e" KERNELVERSION="linux-2.4.37" KERNELEXT=".tar.bz2" KERNELMD5="e4197b25bfddacee61490921c885b2ec" PATCHLEVEL="${KERNELVER}" $important clear rm -rf /tmp/kernel* echo "This will update your kernel to '${KERNELVERSION}'" echo "" echo "Changelog" echo "=========" echo "" echo "2437001: Upgrade to 2.4.37." echo "2434001: Disabled TCP Explicit Congestion notification, upgrade to 2.4.34.2..." echo "2432002: Disabled iptables debugging, disabled crypto test, enabled raid." echo "2432001: New kernel version - 2.4.32-Gentoox, new .config - no modules." echo "2422019: Added an autorepeat patch to the XboxIR driver." echo "2422018: Build FatX into the kernel." echo "2422017: .config tweaks, new naming convention." echo "22016: FatX fixes (case sensitive bug). Removed MCE support." echo "22015: Cache vanilla kernel, extended FatX, rename to -xbox-Gentoox." echo "22014: mremap() bug fix: http://www.k-otik.com/exploits/03.01.mremap_pte.c.php" echo "22013: Preliminary Xcalibur HDTV support." echo "22012: USB + Network now compiled into the kernel." echo "22011: Focus S-Video support." echo "22010: Preliminary Xcalibur (Xbox v1.6 support). MCE support." echo "22009: Fixed NTSC Focus support." echo "22008: Backported i2c and xboxfb from 2.4.26 (i.e. HDTV Focus support)." echo "22007: Fix for http://linuxreviews.org/news/2004-06-11_kernel_crash/index.html" echo "22006: Fixed NTSC video positioning and colours." echo "22005: Focus HOC and VOC support (Overscan fix) and Focus RGB support." echo "22004: OpenMosix support." echo "22003: Focus and HDTV support." sleep 15 clear $busy ### # Install module-rebuild to make reinstalling alsa-drivers easier! ### echo "Emerging module-rebuild..." emerge module-rebuild failCheck emerge ### # Mount the drive to be worked on. ### mount /mnt/fatx/$drive 2> /dev/null 1> /dev/null mount -o remount,rw /mnt/fatx/$drive 2> /dev/null 1> /dev/null clear ### # If the kernel cache directory doesnt exist, make it ### echo -n "Searching for kernel cache directory... " sleep 2 if [ ! -d /usr/share/gentoox/kernel ]; then echo -e "${redtxt}missing${normaltxt}!" sleep 1 echo -n "Creating kernel cache directory... " sleep 2 mkdir -p /usr/share/gentoox/kernel if [ $? == 0 ]; then echo -e "${greentxt}done${normaltxt}." sleep 1 else echo -e "${redtxt}failed${normaltxt}." sleep 1 exit 1 fi else echo -e "${greentxt}found${normaltxt}." fi sleep 1 cd /usr/share/gentoox/kernel ### # If there is no kernel, we obviously need to download it. ### echo -n "Searching for vanilla kernel... " sleep 2 if [ ! -f ./${KERNELVERSION}${KERNELEXT} ]; then echo -e "${redtxt}missing${normaltxt}!" sleep 1 echo -n "Downloading vanilla kernel... " sleep 2 $downloading $wget http://www.kernel.org/pub/linux/kernel/v2.4/${KERNELVERSION}${KERNELEXT} 1> /dev/null 2> /dev/null failCheck download echo -e "${greentxt}done${normaltxt}." else echo -e "${greentxt}found${normaltxt}." fi sleep 1 ### # Verify the kernel is original. ### echo -n "Verifying kernel authenticity... " sleep 2 if [ `md5sum ./${KERNELVERSION}${KERNELEXT} | awk '{ print $1 }'` != ${KERNELMD5} ]; then echo -e "${redtxt}failed${normaltxt}!" $busy echo -n "Invalid kernel source package, redownloading... " ### # Retry forever... good idea, bad idea? ### while [ `md5sum ./${KERNELVERSION}${KERNELEXT} | awk '{ print $1 }'` != ${KERNELMD5} ]; do rm -rf ./${KERNELVERSION}${KERNELEXT} $downloading $wget http://www.kernel.org/pub/linux/kernel/v2.4/${KERNELVERSION}${KERNELEXT} 1> /dev/null 2> /dev/null failCheck download done echo -e "${greentxt}done${normaltxt}." else echo -e "${greentxt}passed${normaltxt}." fi sleep 1 $busy cd /usr/src/ if [ -z `grep -m1 -i kernel-downloaded${PATCHLEVEL} /etc/conf.d/magic-database` ]; then echo -n "Cleaning out old kernel... " sleep 2 rm -rf /usr/src/linux rm -rf /usr/src/${KERNELVERSION}* echo -e "${greentxt}done${normaltxt}." sleep 1 $busy echo -n "Extracting vanilla kernel source... " sleep 2 tar -jxf /usr/share/gentoox/kernel/${KERNELVERSION}${KERNELEXT} failCheck decompress echo -e "${greentxt}done${normaltxt}." sleep 1 mv /usr/src/${KERNELVERSION} /usr/src/${KERNELVERSION}-${DISTRO} ln -sf /usr/src/${KERNELVERSION}-${DISTRO} /usr/src/linux cd /usr/share/gentoox/kernel echo -n "Getting kernel patches... " sleep 2 rm -rf ./kernelpatches${PATCHLEVEL}.diff* $downloading $wget --limit-rate $limitrate $gentooxurl/patch-files/kernelpatches${PATCHLEVEL}.diff.bz2 1> /dev/null 2> /dev/null failCheck download echo -e "${greentxt}done${normaltxt}." $busy echo -n "Applying kernel patches... " sleep 2 bunzip2 ./kernelpatches${PATCHLEVEL}.diff.bz2 failCheck decompress cd /usr/src/linux patch -p1 < /usr/share/gentoox/kernel/kernelpatches${PATCHLEVEL}.diff 1> /dev/null 2> /dev/null if [ $? == 0 ]; then echo -e "${greentxt}done${normaltxt}." sleep 1 else echo -e "${redtxt}failed${normaltxt}." sleep 1 exit 1 fi ### # Put the config in place ### mv /usr/src/linux/kernel.config /usr/src/linux/.config ### # The next line of code stops the kernel from being redownloaded. This is # useful incase something goes wrong with the compilation and the script # needs to be re-executed - stops the kernel from being redownloaded which # wastes bandwidth and time. Delete this file or run # "magic fix kernel" to make magic redownload the source ### echo "kernel-downloaded${PATCHLEVEL}" >> /etc/conf.d/magic-database fi clear cd /usr/src/linux $busy ### # Initialise the .config ### make oldconfig clear ### # make the kernel and install it ### make clean && make dep && make bzImage modules modules_install sleep 5 mount -o remount,rw /mnt/fatx/$drive 2> /dev/null 1> /dev/null mv /mnt/fatx/$drive/vmlinuz /mnt/fatx/$drive/oldlinuz echo "Installing new kernel to /mnt/fatx/$drive/vmlinuz" cp /usr/src/linux/arch/i386/boot/bzImage /mnt/fatx/$drive/vmlinuz sleep 2 $busy clear echo "Running module-rebuild..." module-rebuild rebuild || exit 0