diff options
author | Prakash Surya <[email protected]> | 2012-08-07 13:13:17 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-08-08 15:21:01 -0700 |
commit | 26e08952e6ad113b91ae7d31263b6a4fd3a5a09f (patch) | |
tree | 07291ab4100e10df8d922a871a10e9f3e4f6743d | |
parent | 5085d55817f67e2333366e517c6cc7a6fdda50f7 (diff) |
Support building a zfs-modules-dkms sub package
This commit adds support for building a zfs-modules-dkms sub package
built around Dynamic Kernel Module Support. This is to allow building
packages using the DKMS infrastructure which is intended to ease the
burden of kernel version changes, upgrades, etc.
By default zfs-modules-dkms-* sub package will be built as part of
the 'make rpm' target. Alternately, you can build only the DKMS
module package using the 'make rpm-dkms' target.
Examples:
# To build packaged binaries as well as a dkms packages
$ ./configure && make rpm
# To build only the packaged binary utilities and dkms packages
$ ./configure && make rpm-utils rpm-dkms
Note: Only the RHEL 5/6, CHAOS 5, and Fedora distributions are
supported for building the dkms sub package.
Signed-off-by: Prakash Surya <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #535
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | Makefile.in | 34 | ||||
-rw-r--r-- | config/kernel.m4 | 18 | ||||
-rw-r--r-- | config/rpm.am | 27 | ||||
-rwxr-xr-x | configure | 31 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | dkms.conf.in | 36 | ||||
-rwxr-xr-x | dkms.postinst | 24 | ||||
-rw-r--r-- | zfs-modules.spec.in | 108 |
9 files changed, 266 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am index 1a9171de5..89e094ebe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,6 +16,7 @@ EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am EXTRA_DIST += META DISCLAIMER COPYRIGHT README.markdown EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE +EXTRA_DIST += dkms.postinst noinst_HEADERS = zfs_config.h zfs.release distclean-local:: diff --git a/Makefile.in b/Makefile.in index a8b6a09f0..19992b01b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,7 +44,7 @@ target_triplet = @target@ DIST_COMMON = $(am__configure_deps) $(noinst_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/PKGBUILD-zfs-modules.in $(srcdir)/PKGBUILD-zfs.in \ - $(srcdir)/zfs-modules.spec.in \ + $(srcdir)/dkms.conf.in $(srcdir)/zfs-modules.spec.in \ $(srcdir)/zfs-script-config.sh.in $(srcdir)/zfs.release.in \ $(srcdir)/zfs.spec.in $(srcdir)/zfs_config.h.in \ $(top_srcdir)/config/arch.am $(top_srcdir)/config/deb.am \ @@ -135,7 +135,8 @@ CONFIG_CLEAN_FILES = module/Makefile module/avl/Makefile \ module/nvpair/Makefile module/unicode/Makefile \ module/zcommon/Makefile module/zfs/Makefile \ module/zpios/Makefile zfs.spec zfs-modules.spec PKGBUILD-zfs \ - PKGBUILD-zfs-modules zfs-script-config.sh zfs.release + PKGBUILD-zfs-modules zfs-script-config.sh zfs.release \ + dkms.conf CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) @@ -382,7 +383,7 @@ AUTOMAKE_OPTIONS = foreign EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in \ config/config.awk config/rpm.am config/deb.am config/tgz.am \ META DISCLAIMER COPYRIGHT README.markdown OPENSOLARIS.LICENSE \ - ZFS.RELEASE + ZFS.RELEASE dkms.postinst noinst_HEADERS = zfs_config.h zfs.release all: zfs_config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -465,6 +466,8 @@ zfs-script-config.sh: $(top_builddir)/config.status $(srcdir)/zfs-script-config. cd $(top_builddir) && $(SHELL) ./config.status $@ zfs.release: $(top_builddir)/config.status $(srcdir)/zfs.release.in cd $(top_builddir) && $(SHELL) ./config.status $@ +dkms.conf: $(top_builddir)/config.status $(srcdir)/dkms.conf.in + cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo @@ -912,13 +915,16 @@ srpm-utils: srpm: srpm-modules srpm-utils +rpm-dkms: srpm-modules +@CONFIG_KERNEL_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" dkms-common + rpm-modules: srpm-modules @CONFIG_KERNEL_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common rpm-utils: srpm-utils @CONFIG_USER_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common -rpm: rpm-modules rpm-utils +rpm: rpm-modules rpm-utils rpm-dkms rpm-local: @(if test "${HAVE_RPMBUILD}" = "no"; then \ @@ -937,6 +943,26 @@ rpm-local: mkdir -p $(rpmbuild)/SOURCES && \ cp $(distdir).tar.gz $(rpmbuild)/SOURCES) +dkms-common: + rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ + rpmspec=$(pkg).spec; \ + rpmdkms=$(pkg)-dkms-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).noarch.rpm;\ + rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ + $(MAKE) $(AM_MAKEFLAGS) \ + rpmbuild="$$rpmbuild" \ + rpmspec="$$rpmspec" \ + rpm-local || exit 1; \ + $(RPMBUILD) \ + --define "_tmppath $$rpmbuild/TMP" \ + --define "_topdir $$rpmbuild" \ + --define "dist %{nil}" \ + --define "_without_kernel 1" \ + --define "_without_kernel_debug 1" \ + --define "_with_kernel_dkms 1" \ + --nodeps --rebuild $$rpmpkg || exit 1; \ + cp $$rpmbuild/RPMS/noarch/$$rpmdkms . || exit 1; \ + $(RM) -R $$rpmbuild + srpm-common: dist rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ rpmspec=$(pkg).spec; \ diff --git a/config/kernel.m4 b/config/kernel.m4 index 7d8a5f4d5..c08b6a22c 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -281,14 +281,28 @@ AC_DEFUN([ZFS_AC_SPL], [ AC_MSG_CHECKING([spl source directory]) AS_IF([test -z "$splsrc"], [ + dnl # + dnl # Look in the standard development package location + dnl # sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ 2>/dev/null | tail -1` - AS_IF([test -z "$sourcelink" || test ! -e $sourcelink], [ + dnl # + dnl # Look in the DKMS source location + dnl # + AS_IF([test -z "$sourcelink" || test ! -e $sourcelink/spl_config.h], [ + sourcelink=`ls -1d /var/lib/dkms/spl/*/build \ + 2>/dev/null | tail -1` + ]) + + dnl # + dnl # Look in the parent directory + dnl # + AS_IF([test -z "$sourcelink" || test ! -e $sourcelink/spl_config.h], [ sourcelink=../spl ]) - AS_IF([test -e $sourcelink], [ + AS_IF([test -e $sourcelink/spl_config.h], [ splsrc=`readlink -f ${sourcelink}` ], [ AC_MSG_RESULT([Not found]) diff --git a/config/rpm.am b/config/rpm.am index c5929833b..9deafb3de 100644 --- a/config/rpm.am +++ b/config/rpm.am @@ -10,6 +10,11 @@ endif srpm: srpm-modules srpm-utils +rpm-dkms: srpm-modules +if CONFIG_KERNEL + $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" dkms-common +endif + rpm-modules: srpm-modules if CONFIG_KERNEL $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common @@ -20,7 +25,7 @@ if CONFIG_USER $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common endif -rpm: rpm-modules rpm-utils +rpm: rpm-modules rpm-utils rpm-dkms rpm-local: @(if test "${HAVE_RPMBUILD}" = "no"; then \ @@ -39,6 +44,26 @@ rpm-local: mkdir -p $(rpmbuild)/SOURCES && \ cp $(distdir).tar.gz $(rpmbuild)/SOURCES) +dkms-common: + rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ + rpmspec=$(pkg).spec; \ + rpmdkms=$(pkg)-dkms-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).noarch.rpm;\ + rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ + $(MAKE) $(AM_MAKEFLAGS) \ + rpmbuild="$$rpmbuild" \ + rpmspec="$$rpmspec" \ + rpm-local || exit 1; \ + $(RPMBUILD) \ + --define "_tmppath $$rpmbuild/TMP" \ + --define "_topdir $$rpmbuild" \ + --define "dist %{nil}" \ + --define "_without_kernel 1" \ + --define "_without_kernel_debug 1" \ + --define "_with_kernel_dkms 1" \ + --nodeps --rebuild $$rpmpkg || exit 1; \ + cp $$rpmbuild/RPMS/noarch/$$rpmdkms . || exit 1; \ + $(RM) -R $$rpmbuild + srpm-common: dist rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ rpmspec=$(pkg).spec; \ @@ -12288,17 +12288,25 @@ fi $as_echo_n "checking spl source directory... " >&6; } if test -z "$splsrc"; then - sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ + sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ 2>/dev/null | tail -1` - if test -z "$sourcelink" || test ! -e $sourcelink; then + if test -z "$sourcelink" || test ! -e $sourcelink/spl_config.h; then + + sourcelink=`ls -1d /var/lib/dkms/spl/*/build \ + 2>/dev/null | tail -1` + +fi + + + if test -z "$sourcelink" || test ! -e $sourcelink/spl_config.h; then sourcelink=../spl fi - if test -e $sourcelink; then + if test -e $sourcelink/spl_config.h; then splsrc=`readlink -f ${sourcelink}` @@ -19889,17 +19897,25 @@ fi $as_echo_n "checking spl source directory... " >&6; } if test -z "$splsrc"; then - sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ + sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ 2>/dev/null | tail -1` - if test -z "$sourcelink" || test ! -e $sourcelink; then + if test -z "$sourcelink" || test ! -e $sourcelink/spl_config.h; then + + sourcelink=`ls -1d /var/lib/dkms/spl/*/build \ + 2>/dev/null | tail -1` + +fi + + + if test -z "$sourcelink" || test ! -e $sourcelink/spl_config.h; then sourcelink=../spl fi - if test -e $sourcelink; then + if test -e $sourcelink/spl_config.h; then splsrc=`readlink -f ${sourcelink}` @@ -27352,7 +27368,7 @@ $as_echo_n "checking whether dmu tx validation is enabled... " >&6; } $as_echo "$enable_debug_dmu_tx" >&6; } -ac_config_files="$ac_config_files Makefile dracut/Makefile dracut/90zfs/Makefile udev/Makefile udev/rules.d/Makefile etc/Makefile etc/init.d/Makefile etc/zfs/Makefile man/Makefile man/man5/Makefile man/man8/Makefile lib/Makefile lib/libspl/Makefile lib/libspl/asm-generic/Makefile lib/libspl/asm-i386/Makefile lib/libspl/asm-x86_64/Makefile lib/libspl/include/Makefile lib/libspl/include/ia32/Makefile lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile lib/libefi/Makefile lib/libnvpair/Makefile lib/libunicode/Makefile lib/libuutil/Makefile lib/libzpool/Makefile lib/libzfs/Makefile lib/libshare/Makefile cmd/Makefile cmd/zdb/Makefile cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile cmd/ztest/Makefile cmd/zpios/Makefile cmd/mount_zfs/Makefile cmd/zpool_layout/Makefile cmd/zvol_id/Makefile cmd/zpool_id/Makefile cmd/vdev_id/Makefile module/Makefile module/avl/Makefile module/nvpair/Makefile module/unicode/Makefile module/zcommon/Makefile module/zfs/Makefile module/zpios/Makefile include/Makefile include/linux/Makefile include/sys/Makefile include/sys/fs/Makefile include/sys/fm/Makefile include/sys/fm/fs/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile scripts/zpool-config/Makefile scripts/zpool-layout/Makefile scripts/common.sh zfs.spec zfs-modules.spec PKGBUILD-zfs PKGBUILD-zfs-modules zfs-script-config.sh zfs.release" +ac_config_files="$ac_config_files Makefile dracut/Makefile dracut/90zfs/Makefile udev/Makefile udev/rules.d/Makefile etc/Makefile etc/init.d/Makefile etc/zfs/Makefile man/Makefile man/man5/Makefile man/man8/Makefile lib/Makefile lib/libspl/Makefile lib/libspl/asm-generic/Makefile lib/libspl/asm-i386/Makefile lib/libspl/asm-x86_64/Makefile lib/libspl/include/Makefile lib/libspl/include/ia32/Makefile lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile lib/libefi/Makefile lib/libnvpair/Makefile lib/libunicode/Makefile lib/libuutil/Makefile lib/libzpool/Makefile lib/libzfs/Makefile lib/libshare/Makefile cmd/Makefile cmd/zdb/Makefile cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile cmd/ztest/Makefile cmd/zpios/Makefile cmd/mount_zfs/Makefile cmd/zpool_layout/Makefile cmd/zvol_id/Makefile cmd/zpool_id/Makefile cmd/vdev_id/Makefile module/Makefile module/avl/Makefile module/nvpair/Makefile module/unicode/Makefile module/zcommon/Makefile module/zfs/Makefile module/zpios/Makefile include/Makefile include/linux/Makefile include/sys/Makefile include/sys/fs/Makefile include/sys/fm/Makefile include/sys/fm/fs/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile scripts/zpool-config/Makefile scripts/zpool-layout/Makefile scripts/common.sh zfs.spec zfs-modules.spec PKGBUILD-zfs PKGBUILD-zfs-modules zfs-script-config.sh zfs.release dkms.conf" cat >confcache <<\_ACEOF @@ -28337,6 +28353,7 @@ do "PKGBUILD-zfs-modules") CONFIG_FILES="$CONFIG_FILES PKGBUILD-zfs-modules" ;; "zfs-script-config.sh") CONFIG_FILES="$CONFIG_FILES zfs-script-config.sh" ;; "zfs.release") CONFIG_FILES="$CONFIG_FILES zfs.release" ;; + "dkms.conf") CONFIG_FILES="$CONFIG_FILES dkms.conf" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} diff --git a/configure.ac b/configure.ac index 749f37862..10c2cc0a4 100644 --- a/configure.ac +++ b/configure.ac @@ -124,6 +124,7 @@ AC_CONFIG_FILES([ PKGBUILD-zfs-modules zfs-script-config.sh zfs.release + dkms.conf ]) AC_OUTPUT diff --git a/dkms.conf.in b/dkms.conf.in new file mode 100644 index 000000000..66079dafa --- /dev/null +++ b/dkms.conf.in @@ -0,0 +1,36 @@ +AUTOINSTALL="yes" +PACKAGE_NAME="@PACKAGE@" +PACKAGE_VERSION="@VERSION@" +PRE_BUILD="configure + --prefix=/usr + --with-config=kernel + --with-linux=$(case `lsb_release -is` in + (Debian) echo ${kernel_source_dir/%build/source} ;; + (*) echo ${kernel_source_dir} ;; + esac) + --with-linux-obj=${kernel_source_dir} + --with-spl-timeout=180 +" +POST_INSTALL="dkms.postinst -a ${arch} -k ${kernelver} -t ${dkms_tree} + -n ${PACKAGE_NAME} -v ${PACKAGE_VERSION} +" +REMAKE_INITRD="no" +MAKE[0]="make" +BUILT_MODULE_NAME[0]="zavl" +BUILT_MODULE_LOCATION[0]="module/avl/" +DEST_MODULE_LOCATION[0]="/extra/avl/avl" +BUILT_MODULE_NAME[1]="znvpair" +BUILT_MODULE_LOCATION[1]="module/nvpair/" +DEST_MODULE_LOCATION[1]="/extra/nvpair/znvpair" +BUILT_MODULE_NAME[2]="zunicode" +BUILT_MODULE_LOCATION[2]="module/unicode/" +DEST_MODULE_LOCATION[2]="/extra/unicode/zunicode" +BUILT_MODULE_NAME[3]="zcommon" +BUILT_MODULE_LOCATION[3]="module/zcommon/" +DEST_MODULE_LOCATION[3]="/extra/zcommon/zcommon" +BUILT_MODULE_NAME[4]="zfs" +BUILT_MODULE_LOCATION[4]="module/zfs/" +DEST_MODULE_LOCATION[4]="/extra/zfs/zfs" +BUILT_MODULE_NAME[5]="zpios" +BUILT_MODULE_LOCATION[5]="module/zpios/" +DEST_MODULE_LOCATION[5]="/extra/zpios/zpios" diff --git a/dkms.postinst b/dkms.postinst new file mode 100755 index 000000000..3cbc7c7ce --- /dev/null +++ b/dkms.postinst @@ -0,0 +1,24 @@ +#!/bin/bash + +PROG=$0 + +while getopts "a:k:n:t:v:" opt; do + case $opt in + a) arch=$OPTARG ;; + k) kver=$OPTARG ;; + n) pkgname=$OPTARG ;; + t) tree=$OPTARG ;; + v) pkgver=$OPTARG ;; + esac +done + +if [ -z "${arch}" -o -z "${kver}" -o -z "${pkgname}" -o \ + -z "${tree}" -o -z "${pkgver}" ]; then + echo "Usage: $PROG -a <arch> -k <kver> -n <pkgname>" \ + "-t <tree> -v <pkgver>" + exit 1 +fi + +cp ${tree}/${pkgname}/${pkgver}/build/zfs_config.h \ + ${tree}/${pkgname}/${pkgver}/build/module/Module.symvers \ + ${tree}/${pkgname}/${pkgver}/${kver}/${arch}/ diff --git a/zfs-modules.spec.in b/zfs-modules.spec.in index 5aea11a50..057da20be 100644 --- a/zfs-modules.spec.in +++ b/zfs-modules.spec.in @@ -44,6 +44,17 @@ %endif %endif +# Set using 'rpmbuild ... --with kernel-dkms ...', defaults to disabled. +%if %{defined _with_kernel_dkms} + %define with_kernel_dkms 1 +%else + %if %{defined _without_kernel_dkms} + %define with_kernel_dkms 0 + %else + %define with_kernel_dkms 0 + %endif +%endif + # Set using 'rpmbuild ... --with debug ...', defaults to disabled. %if %{defined _with_debug} %define kdebug --enable-debug @@ -96,12 +107,15 @@ %define kpkg_kern kernel-%{kverextra} %define kpkg_dbug %{nil} + %define kpkg_dkms dkms %define kdevpkg_kern kernel-source %define kdevpkg_dbug %{nil} + %define kdevpkg_dkms dkms %define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/-%{kverextra}//g') %define kverpkg_dbug %{nil} + %define kverpkg_dkms 2.2.0.2 # The kernel and rpm versions do not strictly match under SLES11 # e.g. kernel version 2.6.27.19-5 != rpm version 2.6.27.19-5.1 @@ -143,10 +157,13 @@ %define kpkg_kern kernel %define kpkg_dbug kernel-debug + %define kpkg_dkms dkms %define kdevpkg_kern kernel-devel %define kdevpkg_dbug kernel-debug-devel + %define kdevpkg_dkms dkms + %define kverpkg_dkms 2.2.0.2 %if %{defined el6} || %{defined ch5} %define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/.%{_target_cpu}//g') %define kverpkg_dbug %(echo %{kver_dbug} | %{__sed} -e 's/.%{_target_cpu}//g' | %{__sed} -e 's/.debug//g') @@ -194,10 +211,13 @@ %define kpkg_kern kernel %define kpkg_dbug kernel-debug + %define kpkg_dkms dkms %define kdevpkg_kern kernel-devel %define kdevpkg_dbug kernel-debug-devel + %define kdevpkg_dkms dkms + %define kverpkg_dkms 2.2.0.2 %define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/.%{_target_cpu}//g') %define kverpkg_dbug %(echo %{kver_dbug} | %{__sed} -e 's/.%{_target_cpu}//g' | %{__sed} -e 's/.debug//g') @@ -231,6 +251,7 @@ %define kverpkg_kern %{kver_kern} %define kverpkg_dbug %{nil} + %define kverpkg_dkms %{nil} %if %{undefined kdir} %define kdir_kern /lib/modules/%{kver_kern}/build @@ -274,39 +295,50 @@ %if %{undefined splver} %define spllnk_kern %{_usrsrc}/spl-*/%{kver_kern} %define spllnk_dbug %{_usrsrc}/spl-*/%{kver_dbug} + %define spllnk_dkms %{_var}/lib/dkms/spl/*/build %define splver_kern %((echo X; %{__cat} %{spllnk_kern}/spl.release 2>/dev/null) | tail -1) %define splver_dbug %((echo X; %{__cat} %{spllnk_dbug}/spl.release 2>/dev/null) | tail -1) + %define splver_dkms %((echo X; %{__cat} %{spllnk_dkms}/spl.release + 2>/dev/null) | tail -1) %else %define splver_kern %{splver} %define splver_dbug %{splver} + %define splver_dksm %{splver} %endif %define splpkg_kern spl-modules %define splpkg_dbug spl-modules-debug +%define splpkg_dkms spl-modules-dkms %define spldevpkg_kern spl-modules-devel %define spldevpkg_dbug spl-modules-debug-devel +%define spldevpkg_dkms spl-modules-dkms %define splverpkg_kern %{splver_kern} %define splverpkg_dbug %{splver_dbug} +%define splverpkg_dkms %{splver_dkms} %if %{undefined spldir} %define spldir_kern %{_usrsrc}/spl-%{splver_kern}/%{kver_kern} %define spldir_dbug %{_usrsrc}/spl-%{splver_dbug}/%{kver_dbug} + %define spldir_dkms %{_usrsrc}/spl-%{splver_dkms} %else %define spldir_kern %{spldir} %define spldir_dbug %{spldir}.debug + %define spldir_dkms %{spldir} %endif %if %{undefined splobj} %define splobj_kern %{spldir_kern} %define splobj_dbug %{spldir_dbug} + %define splobj_dkms %{spldir_dkms} %else %define splobj_kern %{splobj} %define splobj_dbug %{splobj}.debug + %define splobj_dkms %{splobj} %endif @@ -322,6 +354,7 @@ %define rel_kern @ZFS_META_RELEASE@ %define rel_dbug @ZFS_META_RELEASE@ +%define rel_dkms @ZFS_META_RELEASE@ %if %{defined kpkg_kern} %define req_kern %{kpkg_kern} @@ -329,12 +362,17 @@ %if %{defined kpkg_dbug} %define req_dbug %{kpkg_dbug} %endif +%if %{defined kpkg_dkms} +%define req_dkms %{kpkg_dkms} +%endif %define splreq_kern %{splpkg_kern} %define splreq_dbug %{splpkg_dbug} +%define splreq_dkms %{splpkg_dkms} %define spldevreq_kern %{spldevpkg_kern} %define spldevreq_dbug %{spldevpkg_dbug} +%define spldevreq_dkms %{spldevpkg_dkms} %else @@ -342,6 +380,7 @@ %define relext_dbug %(echo %{kverpkg_dbug} | %{__sed} -e 's/-/_/g') %define rel_kern @ZFS_META_RELEASE@_%{relext_kern} %define rel_dbug @ZFS_META_RELEASE@_%{relext_dbug} +%define rel_dkms @ZFS_META_RELEASE@ %if %{defined kpkg_kern} %define req_kern %{kpkg_kern} %{koppkg} %{kverpkg_kern} @@ -349,12 +388,17 @@ %if %{defined kpkg_dbug} %define req_dbug %{kpkg_dbug} %{koppkg} %{kverpkg_dbug} %endif +%if %{defined kpkg_dkms} +%define req_dkms %{kpkg_dkms} >= %{kverpkg_dkms} +%endif %define splreq_kern %{splpkg_kern} = %{splverpkg_kern}_%{relext_kern} %define splreq_dbug %{splpkg_dbug} = %{splverpkg_dbug}_%{relext_dbug} +%define splreq_dkms %{splpkg_dkms} = %{splverpkg_dkms} %define spldevreq_kern %{spldevpkg_kern} = %{splverpkg_kern}_%{relext_kern} %define spldevreq_dbug %{spldevpkg_dbug} = %{splverpkg_dbug}_%{relext_dbug} +%define spldevreq_dkms %{spldevpkg_dkms} = %{splverpkg_dkms} %endif @@ -462,6 +506,34 @@ and Module.symvers symbols needed for building additional modules which use %{name}. %endif +%if %{?with_kernel_dkms} + +%package dkms +Summary: ZFS File System (DKMS) +Group: Utilities/System +Release: %{rel_dkms} +Provides: %{name} +BuildArch: noarch +%if %{defined req_dkms} +Requires: %{req_dkms} +%endif +%if %{defined kdevpkg_dkms} +BuildRequires: %{kdevpkg_dkms} +%endif +%if %{defined splreq_dkms} +Requires: %{splreq_dkms} +%endif +%if %{defined spldevpkg_dkms} +BuildRequires: %{spldevpkg_dkms} +%endif +Provides: lustre-backend-fs + +%description dkms +The %{name}-dkms package contains the necessary pieces to build and +install the ZFS kernel modules with Dynamic Kernel Modules Support +(DKMS). + +%endif %prep %setup -n @PACKAGE@-%{version} @@ -486,6 +558,15 @@ make make DESTDIR=$RPM_BUILD_ROOT install %endif +%if %{?with_kernel_dkms} + +%configure %{kdebug} %{kdebug_dmu_tx} +make dist +mkdir -p $RPM_BUILD_ROOT/%{_prefix}/src +tar -xf @PACKAGE@-%{version}.tar.gz -C $RPM_BUILD_ROOT/%{_prefix}/src +cp -af dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/@PACKAGE@-%{version} + +%endif %clean rm -rf $RPM_BUILD_ROOT @@ -540,3 +621,30 @@ else fi %endif +%if %{?with_kernel_dkms} + +%files dkms +%defattr(-,root,root) +%{_prefix}/src/@PACKAGE@-%{version}/* + +%post dkms +for POSTINST in %{_prefix}/lib/dkms/common.postinst; do + if [ -f $POSTINST ]; then + $POSTINST @PACKAGE@ %{version} + exit $? + fi + echo "WARNING: $POSTINST does not exist." +done +echo -e "ERROR: DKMS version is too old and @PACKAGE@ was not" +echo -e "built with legacy DKMS support." +echo -e "You must either rebuild @PACKAGE@ with legacy postinst" +echo -e "support or upgrade DKMS to a more current version." +exit 1 + +%preun dkms +echo -e +echo -e "Uninstall of @PACKAGE@ module (version %{version}) beginning:" +dkms remove -m @PACKAGE@ -v %{version} --all --rpm_safe_upgrade +exit 0 + +%endif |