#!/bin/csh -f #H# This is a quick script that I wrote to run all the commands to build a kernel #H# once it is properly configured. #H# #H# For Linux this should be run in /usr/src/linux #H# For OpenBSD this should be run in /usr/src/sys/arch/*/compile/* #H# In both cases the kernel MUST already be configured. # print out the help info if any args are used. if ($#argv >= 1) then grep ^\#H\# $0 | sed -e 's/^#H# //' exit endif # Find out where we are running set HostName=`hostname` set OS=`uname -s` set Arch=`uname -m` # if we are in a chroot on asylum then pretend we are not on asylum... if ($HostName == "asylum") then set RealIP=`head -n1 /etc/ip.eth0` set RealHostName=`dnsname $RealIP | sed -e 's/.sanitarium.net//'` set HostName=$RealHostName endif echo "I appear to be running on $HostName." if ($Arch == "i686") set Arch="i386" if ($Arch == "i586") set Arch="i386" if ($Arch == "i486") set Arch="i386" if ($OS == "Linux") then # Yay, a Linux box # Determine how many CPUs the system has... set ProcNum=`grep ^processor /proc/cpuinfo | tail -n1 | awk '{print $NF}'` # use numcpus+1 threads while compiling the kernel... set NumProc=`echo ${ProcNum}+2 | bc` set Jobs="-j${NumProc}" # Actually compile the kernel make dep || exec echo "ERROR in make dep" make clean || exec echo "ERROR in make clean" make $Jobs bzImage || exec echo "ERROR in make bzImage" #if ($HostName != "asylum") then # I don't do modules on asylum so this will always fail. make $Jobs modules || exec echo "ERROR in make modules" make modules_install || exec echo "ERROR in make modules_install" #endif # now I will attempt to install the actual kernel image... set Version=`grep ^VERSION Makefile | awk '{print $NF}'` set PatchLevel=`grep ^PATCHLEVEL Makefile | awk '{print $NF}'` set SubLevel=`grep ^SUBLEVEL Makefile | awk '{print $NF}'` set ExtraVersion=`grep ^EXTRAVERSION Makefile | awk '{print $NF}'` set KernelVersion="${Version}.${PatchLevel}.${SubLevel}${ExtraVersion}" # detect legacy /boot partitions and put the kernel there instead of in / grep \/boot /proc/mounts > & /dev/null && set Boot="/boot" || set Boot="/" cp -iv arch/${Arch}/boot/bzImage ${Boot}/vmlinuz-$KernelVersion || exec echo "ERROR installing kernel." cp -fv .config /boot/config-$KernelVersion rm -f /boot/System.map ; cp -fv System.map /boot/ #rm -f /boot/System.map ; ln -s /usr/src/linux/System.map /boot/ endif if ($OS == "OpenBSD") then # compile the kernel make clean make depend || exec echo "ERROR in makde depend." make || exec echo "ERROR in make." # put proper permissions on it chmod 644 bsd || exec "ERROR: Kernel not built." # figure out what kernel is being built... set Kernel=`pwd | awk -F/ '{print $NF}'` # cp the kernel into its permanant home. /usr/local/bin/gcp -iv bsd /bsd.${Kernel} echo "To enable the new kernel run:" echo "rm /bsd ; ln /bsd.${Kernel} /bsd" endif