Screw up your courage! You've screwed up everything else.
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 O switch which does almost the same thing, although the output might not be exactly what you expect. I will not be using that option here.
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, which we don't want.
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 18.104.22.168 kernel with jabberwok as local name. A little bash will copy our modules to it:
LIBSDIR=/tmp/kernel-package/lib/modules/22.214.171.124-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-126.96.36.199-jabberwok cp System.map /tmp/kernel-package/boot/System.map-188.8.131.52-jabberwok cp .config /tmp/kernel-package/boot/config-184.108.40.206-jabberwok
## Taken from stock modules package if [ -x sbin/depmod ]; then chroot . /sbin/depmod -a 220.127.116.11-jabberwok > /dev/null 2> /dev/null fi (cd lib/modules/18.104.22.168-jabberwok ; rm -rf build) (cd lib/modules/22.214.171.124-jabberwok ; ln -sf /usr/src/linux-126.96.36.199-jabberwok build) (cd lib/modules/188.8.131.52-jabberwok ; rm -rf source) (cd lib/modules/184.108.40.206-jabberwok ; ln -sf /usr/src/linux-220.127.116.11-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 18.104.22.168 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-22.214.171.124-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.
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 script 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. It could be possible to split up kernel and modules into separate packages (howto for that coming soon). 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.