Subject: Kernel build script
To: 'NetBSD/VAX Port' <port-vax@NetBSD.ORG>
From: Gunnar Helliesen <gunnar@bitcon.no>
List: port-vax
Date: 11/24/1996 17:53:05
Folks,
As I've been building (or rather, trying to build) a lot of kernels
lately, I've created a kernel build script to help automate the process.
I've tested it on VAX and i386 NetBSD machines, the VAX running 1.1B and
the i386 running 1.2.
I thought I might post it here in case others would like to use it.
I call the script "doconfig". Don't forget to chmod it to 755...
Here it is:
+++++++++++++++++++ cut here
++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
#
# Version 0.9, 24-Nov-96.
#
# Simple shell-script to more-or-less automate the kernel building
# process. The script can't help you with bugs in the source though...
;-)
# Created by Gunnar Helliesen, Bergen IT Consult AS, <gunnar@bitcon.no>
# Distribute freely, but give me credit, OK?
#
# The script assumes that you have already downloaded and unpacked the
# kernel source in /usr/src/sys.
#
# Usage: doconfig <config-name> {init|rebuild|resume}
# <config-name> is the name of the kernel configuration
# Use init if this is the first time you build this version
# Use rebuild if you want to rebuild this version from scratch
# Use resume if you want to resume an interrupted build
#
# Note: if you're doing a major upgrade, like building a 1.2 kernel on
# a 1.1 system, you should download and install the include source as
# well (in /usr/src/include).
#
# Set up variables.
ARCH=`uname -m`
INSTALL=`which install`; export INSTALL
# Test input parameters.
if [ $# -lt 2 ] ; then
echo "*** Usage: $0 <config-name> {init|rebuild|resume}"
echo "*** where:"
echo "*** <config-name> is the name of the kernel configuration file"
echo "*** (usually GENERIC)."
echo "*** init means start from scratch (deleting any previous build"
echo "*** directory if it exists). This option will install the
include"
echo "*** files found in the kernel source tree. Use this option if
you"
echo "*** have not built this version on this system before."
echo "*** rebuild means rebuild this version from a clean build
directory."
echo "*** Use this option if you have built this version on this
system"
echo "*** before but have since changed the configuration file.
This"
echo "*** option will delete any previous build directory if it
exists."
echo "*** resume means resume a previous build that was interrupted"
echo "*** (this option does not delete anything)"
echo "***"
echo "*** If you don't understand any of this and just want to get on
with"
echo "*** it, type: $0 GENERIC init"
exit 1
fi
# OK, at least we got the correct number of parameters. Now, let's check
if
# they make any sense.
case "$2" in
'init')
INCLUDES=YES
DELETE=YES
CONFIG=YES
;;
'rebuild')
INCLUDES=NO
DELETE=YES
CONFIG=YES
;;
'resume')
INCLUDES=NO
DELETE=NO
CONFIG=NO
;;
*)
echo "*** Sorry, illegal parameters. Enter $0"
echo "*** for usage information."
exit 1
;;
esac
if [ -f /sys/arch/$ARCH/conf/$1 ] ; then
echo "*** Config file found, proceeding..."
else
echo "*** Configuration file $1 doesn't exist!"
echo "*** Exiting..."
exit 1
fi
# Everything seems in order. Say hello to the user.
echo "***"
echo "*** Welcome to the kernel build procedure. This may take a while,"
echo "*** why not go grab a cuppacoffee? Or come back next week if
you're"
echo "*** building on a MicroVAX II... ;-)"
echo "***"
# Make includes if so instructed.
if [ $INCLUDES = "YES" ] ; then
echo "*** Making includes (cd /sys; make includes)"
cd /sys; make includes
if [ $? -eq 0 ] ; then
echo "*** Done."
else
echo "*** Couldn't make includes. Correct the problem and restart."
echo "*** Exiting..."
exit 1
fi
fi
# Delete old build directory if needed.
if [ $DELETE = "YES" ] ; then
if [ -d /sys/arch/$ARCH/compile/$1 ] ; then
echo "*** Removing old build directory (cd /sys/arch/$ARCH/compile; rm
-rf $1)
"
cd /sys/arch/$ARCH/compile; rm -rf $1
if [ $? -eq 0 ] ; then
echo "*** Done."
else
echo "*** Unable to remove old build directory!"
echo "*** Exiting..."
exit 1
fi
else
echo "*** No previous build directory to delete. Proceeding..."
fi
fi
# Update the kernel configuration.
if [ $CONFIG = "YES" ] ; then
echo "*** Updating configuration (cd /sys/arch/$ARCH/conf; config $1)"
cd /sys/arch/$ARCH/conf; config $1
if [ $? -eq 0 ] ; then
echo "*** Done."
else
echo "*** Unable to configure the new kernel!"
echo "*** Exiting..."
exit 1
fi
fi
# OK, here we go. Start the kernel build.
if [ -d /sys/arch/$ARCH/compile/$1 ] ; then
if [ $ARCH != "vax" ] ; then
echo "*** Running make depend (cd /sys/arch/$ARCH/compile/$1; make
depend 2>&1
> ../$1.depend.log)"
cd /sys/arch/$ARCH/compile/$1; make depend 2>&1 > ../$1.depend.log
if [ $? -eq 0 ] ; then
echo "*** Done."
else
echo "*** Unable to run make depend!"
echo "*** Examine the log file for details, the log file was:"
echo "*** /sys/arch/$ARCH/compile/$1.depend.log"
echo "*** Exiting..."
exit 1
fi
fi
echo "*** Starting the kernel build, this may take a while."
echo "*** (cd /sys/arch/$ARCH/compile/$1; make 2>&1 > ../$1.build.log)"
echo "*** You might want to background this process and rather keep"
echo "*** an eye on the logfile with the tail command like this:"
echo "*** tail -f /sys/arch/$ARCH/compile/$1.build.log"
echo "*** To background the build, press ^Z (CNTRL/Z) now and enter"
echo "*** bg at the prompt."
cd /sys/arch/$ARCH/compile/$1; make 2>&1 > ../$1.build.log
if [ $? -eq 0 ] ; then
echo "*** Done."
if [ -f /sys/arch/$ARCH/compile/$1/netbsd ] ; then
echo "*** New kernel is /sys/arch/$ARCH/compile/$1/netbsd"
else
echo "*** Couldn't find the new kernel image! Something must have"
echo "*** gone wrong..."
echo "*** Examine the log file for details, the log file was:"
echo "*** /sys/arch/$ARCH/compile/$1.build.log"
echo "*** Exiting..."
exit 1
fi
else
echo "*** Something went belly-up, the kernel build crashed."
echo "*** Examine the log file for details, the log file was:"
echo "*** /sys/arch/$ARCH/compile/$1.build.log"
echo "*** Exiting..."
exit 1
fi
else
echo "*** ??? Couldn't find build directory!"
if [ $CONFIG = "NO" ] ; then
echo "*** Maybe you should try the init or rebuild option instead."
fi
echo "*** Exiting..."
exit 1
fi
# We outta here. Say goodbye.
echo "*** All done, exiting..."
exit 0
+++++++++++++++++++ cut here
++++++++++++++++++++++++++++++++++++++++++++++
Let me know if you like it and use (or improve it).
Gunnar
--
Gunnar Helliesen | Bergen IT Consult AS | NetBSD/VAX on a uVAX II
Systems Consultant | Bergen, Norway | '86 Jaguar Sovereign 4.2
gunnar@bitcon.no | http://www.bitcon.no/ | '73 Mercedes 280 (240D)