#!/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 # Determine how many CPUs the system has... set ProcNum=`grep ^processor /proc/cpuinfo | wc -l` # comatose has lots of RAM and runs over NFS so pile up the CPU load so it has stuff to do while it waits on NFS. if ("$HostName" == "comatose") set ProcNum=8 # use numcpus+2 threads while compiling the kernel... set NumProc=`echo ${ProcNum}+2 | bc` 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}' | sed -e 's/^=//'` set KernelVersion="${Version}.${PatchLevel}.${SubLevel}${ExtraVersion}" set Boot="/boot" 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" make $Jobs modules || exec echo "ERROR in make modules" make modules_install || exec echo "ERROR in make modules_install" # now I will attempt to install the actual kernel image... 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/ if ( -e /boot/initramfs.cpio.gz) then rm -fv /boot/initrd-${KernelVersion}.gz cp -lv /boot/initramfs.cpio.gz /boot/initrd-${KernelVersion}.gz else endif if ( -e /usr/sbin/grub-mkconfig) then /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg endif endif if ($OS == "OpenBSD") then # compile the kernel make -j6 clean make -j6 depend || exec echo "ERROR in makde depend." make -j6 || 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