@@ -26,62 +26,60 @@ function build_and_install_kmodule()
2626 SUBLEVEL=$( echo $KERNEL_MAINVERSION | cut -d. -f3)
2727
2828 # Install the required debian packages to build the kernel modules
29+ apt-get update
2930 apt-get install -y build-essential linux-headers-${KERNEL_RELEASE} autoconf pkg-config fakeroot
30- apt-get install -y flex bison libssl-dev libelf-dev
31+ apt-get install -y flex bison libssl-dev libelf-dev dwarves
3132 apt-get install -y libnl-route-3-200 libnl-route-3-dev libnl-cli-3-200 libnl-cli-3-dev libnl-3-dev
3233
3334 # Add the apt source mirrors and download the linux image source code
3435 cp /etc/apt/sources.list /etc/apt/sources.list.bk
3536 sed -i " s/^# deb-src/deb-src/g" /etc/apt/sources.list
3637 apt-get update
37- apt-get source linux-image-unsigned-$( uname -r) > source.log
38+ KERNEL_PACKAGE_SOURCE=$( apt-cache show linux-image-unsigned-${KERNEL_RELEASE} | grep ^Source: | cut -d' :' -f 2)
39+ KERNEL_PACKAGE_VERSION=$( apt-cache show linux-image-unsigned-${KERNEL_RELEASE} | grep ^Version: | cut -d' :' -f 2)
40+ SOURCE_PACKAGE_VERSION=$( apt-cache showsrc ${KERNEL_PACKAGE_SOURCE} | grep ^Version: | cut -d' :' -f 2)
41+ if [ ${KERNEL_PACKAGE_VERSION} != ${SOURCE_PACKAGE_VERSION} ]; then
42+ echo " WARNING: the running kernel version (${KERNEL_PACKAGE_VERSION} ) doesn't match the source package " \
43+ " version (${SOURCE_PACKAGE_VERSION} ) being downloaded. There's no guarantee the module being downloaded " \
44+ " can be loaded into the kernel or function correctly. If possible, please update your kernel and reboot " \
45+ " your system so that it's running the matching kernel version." >&2
46+ echo " Continuing with the build anyways" >&2
47+ fi
48+ apt-get source linux-image-unsigned-${KERNEL_RELEASE} > source.log
3849
3950 # Recover the original apt sources list
4051 cp /etc/apt/sources.list.bk /etc/apt/sources.list
4152 apt-get update
4253
4354 # Build the Linux kernel module drivers/net/team and vrf
4455 cd $( find . -maxdepth 1 -type d | grep -v " ^.$" )
56+ if [ -e debian/debian.env ]; then
57+ source debian/debian.env
58+ if [ -n " ${DEBIAN} " -a -e ${DEBIAN} /reconstruct ]; then
59+ bash ${DEBIAN} /reconstruct
60+ fi
61+ fi
4562 make allmodconfig
4663 mv .config .config.bk
4764 cp /boot/config-$( uname -r) .config
4865 grep NET_TEAM .config.bk >> .config
49- echo CONFIG_NET_VRF=m >> .config
50- echo CONFIG_MACSEC=m >> .config
51- echo CONFIG_NET_VENDOR_MICROSOFT=y >> .config
52- echo CONFIG_MICROSOFT_MANA=m >> .config
53- echo CONFIG_SYSTEM_REVOCATION_LIST=n >> .config
5466 make VERSION=$VERSION PATCHLEVEL=$PATCHLEVEL SUBLEVEL=$SUBLEVEL EXTRAVERSION=-${EXTRAVERSION} LOCALVERSION=-${LOCALVERSION} modules_prepare
55- make M=drivers/net/team
67+ cp /usr/src/linux-headers-$( uname -r) /Module.symvers .
68+ make -j$( nproc) M=drivers/net/team
5669 mv drivers/net/Makefile drivers/net/Makefile.bak
5770 echo ' obj-$(CONFIG_NET_VRF) += vrf.o' > drivers/net/Makefile
5871 echo ' obj-$(CONFIG_MACSEC) += macsec.o' >> drivers/net/Makefile
59- make M=drivers/net
72+ make -j $( nproc ) M=drivers/net
6073
6174 # Install the module
62- TEAM_DIR=$( echo /lib/modules/$( uname -r) /kernel/net/team)
63- NET_DIR=$( echo /lib/modules/$( uname -r) /kernel/net)
64- if [ ! -e " $TEAM_DIR /team.ko" ]; then
65- mkdir -p $TEAM_DIR
66- cp drivers/net/team/* .ko $TEAM_DIR /
67- modinfo $TEAM_DIR /team.ko
68- depmod
69- modprobe team
70- fi
71- if [ ! -e " $NET_DIR /vrf.ko" ]; then
72- mkdir -p $NET_DIR
73- cp drivers/net/vrf.ko $NET_DIR /
74- modinfo $NET_DIR /vrf.ko
75- depmod
76- modprobe vrf
77- fi
78- if [ ! -e " $NET_DIR /macsec.ko" ]; then
79- mkdir -p $NET_DIR
80- cp drivers/net/macsec.ko $NET_DIR /
81- modinfo $NET_DIR /macsec.ko
82- depmod
83- modprobe macsec
84- fi
75+ SONIC_MODULES_DIR=/lib/modules/$( uname -r) /updates/sonic
76+ mkdir -p $SONIC_MODULES_DIR
77+ cp drivers/net/team/* .ko drivers/net/vrf.ko drivers/net/macsec.ko $SONIC_MODULES_DIR /
78+ depmod
79+ modinfo team vrf macsec
80+ modprobe team
81+ modprobe vrf
82+ modprobe macsec
8583
8684 cd /tmp
8785 rm -rf $WORKDIR
0 commit comments