From 7d052c4a68df8aa5010e240db311674a32f837c2 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 13 Aug 2016 12:58:30 +0100 Subject: Add optional binary kernel modules package Add optional binary kernel modules package, disabled by default (build with DEB_BUILD_OPTIONS=kernel_modules to enable). If enabled will build kernel modules against the local, current kernel version (override by adding ksrc= to DEB_BUILD_OPTIONS) into a dpdk-modules- package. Useful for downstream projects that ship a complete ISO, where it is not desirable to include a whole building environment for DKMS packages. Change-Id: I7e0ab239eaf08da71f9d58d60e32abf7cd42bec4 Signed-off-by: Luca Boccassi --- debian/rules | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'debian/rules') diff --git a/debian/rules b/debian/rules index 77f90d8f..da7e3c86 100755 --- a/debian/rules +++ b/debian/rules @@ -39,11 +39,55 @@ endif DPDK_STATIC_DIR = "debian/build/static-root" DPDK_SHARED_DIR = "debian/build/shared-root" +# kernel_modules can be passed via DEB_BUILD_OPTIONS to enable building the +# optional binary kernel modules package. By default it will be built against +# the current kernel, or ksrc can be passed with a path to the target kernel +# sources instead. +ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS))) +DPDK_CONFIG_BUILD_KMOD=n +KSRC="" +else +ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS))) + KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS))) +else + KSRC := /lib/modules/$(shell uname -r)/build +endif + +KVERS := $(shell perl debian/kernel-version $(KSRC)) +export KVERS + +DPDK_CONFIG_BUILD_KMOD=y + +# Since the binary module package is generated at build time depending on the +# local kernel version, we have to append the new package in d/control. +# We cannot use a separate control file since that wouldn't work with +# dpkg-genchanges, and also would require a lot of overrides for debhelpers. +get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1)) + +override_dh_gencontrol: + dh_gencontrol + dh_gencontrol -p dpdk-modules-$(KVERS) -- \ + -v`cat debian/VERSION` \ + -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))' + +build: + @if [ x"$(KVERS)" = x ] ; then \ + echo 'No version in $(KSRC)/include/linux/version.h' >&2; \ + exit 1; \ + fi + sh debian/prep-modules $(KSRC) + test -f debian/control.orig || cp -v debian/control debian/control.orig + cat debian/control.orig debian/control.modules > debian/control + dh $@ --with python2,dkms +endif + %: dh $@ --with python2,dkms override_dh_auto_clean: - rm -rf debian/build debian/tmp + rm -rf debian/build debian/tmp debian/dpdk-modules-* \ + debian/control.modules debian/VERSION + mv debian/control.orig debian/control || true override_dh_auto_configure: # report dpkg-buildflags status to build log @@ -53,8 +97,8 @@ override_dh_auto_configure: $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) T=$(DPDK_CONFIG) config sed -ri -e 's,(RTE_MACHINE=).*,\1$(RTE_MACHINE),' \ -e 's,(RTE_NEXT_ABI=).*,\1n,' \ - -e 's,(CONFIG_RTE_EAL_IGB_UIO=).*,\1n,' \ - -e 's,(CONFIG_RTE_KNI_KMOD=).*,\1n,' \ + -e 's,(CONFIG_RTE_EAL_IGB_UIO=).*,\1$(DPDK_CONFIG_BUILD_KMOD),' \ + -e 's,(CONFIG_RTE_KNI_KMOD=).*,\1$(DPDK_CONFIG_BUILD_KMOD),' \ -e 's,(LIBRTE_PMD_PCAP=).*,\1y,' \ -e 's,(LIBRTE_PMD_XENVIRT=).*,\1y,' \ $(DPDK_STATIC_DIR)/.config @@ -83,7 +127,7 @@ override_dh_auto_build-arch: cp -a $(DPDK_STATIC_DIR) $(DPDK_SHARED_DIR) sed -ri 's,(RTE_BUILD_SHARED_LIB=).*,\1y,' \ $(DPDK_SHARED_DIR)/.config - $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) build + $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) RTE_KERNELDIR=$(KSRC) build override_dh_auto_install-arch: LIBDIR=usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH) override_dh_auto_install-arch: @@ -146,6 +190,12 @@ override_dh_auto_install-arch: mkdir -p debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION) cp -a lib/librte_eal/linuxapp/kni/* \ debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION) +ifneq (,$(KVERS)) + # Package: dpdk-modules- + mkdir -p debian/dpdk-modules-$(KVERS)/lib/modules/$(KVERS)/kernel/drivers/net + cp -a debian/build/shared-root/kmod/* \ + debian/dpdk-modules-$(KVERS)/lib/modules/$(KVERS)/kernel/drivers/net +endif override_dh_dkms: dh_dkms -V $(VERSION) -- cgit 1.2.3-korg