[semi OFFTOPIC] Shell script to automate kernel builds

William Stearns (wstearns@pobox.com)
Sun, 23 Nov 1997 23:13:23 -0500 (EST)


Good day, all,

I've written a bash script that automates the kernel build
process. It's almost, but not quite, ready for prime time. I'm hoping
that some of you reading this might be willing to try it and offer
constructive criticism. I am also willing to add new features - there's
already a list of things to be done in buildkernel.doc. As an attempt to
try to release a functional tool, however, I'm trying not to add too many
more features before a stable 1.0 release. I will, however, keep track of
all suggestions - there's always 1.1!
"But we already know how to build a kernel!", I hear most of you
say. Too true, but by automating the process, this can free you up to do
other things and focus on which patches to try, etc.
If you are planning to cross compile, be aware that the script
does delete the code for any architecture other than the one it's running
on. This is the only case I can think of where you might not want to use
the script or at least comment out that section. It might later be
configurable...

Here are some of the features, taken from the .doc file:
---------------------------------------------------------------------------
Most of the following features can be enabled or disabled by user
choices. These choices can be preset in the shell environment, stored in
a configuration file, or specified on the command line. If any options
are unspecified, the script deduces intelligent defaults for them. A
number of them are checked for invalid values.
The script will download and open up the source for a kernel and
the pcmcia utilities(*). It removes source code that is not useful for
this machine. The necessary symbolic links are created. If the user
places patches in a particular directory, these patches will be applied
automatically (the build halts if rejects are found so that the user can
fix the patch, remove it, or reorder the patches).
While building, it will initiate multiple simultaneous builds to
make better use of the processors in the system. The builds are "nice'd"
to reduce impact on foreground tasks.
The script has a hands-off mode that, barring errors in the build
process, will complete the build without pausing for user input. If
you've already chosen your kernel configuration options, this lets the
build proceed without interruption.
The compiled kernel is configured. The resulting kernel, modules,
pcmcia modules, and System.map are copied to the correct locations.
Throughout the process, the script works hard (goes overboard?) in
checking that files and directories exist and that the build is
progressing correctly.
---------------------------------------------------------------------------

Please be warned that this is late alpha/early beta level
software. There is a chance that this may do any number of nasty things to
your system - I would encourage you to make a backup before using it.
That said, I really have tried to make this script careful about
what it does. I don't have any interest in having it blow up my own
system either!

There are a few things I know I need help with. These are
listed in buildkernel.doc in section 7.1. As I get closer to 1.0 I am
focusing on cleaning it up. For now, I want to make it bulletproof.

* Finally, most of the features are implemented and have had some
testing. Pcmcia-cs autodownload is not yet one of those. The script
will _build_ pcmcia-cs if requested; it simply won't automatically
download the pcmcia-cs sources. This script has had most of its testing
on my system - a Redhat 4.2 Intel system. It is really in need of testing
on non-intel, non-RedHat systems.

Because the package is 26K, I've chosen not to attach it here.
The script can be found at:
http://www.pobox.com/~wstearns/buildkernel/index.html
or
ftp://x.websense.net/pub/buildkernel
I recommend the web site; the ftp site is there for those without
web access and may move; the web site should be permanent. If you can't
get to either of these, let me know and I'll email you a copy.

Any takers? Thanks.
- Bill

---------------------------------------------------------------------------
Unix _is_ user friendly. It's just very selective about who its friends
are. And sometimes even best friends have fights.
William Stearns (wstearns@pobox.com) http://www.websense.net
---------------------------------------------------------------------------