I compile the snapshot for pi 4 using default configuration. When I try to install kmod-wireguard in opkg, I got this error
The installed version of package kernel is not compatible, require 5.4.52-1-1e805069… while 5.4.52-1-baff6070… is installed.
However, I can't find any way to select kernel modules that woudl sepcific 5.4.52-1-1e805069. I only find a place that could specify kernel to be 5.4. If I replace /home/XXX/openwrt/package/kernel/linux and in makefile set the patch version to 5.4.52-1-1e805069 will it do the job?
That library is keyed to a specific commit that was at the top of the stack when you compiled, for some reason.. I've seen a few others that do this and I'm not sure its really necessary, but I could be wrong In any case, the only thing you can do is rebuild your packages. This is a real bummer for those who build all the packages, meh..
You are wrong.
The kernel kmods set a a verification check via a hash "vermagic" compiled from the kernel options and kmods selected. That aims to ensure compatibility between kernel and all other kmods. So it is not about a commit, but more complicated. Anomeome already linked to vermagic search.
It is kernel, kernel kmod packages and a few other kernel related userspace packages (that closely interact with kmods).
The goal is to ensure compatibility and prevent crashes. OpenWrt is so close to the actual hardware that many packages are driver-like. It is too easy to make hardware drivers to mysteriously crash if you have version mismatches between different components. That needs to also account for optional features that may be selected at compilation time. That may have impact on the interaction between driver components.
Earlier, ten years ago, there were too many end user problems / bug reports that were difficult to reproduce/debug as the reason was slight mismatches in driver components. So, a version hash was invented to prevent installing mixed components accidentally.
The version magic mainly affects master snapshot users, who try to later install new packages to the build.