Does anyone have a debugging kernel SlackBuild? (or the experience of making one)
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Does anyone have a debugging kernel SlackBuild? (or the experience of making one)
Hello, everyone.
I seem to be needing a few features of the debugging kernel (such a KPROBES).
I have built the kernel myself and had a few successful days of work, but the kernel keeps getting updated almost daily, so just through that I'd better make a script that rebuilds everything as soon as the kernel is updated.
So in order to avoid reinventing the wheel, I'm asking if anyone has had such a thing done before and can share their scripts?
Additionally, if I end up rebuilding the kernel anyway, suggestions on a good "debugging" kernel .config are welcome.
Note that I made no particular effort to make the script “generic”, it is tailored for my needs and probably cannot (or should not) be directly re-used without some adjustments.
Note also that the script does not take care of configuring the kernel: it assumes the kernel source tree has already been configured (using make config or any similar configuration command).
Code:
#!/bin/bash
set -e
if [ ! -f Kbuild ]; then
echo "This script should be run in a Linux source tree!"
exit 1
fi
MACHINE=${MACHINE:-$(uname -n | cut -d. -f1)}
JOBS=${JOBS:-7}
OUT=${OUT:-/tmp}
PKG=${PKG:-$OUT/kernel}
KERNEL_RELEASE=$(make -s kernelrelease)
KERNEL_VERSION=$(make -s kernelversion)
# Extract the build number from CONFIG_LOCALVERSION
BUILD=$(echo ${KERNEL_RELEASE#*-} | tr a-z A-Z)
[ "$BUILD" != "$KERNEL_RELEASE" ] || BUILD=1GGD
# Build the kernel amd the modules
make -j $JOBS bzImage
make -j $JOBS modules
# Install modules in stage directory
make modules_install INSTALL_MOD_PATH=$PKG
rm $PKG/lib/modules/$KERNEL_RELEASE/{source,build}
# Delete module signing key
rm certs/signing_key.pem
# Install kernel and associated files in /boot
install -D -m 0644 arch/x86_64/boot/bzImage $PKG/boot/vmlinuz-$KERNEL_RELEASE
install -m 0644 System.map $PKG/boot/System.map-$KERNEL_RELEASE
install -m 0644 .config $PKG/boot/config-$KERNEL_RELEASE
# Install the kernel in the EFI filesystem
install -D -m 0644 arch/x86_64/boot/bzImage $PKG/boot/efi/EFI/Slackware/vmlinuz-$KERNEL_RELEASE
# Post-install script:
# * Build the initrd and copy it to the EFI filesystem
# * Add an ELILO entry for the new kernel
mkdir -p $PKG/install
cat <<EOF >$PKG/install/doinst.sh
#!/bin/sh
mkinitrd -F -c -k $KERNEL_RELEASE -o boot/initrd-$KERNEL_RELEASE.gz -s tmp/initrd-$KERNEL_RELEASE-tree
rm -rf tmp/initrd-$KERNEL_RELEASE-tree
cp boot/initrd-$KERNEL_RELEASE.gz boot/efi/EFI/Slackware/initrd-$KERNEL_RELEASE.gz
cat <<EOG >> boot/efi/EFI/Slackware/elilo.conf
image=vmlinuz-$KERNEL_RELEASE
label=linux-$MACHINE-$KERNEL_RELEASE
initrd=initrd-$KERNEL_RELEASE.gz
read-only
EOG
echo
echo Kernel installed. Do not forget to edit
echo /boot/efi/EFI/Slackware/elilo.conf to boot
echo on the new kernel by default.
echo
EOF
chmod 755 $PKG/install/doinst.sh
# Add package description
cat <<EOF >$PKG/install/slack-desc
kernel-$MACHINE: kernel-$MACHINE (custom-built Linux kernel)
kernel-$MACHINE:
kernel-$MACHINE: This is a Linux kernel specifically built for $MACHINE.
kernel-$MACHINE:
kernel-$MACHINE:
kernel-$MACHINE:
kernel-$MACHINE:
kernel-$MACHINE:
kernel-$MACHINE:
kernel-$MACHINE:
kernel-$MACHINE:
EOF
# Package the whole thing
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/kernel-$MACHINE-$KERNEL_VERSION-x86_64-$BUILD.txz
rm -rf $PKG
"
su -c "$PACKAGING"
A minor tweak you might like to prevent needing to edit your elilo.conf afterwards. Instead of using cat, use sed, which can add it to the top of the Linux stanzas rather than the bottom. This would prevent you from needing to edit the conf file after installation and the newest kernel would always be the default.
Looking at my elilo.conf, there is a # before the individual stanzas start, so if you search for that, you can add text right after it (you could also add text to search for, like "# Linux Stanzas" to prevent any issues if you add additional comments). This will redirect the output into an elilo.conf in your package, which will overwrite the one on your system when you install the package.
Code:
sed "/#/aimage=vmlinuz-$KERNEL_RELEASE\n label=linux-$MACHINE-$KERNEL_RELEASE\n initrd=initrd-$KERNEL_RELEASE.gz\n read-only\n" /boot/efi/EFI/Slackware/elilo.conf > $PKG/boot/efi/EFI/Slackware/elilo.conf
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.