]> git.proxmox.com Git - mirror_spl-debian.git/commitdiff
Support building a spl-modules-dkms sub package
authorPrakash Surya <surya1@llnl.gov>
Tue, 7 Aug 2012 20:57:03 +0000 (13:57 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 8 Aug 2012 20:49:40 +0000 (13:49 -0700)
This commit adds support for building a spl-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 spl-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 <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/zfs#535

Makefile.am
Makefile.in
config/rpm.am
configure
configure.ac
dkms.conf.in [new file with mode: 0644]
dkms.postinst [new file with mode: 0755]
spl-modules.spec.in

index 490d128026a8b78f66b906beedbcf3eb806a92ba..a60ce1a5e57adcffee6c052272bedd8ccf7f8309 100644 (file)
@@ -14,6 +14,7 @@ SUBDIRS = $(USER_DIR) $(KERNEL_DIR)
 AUTOMAKE_OPTIONS = foreign
 EXTRA_DIST  = autogen.sh spl.spec.in spl-modules.spec.in META DISCLAIMER
 EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
+EXTRA_DIST += dkms.postinst
 noinst_HEADERS = spl_config.h spl.release
 
 distclean-local::
index a700798934feba6757d80d6b17a76bfead83c903..475ab084aca398612e2da47b0c98ec65658cef3b 100644 (file)
@@ -80,11 +80,12 @@ target_triplet = @target@
 DIST_COMMON = $(am__configure_deps) $(noinst_HEADERS) \
        $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
        $(srcdir)/PKGBUILD-spl-modules.in $(srcdir)/PKGBUILD-spl.in \
-       $(srcdir)/spl-modules.spec.in $(srcdir)/spl.release.in \
-       $(srcdir)/spl.spec.in $(srcdir)/spl_config.h.in \
-       $(top_srcdir)/config/arch.am $(top_srcdir)/config/deb.am \
-       $(top_srcdir)/config/rpm.am $(top_srcdir)/config/tgz.am \
-       $(top_srcdir)/configure $(top_srcdir)/module/Makefile.in \
+       $(srcdir)/dkms.conf.in $(srcdir)/spl-modules.spec.in \
+       $(srcdir)/spl.release.in $(srcdir)/spl.spec.in \
+       $(srcdir)/spl_config.h.in $(top_srcdir)/config/arch.am \
+       $(top_srcdir)/config/deb.am $(top_srcdir)/config/rpm.am \
+       $(top_srcdir)/config/tgz.am $(top_srcdir)/configure \
+       $(top_srcdir)/module/Makefile.in \
        $(top_srcdir)/module/spl/Makefile.in \
        $(top_srcdir)/module/splat/Makefile.in AUTHORS COPYING \
        ChangeLog INSTALL config/config.guess config/config.sub \
@@ -102,7 +103,7 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = spl_config.h
 CONFIG_CLEAN_FILES = module/Makefile module/spl/Makefile \
        module/splat/Makefile spl.spec spl-modules.spec PKGBUILD-spl \
-       PKGBUILD-spl-modules spl.release
+       PKGBUILD-spl-modules spl.release dkms.conf
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_GEN = $(am__v_GEN_$(V))
 am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
@@ -331,7 +332,7 @@ SUBDIRS = $(USER_DIR) $(KERNEL_DIR)
 AUTOMAKE_OPTIONS = foreign
 EXTRA_DIST = autogen.sh spl.spec.in spl-modules.spec.in META \
        DISCLAIMER config/config.awk config/rpm.am config/deb.am \
-       config/tgz.am
+       config/tgz.am dkms.postinst
 noinst_HEADERS = spl_config.h spl.release
 all: spl_config.h
        $(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -404,6 +405,8 @@ PKGBUILD-spl-modules: $(top_builddir)/config.status $(srcdir)/PKGBUILD-spl-modul
        cd $(top_builddir) && $(SHELL) ./config.status $@
 spl.release: $(top_builddir)/config.status $(srcdir)/spl.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
@@ -852,13 +855,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 \
@@ -877,6 +883,26 @@ rpm-local:
        mkdir -p $(rpmbuild)/SOURCES && \
        cp $(distdir).tar.gz $(rpmbuild)/SOURCES)
 
+dkms-common:
+       rpmpkg=$(pkg)-$(SPL_META_VERSION)-$(SPL_META_RELEASE).src.rpm; \
+       rpmspec=$(pkg).spec; \
+       rpmdkms=$(pkg)-dkms-$(SPL_META_VERSION)-$(SPL_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)-$(SPL_META_VERSION)-$(SPL_META_RELEASE).src.rpm; \
        rpmspec=$(pkg).spec; \
index a0a4ed1487b5e0cd90e3cbf5fae392a725fb15f7..7340b4fce8658c97027c5209e7f736c08e5e637d 100644 (file)
@@ -18,6 +18,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
@@ -28,7 +33,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 \
@@ -47,6 +52,26 @@ rpm-local:
        mkdir -p $(rpmbuild)/SOURCES && \
        cp $(distdir).tar.gz $(rpmbuild)/SOURCES)
 
+dkms-common:
+       rpmpkg=$(pkg)-$(SPL_META_VERSION)-$(SPL_META_RELEASE).src.rpm; \
+       rpmspec=$(pkg).spec; \
+       rpmdkms=$(pkg)-dkms-$(SPL_META_VERSION)-$(SPL_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)-$(SPL_META_VERSION)-$(SPL_META_RELEASE).src.rpm; \
        rpmspec=$(pkg).spec; \
index bbaedb0530e60554c4494b7b2727113c7ecbbbeb..4d2d458955bca6d83d455347ae0a3b2bcd00ae9f 100755 (executable)
--- a/configure
+++ b/configure
@@ -24169,7 +24169,7 @@ fi
 
 
 
-ac_config_files="$ac_config_files Makefile lib/Makefile cmd/Makefile module/Makefile module/spl/Makefile module/splat/Makefile include/Makefile scripts/Makefile spl.spec spl-modules.spec PKGBUILD-spl PKGBUILD-spl-modules spl.release"
+ac_config_files="$ac_config_files Makefile lib/Makefile cmd/Makefile module/Makefile module/spl/Makefile module/splat/Makefile include/Makefile scripts/Makefile spl.spec spl-modules.spec PKGBUILD-spl PKGBUILD-spl-modules spl.release dkms.conf"
 
 
 cat >confcache <<\_ACEOF
@@ -25091,6 +25091,7 @@ do
     "PKGBUILD-spl") CONFIG_FILES="$CONFIG_FILES PKGBUILD-spl" ;;
     "PKGBUILD-spl-modules") CONFIG_FILES="$CONFIG_FILES PKGBUILD-spl-modules" ;;
     "spl.release") CONFIG_FILES="$CONFIG_FILES spl.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;}
index 75859f77e3ba67a097dcb9bcce9919c498208e9f..27d3356ecbe0260c71c13fe7f68c0420bdb55447 100644 (file)
@@ -59,6 +59,7 @@ AC_CONFIG_FILES([
        PKGBUILD-spl
        PKGBUILD-spl-modules
        spl.release
+       dkms.conf
 ])
 
 AC_OUTPUT
diff --git a/dkms.conf.in b/dkms.conf.in
new file mode 100644 (file)
index 0000000..64f1f91
--- /dev/null
@@ -0,0 +1,23 @@
+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}
+"
+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]="spl"
+BUILT_MODULE_LOCATION[0]="module/spl/"
+DEST_MODULE_LOCATION[0]="/extra/spl/spl"
+BUILT_MODULE_NAME[1]="splat"
+BUILT_MODULE_LOCATION[1]="module/splat/"
+DEST_MODULE_LOCATION[1]="/extra/splat/splat"
diff --git a/dkms.postinst b/dkms.postinst
new file mode 100755 (executable)
index 0000000..cecf58e
--- /dev/null
@@ -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/spl_config.h          \
+   ${tree}/${pkgname}/${pkgver}/build/module/Module.symvers \
+   ${tree}/${pkgname}/${pkgver}/${kver}/${arch}/
index c27d0a5f9d47c7dc46dfddcde65bbd3c659a03c7..044225098d66145942f4ba53f96e43fdc6826338 100644 (file)
  %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
 
  %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
 
  %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')
 
  %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')
 
 
  %define kverpkg_kern    %{kver_kern}
  %define kverpkg_dbug    %{nil}
+ %define kverpkg_dkms    %{nil}
 
  %if %{undefined kdir}
   %define kdir_kern      /lib/modules/%{kver_kern}/build
 %if %{defined build_src_rpm}
 %define rel_kern         @SPL_META_RELEASE@
 %define rel_dbug         @SPL_META_RELEASE@
+%define rel_dkms         @SPL_META_RELEASE@
 %if %{defined kpkg_kern}
 %define req_kern         %{kpkg_kern}
 %endif
 %if %{defined kpkg_dbug}
 %define req_dbug         %{kpkg_dbug}
 %endif
+%if %{defined kpkg_dkms}
+%define req_dkms         %{kpkg_dkms}
+%endif
 %if %{defined kdevpkg_kern}
 %define devreq_kern      %{kdevpkg_kern}
 %endif
 %define relext_dbug      %(echo %{kverpkg_dbug} | %{__sed} -e 's/-/_/g')
 %define rel_kern         @SPL_META_RELEASE@_%{relext_kern}
 %define rel_dbug         @SPL_META_RELEASE@_%{relext_dbug}
+%define rel_dkms         @SPL_META_RELEASE@
 %if %{defined kpkg_kern}
 %define req_kern         %{kpkg_kern} %{koppkg} %{kverpkg_kern}
 %endif
 %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
 %if %{defined kdevpkg_kern}
 %define devreq_kern      %{kdevpkg_kern} %{koppkg} %{kverpkg_kern}
 %endif
@@ -397,6 +426,30 @@ The %{name}-debug-devel package contains the header files and
 Module{s}.symvers symbols needed for building additional modules which
 use %{name}-debug.
 
+%endif
+%if %{?with_kernel_dkms}
+
+%package dkms
+Summary:         Solaris Porting Layer Modules (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
+
+%description dkms
+The %{name}-dkms package contains all the necessary pieces to build and
+install Solaris Porting Layer (SPL) kernel modules with Dynamic Kernel
+Modules Support (DKMS). The SPL modules emulate Solaris style primatives
+in the the linux kernel. They include, but are not limited to: atomic,
+condvar, debug, error, memory, kobject, kstat, mutex, rwlock, taskq,
+thread, time, and vnode APIs.
+
 %endif
 
 %prep
@@ -421,6 +474,16 @@ make DESTDIR=$RPM_BUILD_ROOT install
 make
 make DESTDIR=$RPM_BUILD_ROOT install
 
+%endif
+%if %{?with_kernel_dkms}
+
+%configure --with-config=kernel \
+           %{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
+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
@@ -476,3 +539,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