Maybe this will help someone else, but mostly I'm posting this because I've lost & rewritten this (small) bash script to automate compiling my 'test' kernels more times than I can remember and can't think of a better place to keep a copy.
compile.sh
Code:
cmp_dir="/home/kernel";
src_dir="/usr/src";
lilo_conf="/etc/lilo.conf";
lilo_root="/dev/md2";
t1=$(($((`date +%H` * 60)) + $((`date +%M`))));
for i in `ls -1 $src_dir/linux-2.6*.bz2 | sed 's/^.*linux/linux/g' | sort`; do
i=$i;
done;
ver=`echo $i | sed 's/.tar.bz2//g' | sed 's/linux-//g'`;
lin_ver="linux-$ver";
if [ -d $cmp_dir ]; then
if [ -e $cmp_dir/.config ]; then
cp $cmp_dir/.config $src_dir/config.save;
fi;
echo "Removing Compiled Directory ...";
rm -r $cmp_dir;
echo "Creating Compiled Directory ...";
mkdir $cmp_dir;
cp $src_dir/config.save $cmp_dir/.config;
else
mkdir $cmp_dir;
cp $src_dir/config.save $cmp_dir/.config;
fi;
if [ -d /lib/modules/${ver} ]; then
echo "Removing Old Modules";
rm -r /lib/modules/${ver};
else
echo "Old modules do not exist - continuing ...";
fi;
if [ ! -z $lin_ver ] && [ -d $src_dir/$lin_ver ] && [ -e $src_dir/linux -a -h $src_dir/linux ]; then
rm $src_dir/linux;
ln -s $src_dir/$lin_ver $src_dir/linux;
s1=1;
fi
if [ -z $lin_ver ] && [ -z $s1 ]; then
echo "ERROR: No compressed Kernel source found in $src_dir";
exit;
else
if [ ! -d $src_dir/$lin_ver ]; then
echo "Creating source directory";
cd $src_dir;
tar xjf $src_dir/$i;
fi
if [ -e $src_dir/linux ]; then
if [ ! -h $src_dir/linux ]; then
echo "ERROR: $src_dir/linux is not symbolic ";
exit;
fi;
rm $src_dir/linux;
ln -s $src_dir/$lin_ver $src_dir/linux;
fi
fi;
echo "Cleaning source kernel";
cd $src_dir/linux/;
make -j3 mrproper;
make -j3 clean;
make -j3 O=$cmp_dir xconfig;
make -j3 O=$cmp_dir;
make -j3 O=$cmp_dir modules;
make -j3 O=$cmp_dir modules_install;
rm /boot/*-test;
cp $cmp_dir/System.map /boot/System.map-${ver}-test;
cp $cmp_dir/arch/i386/boot/bzImage /boot/vmlinuz-${ver}-test;
more $lilo_conf | grep -v "#test" > /tmp/lilo.tmp;
mv /tmp/lilo.tmp $lilo_conf;
echo " #test
image = /boot/vmlinuz-${ver}-test #test
root = $lilo_root #test
label = Linux-Test #test" >> $lilo_conf
/sbin/lilo
t2=$(($((`date +%H` * 60)) + $((`date +%M`))));
elapsed=$(( $t2 - $t1 ));
xmessage -center "Done in $elapsed minutes";
By the way, props go to
the Digital Hermit's Rebuild Guide for getting me started on the basics.