Note: This tutorial assumes that you know how to compile a kernel already. It only looks at a way of creating a package and doesn't aim to show kernel config options.
Note 2: We won't be using the stock Slackware kernel SlackBuilds.
Kernel Output Target Option
The usual way to make any sort of package is via the $DESTDIR variable. The kernel doesn't use this however, but it does have an
Copy your .config into the source directory and do
(or whichever method you prefer.)
You may need to do 'make mrproper' first, and perhaps 'make oldconfig'.
Note: Do not use 'make install' or 'make modules_install', even with O switch, as this *will* install to /boot and /lib/modules.
At this point everything we need is in the source directory. The file modules.order lists the modules to be installed and we can use that to help us make a package.
Installing Modules and Kernel to our Package Directory
Ok let's use /tmp/kernel-package for our package directory. Also let's assume a 220.127.116.11 kernel with jabberwok as local name. A little bash will copy our modules to it:
LIBSDIR=/tmp/kernel-package/lib/modules/18.104.22.168-jabberwok/kernel for i in $(sed "s#^kernel/##" modules.order) do mkdir -p $LIBSDIR/$(dirname $i) install -m 644 -v $i $LIBSDIR/$(dirname $i) done
Now we need the kernel and associated files.
mkdir /tmp/kernel-package/boot cp arch/x86/boot/bzImage /tmp/kernel-package/boot/vmlinuz-22.214.171.124-jabberwok cp System.map /tmp/kernel-package/boot/System.map-126.96.36.199-jabberwok cp .config /tmp/kernel-package/boot/config-188.8.131.52-jabberwok
And then the doinst.sh and slack-desc.
## Taken from stock modules package if [ -x sbin/depmod ]; then chroot . /sbin/depmod -a 184.108.40.206-jabberwok > /dev/null 2> /dev/null fi (cd lib/modules/220.127.116.11-jabberwok ; rm -rf build) (cd lib/modules/18.104.22.168-jabberwok ; ln -sf /usr/src/linux-22.214.171.124-jabberwok build) (cd lib/modules/126.96.36.199-jabberwok ; rm -rf source) (cd lib/modules/188.8.131.52-jabberwok ; ln -sf /usr/src/linux-184.108.40.206-jabberwok source)
# HOW TO EDIT THIS FILE: # The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' # on the right side marks the last column you can put a character in. You must # make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. kernel-jabberwok|-----handy-ruler------------------------------------------------------| kernel-jabberwok: kernel and modules for kernel-jabberwok 220.127.116.11 kernel-jabberwok: kernel-jabberwok: Jabberwokky type kernel! kernel-jabberwok: kernel-jabberwok: kernel-jabberwok: kernel-jabberwok: kernel-jabberwok: kernel-jabberwok: kernel-jabberwok: kernel-jabberwok:
They should both be copied to the install directory.
Making the Package
cd /tmp/kernel-package /sbin/makepkg -l y -c n /tmp/kernel-jabberwok-18.104.22.168-i686-1_tag.txz
Change '_tag' to your usual moniker. Hopefully we now have a package in /tmp. Copy it to a temporary directory somewhere, explodepkg it and check the contents. We don't want to install something with messed up paths etc. If all is well we can installpkg it.
i As usual, edit your /etc/lilo.conf and add an option for the new kernel, keeping the old kernel entry in place for safety, then run lilo.
A Little Automation
Of course this would be easier to control with a script rather than typing in these commands manually and trying not to make typos. Here is the SlackBuild that I've been using (run make menuconfig first):
You should have a /usr/src/linux-$VERSION-$LOCALNAME on your target box or you may have problems later if compiling anything that needs that source.
Do not omit setting localname in .config.
The aim for doing this was to be able to build a kernel for my old T42 on my desktop box using the T42's .config. Note that this does not include the firmware so you should keep the relevant kernel-firmware package installed.
At the end of the day, this helped me to compile a kernel without my laptop getting even warm, which was the point of the project.
If you are packaging kernel 3.0 you will need to change $VERSION to 3.0.0 (and source trees). This is because depmod will not work with 3.0, but there is an update to module-init-tools that fixes this.