@@ -28,64 +28,61 @@ function build_and_install_kmodule()
28
28
# Install the required debian packages to build the kernel modules
29
29
apt-get update
30
30
apt-get install -y build-essential linux-headers-${KERNEL_RELEASE} autoconf pkg-config fakeroot
31
- apt-get install -y flex bison libssl-dev libelf-dev
31
+ apt-get install -y flex bison libssl-dev libelf-dev dwarves
32
32
apt-get install -y libnl-route-3-200 libnl-route-3-dev libnl-cli-3-200 libnl-cli-3-dev libnl-3-dev
33
33
34
34
# Add the apt source mirrors and download the linux image source code
35
35
cp /etc/apt/sources.list /etc/apt/sources.list.bk
36
36
sed -i " s/^# deb-src/deb-src/g" /etc/apt/sources.list
37
37
apt-get update
38
- 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
39
49
40
50
# Recover the original apt sources list
41
51
cp /etc/apt/sources.list.bk /etc/apt/sources.list
42
52
apt-get update
43
53
44
54
# Build the Linux kernel module drivers/net/team and vrf
45
55
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
46
62
make allmodconfig
47
63
mv .config .config.bk
48
64
cp /boot/config-$( uname -r) .config
49
65
grep NET_TEAM .config.bk >> .config
50
- echo CONFIG_NET_VRF=m >> .config
51
- echo CONFIG_MACSEC=m >> .config
52
- echo CONFIG_NET_VENDOR_MICROSOFT=y >> .config
53
- echo CONFIG_MICROSOFT_MANA=m >> .config
54
- echo CONFIG_SYSTEM_REVOCATION_LIST=n >> .config
55
66
make VERSION=$VERSION PATCHLEVEL=$PATCHLEVEL SUBLEVEL=$SUBLEVEL EXTRAVERSION=-${EXTRAVERSION} LOCALVERSION=-${LOCALVERSION} modules_prepare
56
- make M=drivers/net/team
67
+ cp /usr/src/linux-headers-$( uname -r) /Module.symvers .
68
+ make -j$( nproc) M=drivers/net/team
57
69
mv drivers/net/Makefile drivers/net/Makefile.bak
58
70
echo ' obj-$(CONFIG_NET_VRF) += vrf.o' > drivers/net/Makefile
59
71
echo ' obj-$(CONFIG_MACSEC) += macsec.o' >> drivers/net/Makefile
60
- make M=drivers/net
72
+ make -j $( nproc ) M=drivers/net
61
73
62
74
# Install the module
63
- TEAM_DIR=$( echo /lib/modules/$( uname -r) /kernel/net/team)
64
- NET_DIR=$( echo /lib/modules/$( uname -r) /kernel/net)
65
- if [ ! -e " $TEAM_DIR /team.ko" ]; then
66
- mkdir -p $TEAM_DIR
67
- cp drivers/net/team/* .ko $TEAM_DIR /
68
- modinfo $TEAM_DIR /team.ko
69
- depmod
70
- modprobe team
71
- fi
72
- if [ ! -e " $NET_DIR /vrf.ko" ]; then
73
- mkdir -p $NET_DIR
74
- cp drivers/net/vrf.ko $NET_DIR /
75
- modinfo $NET_DIR /vrf.ko
76
- depmod
77
- modprobe vrf
78
- fi
79
- if [ ! -e " $NET_DIR /macsec.ko" ]; then
80
- mkdir -p $NET_DIR
81
- cp drivers/net/macsec.ko $NET_DIR /
82
- modinfo $NET_DIR /macsec.ko
83
- depmod
84
- modprobe macsec
85
- 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
86
83
87
84
cd /tmp
88
85
rm -rf $WORKDIR
89
86
}
90
87
91
- build_and_install_kmodule
88
+ build_and_install_kmodule
0 commit comments