Skip to content

Support build on eLxr when multi headers pkgs installed

When build this OOT module on eLxr target and multi headers
packages are available on it, e.g.
root@elxr-server:~# dpkg -l |grep linux-headers
ii linux-headers-6.1.0-29-amd64 6.1.123-elxr1-1
amd64 Header files for Linux 6.1.0-29-amd64
ii linux-headers-6.1.0-29-common 6.1.123-elxr1-1
all Common header files for Linux 6.1.0-29
ri linux-headers-6.1.0-32-amd64 6.1.129-elxr1-1
amd64 Header files for Linux 6.1.0-32-amd64
ii linux-headers-6.1.0-32-common 6.1.129-elxr1-1
all Common header files for Linux 6.1.0-32
ii linux-headers-amd64 6.1.123-elxr1-1
amd64 Header files for Linux amd64 configuration (meta-package)

the var "kheaders_name" will get a result as:
"linux-headers-6.1.0-29-amd64
linux-headers-6.1.0-32-amd64".
This will cause build error because only one
linux-headers-6.1.0-XX-amd64 path under /usr/src is expected by
the debian/rules code. It can also cause error for var "kversion".

To fix this issue, use "uname -r" to get the definite "kversion"
from running kernel version even when multi headers packages are
installed on system.

But above way only works when building modules on eLxr system.
If build on other systems (e.g. debian bookworm runner used by
gitlab pipeline), "uname -r" can't return the target eLxr kernel
version that this package will run on. This will cause build error.
So we will deal with eLxr system and gitlab pipeline differently to
make the build work for both.

Signed-off-by: Li Zhou li.zhou@windriver.com


Test case (1): build on eLxr target
The kernel version running on the target is lower than the newest on eLxr mirror, e.g 6.1.123-elxr1-1 (ABI version: 6.1.0-29)

apt-get install -y devscripts
//install 2 sets of kernel headers pakcages
apt-get install linux-headers-amd64
apt-get install linux-headers-amd64=6.1.123-elxr1-1
git clone https://gitlab.com/elxr/kernel/hello-world.git
tar zcvf hello-world_1.0-elxr2b3.orig.tar.gz hello-world/
cd hello-world
debuild -uc -us -ui
dpkg -i ../hello-world-common_*.deb
dpkg -i ..hello-world_*.deb
modprobe hello-world
The hello-world module is installed successfully on system by checking "lsmod |grep hello"
The ko in package is installed to /lib/modules/6.1.0-29-amd64.

Test case (2): pipeline build job succeed and the ko in package is installed to /lib/modules/6.1.0-32-amd64.

Edited by Li Zhou

Merge request reports

Loading