From 3060aaf95f261856352c9c3a6c6e244212a7a08b Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 2 Nov 2020 18:51:55 +0100 Subject: [PATCH] Introduce DKMS support for DEB packages Signed-off-by: Robert Baldyga --- modules/Makefile | 7 ++++--- modules/extra.mk | 2 +- utils/pckgen | 2 +- utils/pckgen.d/deb/debian/CAS_NAME-modules.dkms | 11 +++++++++++ .../pckgen.d/deb/debian/CAS_NAME-modules.install | 10 +++++++++- utils/pckgen.d/deb/debian/changelog | 6 ++++++ utils/pckgen.d/deb/debian/control | 4 ++-- utils/pckgen.d/deb/debian/rules | 16 +++++++++++++--- 8 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 utils/pckgen.d/deb/debian/CAS_NAME-modules.dkms diff --git a/modules/Makefile b/modules/Makefile index 2387708..c5923f2 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -2,9 +2,9 @@ # Copyright(c) 2012-2020 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause-Clear # -# If KERNELRELEASE is defined, we've been invoked from the +# If $(M) is defined, we've been invoked from the # kernel build system and can use its language. -ifneq ($(KERNELRELEASE),) +ifneq ($(M),) include $(M)/config.mk @@ -16,8 +16,9 @@ obj-y += cas_disk/ else OCFDIR=$(PWD)/../ocf -KERNEL_DIR ?= "/lib/modules/$(shell uname -r)/build" PWD=$(shell pwd) +KERNEL_VERSION ?= "$(shell uname -r)" +KERNEL_DIR ?= "/lib/modules/$(KERNEL_VERSION)/build" MODULES_DIR=/lib/modules/$(shell uname -r)/extra DISK_MODULE = cas_disk diff --git a/modules/extra.mk b/modules/extra.mk index a74eb20..a1c4bc4 100644 --- a/modules/extra.mk +++ b/modules/extra.mk @@ -2,7 +2,7 @@ # Copyright(c) 2012-2020 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause-Clear # -ifneq ($(KERNELRELEASE),) +ifneq ($(M),) ifeq ($(CAS_EXT_EXP),1) EXTRA_CFLAGS += -DWI_AVAILABLE diff --git a/utils/pckgen b/utils/pckgen index 909a79d..e749eed 100755 --- a/utils/pckgen +++ b/utils/pckgen @@ -32,7 +32,7 @@ DEPENDENCIES_TAR=(tar) DEPENDENCIES_ZIP=(zip) DEPENDENCIES_RPM=(rpmbuild tar) DEPENDENCIES_SRPM=("${DEPENDENCIES_RPM[@]}") -DEPENDENCIES_DEB=(debuild dh fakeroot tar) +DEPENDENCIES_DEB=(debuild dh fakeroot tar dkms) DEPENDENCIES_DSC=("${DEPENDENCIES_DEB[@]}") # List of relative submodule directories: SUBMODULES=( diff --git a/utils/pckgen.d/deb/debian/CAS_NAME-modules.dkms b/utils/pckgen.d/deb/debian/CAS_NAME-modules.dkms new file mode 100644 index 0000000..f588239 --- /dev/null +++ b/utils/pckgen.d/deb/debian/CAS_NAME-modules.dkms @@ -0,0 +1,11 @@ +PACKAGE_NAME="-modules" +PACKAGE_VERSION="#MODULE_VERSION#" +BUILT_MODULE_NAME[0]="cas_disk" +BUILT_MODULE_NAME[1]="cas_cache" +BUILT_MODULE_LOCATION[0]="modules/cas_disk/" +BUILT_MODULE_LOCATION[1]="modules/cas_cache/" +DEST_MODULE_LOCATION[0]="/extra" +DEST_MODULE_LOCATION[1]="/extra" +PRE_BUILD="./configure" +MAKE[0]="make -j -C modules/ KERNEL_VERSION=$kernelver" +AUTOINSTALL=yes diff --git a/utils/pckgen.d/deb/debian/CAS_NAME-modules.install b/utils/pckgen.d/deb/debian/CAS_NAME-modules.install index f24e80a..960af1c 100644 --- a/utils/pckgen.d/deb/debian/CAS_NAME-modules.install +++ b/utils/pckgen.d/deb/debian/CAS_NAME-modules.install @@ -1 +1,9 @@ -lib/modules/ +./.metadata/* usr/src/-modules-/.metadata/ +./modules/* usr/src/-modules-/modules/ +./ocf/* usr/src/-modules-/ocf/ +./utils/* usr/src/-modules-/utils/ +./configure.d/* usr/src/-modules-/configure.d/ +./configure usr/src/-modules-/ +./Makefile usr/src/-modules-/ +./LICENSE usr/src/-modules-/ +./version usr/src/-modules-/ diff --git a/utils/pckgen.d/deb/debian/changelog b/utils/pckgen.d/deb/debian/changelog index 06ab4b8..54299fe 100644 --- a/utils/pckgen.d/deb/debian/changelog +++ b/utils/pckgen.d/deb/debian/changelog @@ -4,6 +4,12 @@ -- +open-cas-linux (20.03.3.0303-1) trusty; urgency=medium + + * Add DKMS support + + -- Robert Baldyga Mon, 02 Nov 2020 18:47:04 +0200 + open-cas-linux (20.03.2.0295-1) trusty; urgency=medium * Initial OpenCAS DEB package release diff --git a/utils/pckgen.d/deb/debian/control b/utils/pckgen.d/deb/debian/control index 4500338..db2158e 100644 --- a/utils/pckgen.d/deb/debian/control +++ b/utils/pckgen.d/deb/debian/control @@ -2,7 +2,7 @@ Source: Section: utils Priority: optional Maintainer: -Build-Depends: debhelper (>= 11), gawk, libelf-dev, linux-headers-generic +Build-Depends: debhelper (>= 11), gawk, libelf-dev, linux-headers-generic, dkms Standards-Version: 4.1.2 Homepage: Vcs-Git: @@ -21,7 +21,7 @@ Description: Open Cache Acceleration Software Package: -modules Architecture: amd64 -Depends: ${misc:Depends} +Depends: ${misc:Depends}, debhelper (>= 9), dkms Description: Open Cache Acceleration Software kernel modules (${kver}) Open Cache Acceleration Software (Open CAS) is an open source project encompassing block caching software libraries, adapters, tools and more. diff --git a/utils/pckgen.d/deb/debian/rules b/utils/pckgen.d/deb/debian/rules index 6d64753..a8e9f2c 100755 --- a/utils/pckgen.d/deb/debian/rules +++ b/utils/pckgen.d/deb/debian/rules @@ -4,13 +4,23 @@ #export DH_VERBOSE = 1 %: - dh $@ + dh $@ --with dkms override_dh_auto_configure : - ./configure + +override_dh_auto_build : + (cd utils/; ./cas_version_gen build) + make -C casadm override_dh_auto_install : - make install_files DESTDIR="$(shell pwd)/debian/tmp" + make -C casadm install_files DESTDIR="$(shell pwd)/debian/tmp" + make -C utils install_files DESTDIR="$(shell pwd)/debian/tmp" + # clean and generate version again before installing sources for DKMS + make distclean + (cd utils/; ./cas_version_gen) + +override_dh_dkms : + dh_dkms -V $(DEB_VERSION_UPSTREAM) override_dh_installsystemd : dh_installsystemd --no-start