cplayground
cplayground copied to clipboard
Figure out how to build kernel with custom version string
build-kernel.sh applies this patch to the kernel code in order to make get_files_struct
and put_files_struct
available to kernel modules. (I have no idea why these are not exported in the first place; they're pretty important.) However, the compiled kernel ends up being built with the normal version string; if I run uname -r
, it returns 5.3.0-42-generic
. It would be nice to have a version suffix added, so that we can see in production that we're running the cplayground kernel (e.g. 5.3.0-42+cplayground-generic
).
The Ubuntu build instructions say to do this by modifying debian.master/changelog
, but this didn't work for me. I did a lot of Googling and saw some other possible methods (e.g. editing the Makefile
) but I haven't had time to get anything to work.
Some quick research reveals a few useful things:
- https://unix.stackexchange.com/q/136959
- There are
EXTRAVERSION
(top of the Makefile) andLOCALVERSION
("General Setup -> Local version - append to kernel release") config flags which may or may not help
I'm taking a poke at this, currently trying to get build-kernel.sh
to consistently succeed. If we have to do much more in terms of kernel patch development it might be worth revisiting the build time and process for the kernel to see if we can improve either, but hopefully that shouldn't be necessarily.
Edit: This link, on how to make a custom "flavour," looks potentially the most useful yet.
For what it's worth, if I try the LOCALVERSION tweak as described above via debian/rules editconfig
, the build seems to go fairly well until this bit:
Some make output
#
# Build module blacklists:
# - blacklist all watchdog drivers (LP:1432837)
#
install -d /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modprobe.d
echo "# Kernel supplied blacklist for linux-hwe 5.3.0-62-generic amd64" \
>/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modprobe.d/blacklist_linux-hwe_5.3.0-62-generic.conf
for conf in amd64-generic amd64 common.conf; do \
if [ -f debian.hwe/modprobe.d/$conf ]; then \
echo "# modprobe.d/$conf"; \
cat debian.hwe/modprobe.d/$conf; \
fi; \
done >>/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modprobe.d/blacklist_linux-hwe_5.3.0-62-generic.conf
echo "# Autogenerated watchdog blacklist" \
>>/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modprobe.d/blacklist_linux-hwe_5.3.0-62-generic.conf
ls -1 /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel/drivers/watchdog/ | \
grep -v '^bcm2835_wdt$' | \
sed -e 's/^/blacklist /' -e 's/.ko$//' | \
sort -u \
>>/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modprobe.d/blacklist_linux-hwe_5.3.0-62-generic.conf
ls: cannot access '/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel/drivers/watchdog/': No such file or directory
#
# Remove all modules not in the inclusion list.
#
if [ -f debian.hwe/control.d/generic.inclusion-list ] ; then \
/sbin/depmod -v -b /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic 5.3.0-62-generic | \
sed -e "s@/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel/@@g" | \
awk '{ print $1 " " $NF}' >/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/build/build-generic/module-inclusion.depmap; \
mkdir -p /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-extra-5.3.0-62-generic/lib/modules/5.3.0-62-generic; \
mv /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel \
/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-extra-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel; \
/bin/bash -e debian/scripts/module-inclusion --master \
/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-extra-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel \
/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel \
debian.hwe/control.d/generic.inclusion-list \
/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/build/build-generic/module-inclusion.depmap 2>&1 | \
tee generic.inclusion-list.log; \
/sbin/depmod -b /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic -ea -F /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/boot/System.map-5.3.0-62-generic \
5.3.0-62-generic 2>&1 |tee generic.depmod.log; \
if [ `grep -c 'unknown symbol' generic.depmod.log` -gt 0 ]; then \
echo "EE: Unresolved module dependencies in base package!"; \
exit 1; \
fi \
fi
depmod: ERROR: could not open directory /root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
mv: cannot stat '/root/cplayground/src/server/kernel/linux-hwe-5.3.0/debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic/kernel': No such file or directory
debian/rules.d/2-binary-arch.mk:113: recipe for target 'install-generic' failed
make: *** [install-generic] Error 1
It looks like it looks for linux-modules-5.3.0-62-generic
in some places where it should be looking for linux-modules-5.3.0-62-generic-cplayground
, which maybe indicates there's another place we need to tweak that string for Debian. The build seems to work - I'm getting a debian/build/build-generic/vmlinux
file - although I haven't done any kernel hacking before, so maybe I'm looking at the wrong thing.
The directory which does exist is debian/linux-modules-5.3.0-62-generic/lib/modules/5.3.0-62-generic-cplayground/
: I still see reference to a -generic
without cplayground
in part of the path; something (a packaging thing for Debian, maybe?) is confused.