Skip to content

Commit dc42f34

Browse files
authored
Update build_and_install_module.sh to match newer Linux kernel version (#1551)
1 parent 6ee6444 commit dc42f34

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

.azure-pipelines/build_and_install_module.sh

+30-33
Original file line numberDiff line numberDiff line change
@@ -28,64 +28,61 @@ function build_and_install_kmodule()
2828
# Install the required debian packages to build the kernel modules
2929
apt-get update
3030
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
3232
apt-get install -y libnl-route-3-200 libnl-route-3-dev libnl-cli-3-200 libnl-cli-3-dev libnl-3-dev
3333

3434
# Add the apt source mirrors and download the linux image source code
3535
cp /etc/apt/sources.list /etc/apt/sources.list.bk
3636
sed -i "s/^# deb-src/deb-src/g" /etc/apt/sources.list
3737
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
3949

4050
# Recover the original apt sources list
4151
cp /etc/apt/sources.list.bk /etc/apt/sources.list
4252
apt-get update
4353

4454
# Build the Linux kernel module drivers/net/team and vrf
4555
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
4662
make allmodconfig
4763
mv .config .config.bk
4864
cp /boot/config-$(uname -r) .config
4965
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
5566
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
5769
mv drivers/net/Makefile drivers/net/Makefile.bak
5870
echo 'obj-$(CONFIG_NET_VRF) += vrf.o' > drivers/net/Makefile
5971
echo 'obj-$(CONFIG_MACSEC) += macsec.o' >> drivers/net/Makefile
60-
make M=drivers/net
72+
make -j$(nproc) M=drivers/net
6173

6274
# 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
8683

8784
cd /tmp
8885
rm -rf $WORKDIR
8986
}
9087

91-
build_and_install_kmodule
88+
build_and_install_kmodule

0 commit comments

Comments
 (0)