Skip to content

Commit f781acf

Browse files
authored
Merge pull request #1262 from c-po/kernel-build-improvements
Kernel: T9181: modernize packaging and remove redundant work
2 parents 7633417 + 07a3aa7 commit f781acf

16 files changed

Lines changed: 508 additions & 475 deletions

scripts/package-build/linux-kernel/build-accel-ppp-ng.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ if [ ! -f ${KERNEL_VAR_FILE} ]; then
1818
exit 1
1919
fi
2020

21-
# Build VPP as we need VPP libraries
22-
cd ../vpp/
23-
./build.py
24-
cd ${CWD}
21+
# Build VPP as we need VPP libraries. This is a full VPP build (make pkg-deb),
22+
# not just headers, since that's the only build target VPP exposes here - skip
23+
# it if a previous run already produced the libraries we link against. Remove
24+
# ${VPP_LIB_CHECK_PATH} (or the whole ../vpp/vpp checkout) to force a rebuild,
25+
# e.g. after bumping the VPP commit_id in ../vpp/package.toml.
26+
if [ ! -d ${VPP_LIB_CHECK_PATH} ]; then
27+
cd ../vpp/
28+
./build.py
29+
cd ${CWD}
30+
fi
2531

2632
if [ ! -d ${VPP_LIB_CHECK_PATH} ]; then
2733
echo "VPP source libraries not found"
@@ -70,5 +76,7 @@ cpack -G DEB
7076
# rename resulting Debian package according git description
7177
mv accel-ppp*.deb ${CWD}/accel-ppp-ng_$(git describe --always --tags)_$(dpkg --print-architecture).deb
7278

73-
# move VPP binaries to linux-kernel dir, CI will get VPP .deb here
74-
cp ${CWD}/../vpp/*.deb ${CWD}
79+
# move VPP binaries to linux-kernel dir, CI will get VPP .deb here.
80+
# If the VPP build was skipped above (libraries already present from a
81+
# prior run), there may be no fresh .deb here to copy - that's fine.
82+
cp ${CWD}/../vpp/*.deb ${CWD} 2>/dev/null || echo "I: No freshly built VPP .deb to copy"
Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/sh
2+
set -e
23
CWD=$(pwd)
34
KERNEL_VAR_FILE=${CWD}/kernel-vars
5+
. ${CWD}/common.sh
46

5-
if ! dpkg-architecture -iamd64; then
6-
echo "Intel drivers only buildable on amd64 platforms"
7-
exit 0
8-
fi
7+
require_amd64 "Intel drivers"
98

109
if [ ! -f ${KERNEL_VAR_FILE} ]; then
1110
echo "Kernel variable file '${KERNEL_VAR_FILE}' does not exist, run ./build_kernel.sh first"
@@ -26,14 +25,6 @@ if [ -d .git ]; then
2625
git reset --hard origin/main
2726
fi
2827

29-
DRIVER_VERSION=$(git describe | sed s/^v//)
30-
31-
# Build up Debian related variables required for packaging
32-
DEBIAN_ARCH=$(dpkg --print-architecture)
33-
DEBIAN_DIR="${CWD}/vyos-intel-${DRIVER_NAME}_${DRIVER_VERSION}_${DEBIAN_ARCH}"
34-
DEBIAN_CONTROL="${DEBIAN_DIR}/DEBIAN/control"
35-
DEBIAN_POSTINST="${CWD}/vyos-intel-${DRIVER_NAME}.postinst"
36-
3728
# See https://vyos.dev/T6155
3829
# See https://vyos.dev/T6162
3930
PATCH_DIR=${CWD}/patches/${DRIVER_NAME}
@@ -45,37 +36,52 @@ if [ -d $PATCH_DIR ]; then
4536
done
4637
fi
4738

48-
echo "I: Compile Kernel module for Intel ${DRIVER_NAME} driver"
49-
make KSRC=${KERNEL_DIR} BUILD_KERNEL=${KERNEL_VERSION}${KERNEL_SUFFIX} INSTALL_MOD_PATH=${DEBIAN_DIR} INSTALL_FW_PATH=${DEBIAN_DIR} -j $(getconf _NPROCESSORS_ONLN) -C src install
39+
PACKAGE_NAME=vyos-intel-${DRIVER_NAME}
40+
PACKAGE_VERSION=$(debian_version "$(git describe | sed s/^v//)")
5041

51-
if [ "x$?" != "x0" ]; then
52-
exit 1
53-
fi
42+
debmake -n -y -p ${PACKAGE_NAME} -u ${PACKAGE_VERSION} \
43+
-e maintainers@vyos.net -f "VyOS Package Maintainers"
5444

55-
if [ -f ${DEBIAN_DIR}.deb ]; then
56-
rm ${DEBIAN_DIR}.deb
57-
fi
45+
echo "misc:Depends=linux-image-${KERNEL_VERSION}${KERNEL_SUFFIX}" > debian/${PACKAGE_NAME}.substvars
46+
47+
cat << EOF > debian/control
48+
Source: ${PACKAGE_NAME}
49+
Section: kernel
50+
Priority: optional
51+
Maintainer: VyOS Package Maintainers <maintainers@vyos.net>
52+
Build-Depends: debhelper-compat (= 13)
53+
Standards-Version: 4.5.1
54+
Rules-Requires-Root: no
55+
56+
Package: ${PACKAGE_NAME}
57+
Architecture: any
58+
Depends: \${misc:Depends}
59+
Description: Vendor based driver for Intel ${DRIVER_NAME}
60+
Out-of-tree Intel ${DRIVER_NAME} network driver kernel module.
61+
EOF
62+
63+
cat << EOF > debian/rules
64+
#!/usr/bin/make -f
65+
export KERNEL_DIR := ${KERNEL_DIR}
66+
PACKAGE_BUILD_DIR := debian/${PACKAGE_NAME}
67+
KVER := ${KERNEL_VERSION}${KERNEL_SUFFIX}
5868
59-
# build Debian package
60-
echo "I: Building Debian package vyos-intel-${DRIVER_NAME}"
61-
cd ${CWD}
69+
%:
70+
dh \$@
6271
63-
# Sign generated Kernel modules
64-
${CWD}/sign-modules.sh ${DEBIAN_DIR}
72+
override_dh_clean:
73+
dh_clean --exclude=debian/${PACKAGE_NAME}.substvars
6574
66-
# delete non required files which are also present in the kernel package
67-
# und thus lead to duplicated files
68-
find ${DEBIAN_DIR} -name "modules.*" | xargs rm -f
75+
override_dh_prep:
76+
dh_prep --exclude=debian/${PACKAGE_NAME}.substvars
6977
70-
echo "#!/bin/sh" > ${DEBIAN_POSTINST}
71-
echo "/sbin/depmod -a ${KERNEL_VERSION}${KERNEL_SUFFIX}" >> ${DEBIAN_POSTINST}
78+
override_dh_auto_build:
79+
@true
7280
73-
fpm --input-type dir --output-type deb --name vyos-intel-${DRIVER_NAME} \
74-
--version ${DRIVER_VERSION} --deb-compression gz \
75-
--maintainer "VyOS Package Maintainers <maintainers@vyos.net>" \
76-
--description "Vendor based driver for Intel ${DRIVER_NAME}" \
77-
--depends linux-image-${KERNEL_VERSION}${KERNEL_SUFFIX} \
78-
--license "GPL2" -C ${DEBIAN_DIR} --after-install ${DEBIAN_POSTINST}
81+
override_dh_auto_install:
82+
make KSRC=\${KERNEL_DIR} BUILD_KERNEL=\${KVER} INSTALL_MOD_PATH=\$(CURDIR)/\${PACKAGE_BUILD_DIR} INSTALL_FW_PATH=\$(CURDIR)/\${PACKAGE_BUILD_DIR} -j \$(shell getconf _NPROCESSORS_ONLN) -C src install
83+
find \${PACKAGE_BUILD_DIR} -name "modules.*" -delete
84+
\${KERNEL_DIR}/../sign-modules.sh \${PACKAGE_BUILD_DIR}/lib
85+
EOF
7986

80-
# cleanup
81-
rm -rf -- "${DEBIAN_DIR}" "${DEBIAN_POSTINST}"
87+
debuild

scripts/package-build/linux-kernel/build-intel-qat.sh

Lines changed: 67 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/sh
2+
set -e
23
CWD=$(pwd)
34
KERNEL_VAR_FILE=${CWD}/kernel-vars
5+
. ${CWD}/common.sh
46

5-
if ! dpkg-architecture -iamd64; then
6-
echo "Intel-QAT is only buildable on amd64 platforms"
7-
exit 0
8-
fi
7+
require_amd64 "Intel-QAT"
98

109
if [ ! -f ${KERNEL_VAR_FILE} ]; then
1110
echo "Kernel variable file '${KERNEL_VAR_FILE}' does not exist, run ./build_kernel.sh first"
@@ -25,12 +24,6 @@ DRIVER_NAME_EXTRA="L."
2524
DRIVER_VERSION=$(echo ${DRIVER_DIR} | awk -F${DRIVER_NAME} '{print $2}' | awk -F${DRIVER_NAME_EXTRA} '{print $2}')
2625
DRIVER_VERSION_EXTRA="-0"
2726

28-
# Build up Debian related variables required for packaging
29-
DEBIAN_ARCH=$(dpkg --print-architecture)
30-
DEBIAN_DIR="${CWD}/vyos-intel-${DRIVER_NAME}_${DRIVER_VERSION}${DRIVER_VERSION_EXTRA}_${DEBIAN_ARCH}"
31-
DEBIAN_CONTROL="${DEBIAN_DIR}/DEBIAN/control"
32-
DEBIAN_POSTINST="${CWD}/vyos-intel-qat.postinst"
33-
3427
# Fetch Intel driver source from SourceForge
3528
if [ -e ${DRIVER_FILE} ]; then
3629
rm -f ${DRIVER_FILE}
@@ -62,53 +55,70 @@ if [ -d "${CWD}/patches/intel-qat" ]; then
6255
done
6356
fi
6457

65-
echo "I: Compile Kernel module for Intel ${DRIVER_NAME} driver"
66-
mkdir -p \
67-
${DEBIAN_DIR}/lib/firmware \
68-
${DEBIAN_DIR}/usr/sbin \
69-
${DEBIAN_DIR}/usr/lib/x86_64-linux-gnu \
70-
${DEBIAN_DIR}/etc/init.d
71-
KERNEL_SOURCE_ROOT=${KERNEL_DIR} ./configure --enable-kapi --enable-qat-lkcf
72-
make -j $(getconf _NPROCESSORS_ONLN) all
73-
make INSTALL_MOD_PATH=${DEBIAN_DIR} INSTALL_FW_PATH=${DEBIAN_DIR} \
74-
qat-driver-install adf-ctl-all
75-
76-
if [ "x$?" != "x0" ]; then
77-
exit 1
78-
fi
79-
80-
cp quickassist/qat/fw/*.bin ${DEBIAN_DIR}/lib/firmware
81-
cp build/*.so ${DEBIAN_DIR}/usr/lib/x86_64-linux-gnu
82-
cp build/adf_ctl ${DEBIAN_DIR}/usr/sbin
83-
cp quickassist/build_system/build_files/qat_service ${DEBIAN_DIR}/etc/init.d
84-
cp build/usdm_drv.ko ${DEBIAN_DIR}/lib/modules/${KERNEL_VERSION}${KERNEL_SUFFIX}/updates/drivers
85-
chmod 644 ${DEBIAN_DIR}/lib/firmware/*
86-
chmod 755 ${DEBIAN_DIR}/etc/init.d/* ${DEBIAN_DIR}/usr/local/bin/*
87-
88-
if [ -f ${DEBIAN_DIR}.deb ]; then
89-
rm ${DEBIAN_DIR}.deb
90-
fi
91-
92-
# build Debian package
93-
echo "I: Building Debian package vyos-intel-${DRIVER_NAME}"
94-
cd ${CWD}
95-
96-
# Sign generated Kernel modules
97-
${CWD}/sign-modules.sh ${DEBIAN_DIR}
98-
99-
# delete non required files which are also present in the kernel package
100-
# und thus lead to duplicated files
101-
find ${DEBIAN_DIR} -name "modules.*" | xargs rm -f
102-
103-
echo "#!/bin/sh" > ${DEBIAN_POSTINST}
104-
echo "/sbin/depmod -a ${KERNEL_VERSION}${KERNEL_SUFFIX}" >> ${DEBIAN_POSTINST}
105-
106-
fpm --input-type dir --output-type deb --name vyos-intel-${DRIVER_NAME} \
107-
--version ${DRIVER_VERSION}${DRIVER_VERSION_EXTRA} --deb-compression gz \
108-
--maintainer "VyOS Package Maintainers <maintainers@vyos.net>" \
109-
--description "Vendor based driver for Intel ${DRIVER_NAME}" \
110-
--depends linux-image-${KERNEL_VERSION}${KERNEL_SUFFIX} \
111-
--license "GPL2" -C ${DEBIAN_DIR} --after-install ${DEBIAN_POSTINST}
58+
PACKAGE_NAME=vyos-intel-$(echo ${DRIVER_NAME} | tr 'A-Z' 'a-z')
59+
PACKAGE_VERSION=$(debian_version "${DRIVER_VERSION}${DRIVER_VERSION_EXTRA}")
60+
61+
debmake -n -y -p ${PACKAGE_NAME} -u ${PACKAGE_VERSION} \
62+
-e maintainers@vyos.net -f "VyOS Package Maintainers"
63+
64+
echo "misc:Depends=linux-image-${KERNEL_VERSION}${KERNEL_SUFFIX}" > debian/${PACKAGE_NAME}.substvars
65+
66+
cat << EOF > debian/control
67+
Source: ${PACKAGE_NAME}
68+
Section: kernel
69+
Priority: optional
70+
Maintainer: VyOS Package Maintainers <maintainers@vyos.net>
71+
Build-Depends: debhelper-compat (= 13)
72+
Standards-Version: 4.5.1
73+
Rules-Requires-Root: no
74+
75+
Package: ${PACKAGE_NAME}
76+
Architecture: any
77+
Depends: \${misc:Depends}
78+
Description: Vendor based driver for Intel ${DRIVER_NAME}
79+
Intel QuickAssist Technology (QAT) kernel driver and userspace tools.
80+
EOF
81+
82+
cat << EOF > debian/rules
83+
#!/usr/bin/make -f
84+
export KERNEL_DIR := ${KERNEL_DIR}
85+
PACKAGE_BUILD_DIR := debian/${PACKAGE_NAME}
86+
KVER := ${KERNEL_VERSION}${KERNEL_SUFFIX}
87+
88+
%:
89+
dh \$@
90+
91+
override_dh_clean:
92+
dh_clean --exclude=debian/${PACKAGE_NAME}.substvars
93+
94+
override_dh_prep:
95+
dh_prep --exclude=debian/${PACKAGE_NAME}.substvars
96+
97+
override_dh_auto_clean:
98+
@true
99+
100+
override_dh_auto_configure:
101+
@true
102+
103+
override_dh_auto_build:
104+
KERNEL_SOURCE_ROOT=\${KERNEL_DIR} ./configure --enable-kapi --enable-qat-lkcf
105+
\$(MAKE) -j \$(shell getconf _NPROCESSORS_ONLN) all
106+
107+
override_dh_auto_install:
108+
mkdir -p \${PACKAGE_BUILD_DIR}/lib/firmware \${PACKAGE_BUILD_DIR}/usr/sbin \${PACKAGE_BUILD_DIR}/usr/lib/x86_64-linux-gnu \${PACKAGE_BUILD_DIR}/etc/init.d
109+
\$(MAKE) INSTALL_MOD_PATH=\$(CURDIR)/\${PACKAGE_BUILD_DIR} INSTALL_FW_PATH=\$(CURDIR)/\${PACKAGE_BUILD_DIR} qat-driver-install adf-ctl-all
110+
cp quickassist/qat/fw/*.bin \${PACKAGE_BUILD_DIR}/lib/firmware
111+
cp build/*.so \${PACKAGE_BUILD_DIR}/usr/lib/x86_64-linux-gnu
112+
cp build/adf_ctl \${PACKAGE_BUILD_DIR}/usr/sbin
113+
cp quickassist/build_system/build_files/qat_service \${PACKAGE_BUILD_DIR}/etc/init.d
114+
cp build/usdm_drv.ko \${PACKAGE_BUILD_DIR}/lib/modules/\${KVER}/updates/drivers
115+
chmod 644 \${PACKAGE_BUILD_DIR}/lib/firmware/*
116+
chmod 755 \${PACKAGE_BUILD_DIR}/etc/init.d/*
117+
find \${PACKAGE_BUILD_DIR} -name "modules.*" -delete
118+
\${KERNEL_DIR}/../sign-modules.sh \${PACKAGE_BUILD_DIR}/lib
119+
EOF
120+
121+
debuild
112122

113123
echo "I: Cleanup ${DRIVER_NAME} source"
114124
cd ${CWD}
@@ -118,9 +128,3 @@ fi
118128
if [ -d ${DRIVER_DIR} ]; then
119129
rm -rf ${DRIVER_DIR}
120130
fi
121-
if [ -d ${DEBIAN_DIR} ]; then
122-
rm -rf ${DEBIAN_DIR}
123-
fi
124-
if [ -f ${DEBIAN_POSTINST} ]; then
125-
rm -f ${DEBIAN_POSTINST}
126-
fi

0 commit comments

Comments
 (0)