11#! /bin/sh
2+ set -e
23CWD=$( pwd)
34KERNEL_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
109if [ ! -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."
2524DRIVER_VERSION=$( echo ${DRIVER_DIR} | awk -F${DRIVER_NAME} ' {print $2}' | awk -F${DRIVER_NAME_EXTRA} ' {print $2}' )
2625DRIVER_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
3528if [ -e ${DRIVER_FILE} ]; then
3629 rm -f ${DRIVER_FILE}
@@ -62,53 +55,70 @@ if [ -d "${CWD}/patches/intel-qat" ]; then
6255 done
6356fi
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
113123echo " I: Cleanup ${DRIVER_NAME} source"
114124cd ${CWD}
118128if [ -d ${DRIVER_DIR} ]; then
119129 rm -rf ${DRIVER_DIR}
120130fi
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