#!/bin/sh
## this script assumes you have downloaded, unpacked and linked kernel-whatever.version
## First, edit this to set the version string to match the Makefile setting
# yeah, I know, I should pass it as $1.  Someday...
VER=2.6.32
echo now makeing kernel $VER, if not right, hit ctl+c now && \
sleep 3 && \
## For use with the lm_sensors kit, you'll need the following lines inserted
## into your /etc/rc.d/rc.local script
##------------------
### now do some lm-sensors stuff
## i2c adaptor drivers
#modprobe i2c-via
## i2c chip drivers
#modprobe gl518sm
## alternate chip driver
#modprobe eeprom
##------------------
## And add these lines to /etc/conf.modules
# I2C module options
#alias char-major-89 i2c-dev
##------------------
## Now, the real work.  This assumes you have copied your
## .config and .config.old
## files from the source directory of your previous kernel install, and have
## done 'make oldconfig' in the new source directory and answered all the
## questions, and then do a 'make xconfig' to check/change anything you wanted
## to

## The above is NOT for major version upgrades, you must start from scratch, do NOT
## copy over the older .config's when upping from 2.2.x to 2.4.x or 2.6.x

# I've re-arranged this to be one contiguous command line, because this way if there
# is an error, it dies right there instead of making you scroll back 300k in the
# history to check for errors.
# And, due to changes in the 2.6 way of doing things, the System.map
# stuff has been moved to a point BEFORE the make modules_install
# because make modules_install now has a self-contained depmod command. :(

# Also, one should make sure the DEPMOD declaration in the Makefile
# is NOT hard coded pathwise, so it will find the newer, 2.6 version of depmod

make clean && \
echo && \
echo && \
echo makeing bzImage && \
ccache make -j3 bzImage && \
echo && \
echo && \
echo Now making modules && \
echo && \
echo && \
ccache make -j3 modules && \
echo && \
echo removeing /boot/vmlinuz-$VER-old && \
rm -f /boot/vmlinuz-$VER-old && \
echo touching vmlinuz-$VER && \
touch /boot/vmlinuz-$VER && \
echo mv-ing /boot/vmlinuz-$VER /boot/vmlinuz-$VER-old && \
mv -f /boot/vmlinuz-$VER /boot/vmlinuz-$VER-old && \
echo copying bzImage to /boot/vmlinuz-$VER && \
cp -f arch/i386/boot/bzImage /boot/vmlinuz-$VER && \
echo removeing old lib/modules/$VER.old && \
rm -fR /lib/modules/$VER.old && \
echo touching /lib/modules/$VER && \
touch /lib/modules/$VER && \
echo moving /lib/modules/$VER to /lib/modules/$VER.old && \
mv -f /lib/modules/$VER /lib/modules/$VER.old && \
echo cleaning up in /boot && \
rm -f /boot/System.map && \
echo saveing the System.map-$VER to System.map-$VER.old && \
touch /boot/System.map-$VER && \
mv /boot/System.map-$VER /boot/System.map-$VER.old && \
echo copying in new System.map && \
cp -f System.map /boot/System.map-$VER && \
echo cd-ing to /boot && \
cd /boot && \
echo doing the link of System.map-$VER to System.map && \
ln -s System.map-$VER System.map && \
echo cd-ing back to /usr/src/linux-$VER to do the modules_install && \
cd /usr/src/linux-$VER && \
echo make modules_install && \
ccache make -j3 modules_install && \
echo now making a new initrd.$VER.img && \
touch initrd-$VER.img && \
rm -f initrd-$VER.img && \
mkinitrd -f initrd-$VER.img $VER && \
echo and copying it to /boot/initrd-$VER.img && \
touch /boot/initrd-$VER.img.old && \
rm -f /boot/initrd-$VER.img.old && \
touch /boot/initrd-$VER.img && \
mv /boot/initrd-$VER.img /boot/initrd-$VER.img.old && \
cp initrd-$VER.img /boot/initrd-$VER.img && \
make firmware_install && \
cd /usr/src/linux-$VER && \
depmod -ae -F System.map $VER && \
# Ok, now we need to be saving the .config in /boot and dump the copy in /proc \
touch /boot/config-$VER.gz && \
mv /boot/config-$VER.gz /boot/config-$VER.gz.old && \
gzip -c .config >/boot/config-$VER.gz && \
ls -l /boot/ | grep config-$VER.gz && \
echo All done! Edit grub.conf, reboot and chose your kernel at the grub prompt