Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #535
  • Loading branch information
prakashsurya authored and behlendorf committed Aug 8, 2012
1 parent 5085d55 commit 26e0895
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 14 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -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::
Expand Down
34 changes: 30 additions & 4 deletions Makefile.in
Expand Up @@ -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 \
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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; \
Expand Down
18 changes: 16 additions & 2 deletions config/kernel.m4
Expand Up @@ -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])
Expand Down
27 changes: 26 additions & 1 deletion config/rpm.am
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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; \
Expand Down
31 changes: 24 additions & 7 deletions configure
Expand Up @@ -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}`

Expand Down Expand Up @@ -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}`

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;}
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -124,6 +124,7 @@ AC_CONFIG_FILES([
PKGBUILD-zfs-modules
zfs-script-config.sh
zfs.release
dkms.conf
])

AC_OUTPUT
36 changes: 36 additions & 0 deletions 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"
24 changes: 24 additions & 0 deletions 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}/

0 comments on commit 26e0895

Please sign in to comment.