Refresh RPM packaging

Refresh the existing RPM packaging to conform to the 'Fedora
Packaging Guidelines'.  This includes adopting the kmods2
packaging standard which is used fod kmods distributed by
rpmfusion for Fedora/RHEL.

  http://fedoraproject.org/wiki/Packaging:Guidelines
  http://rpmfusion.org/Packaging/KernelModules/Kmods2

While the spec files have been entirely rewritten from a
user perspective the only major changes are:

* The Fedora packages now have a build dependency on the
  rpmfusion repositories.  The generic kmod packages also
  have a new dependency on kmodtool-1.22 but it is bundled
  with the source rpm so no additional packages are needed.

* The kernel binary module packages have been renamed from
  zfs-modules-* to kmod-zfs-* as specificed by kmods2.

* The is now a common kmod-zfs-devel-* package in addition
  to the per-kernel devel packages.  The common package
  contains the development headers while the per-kernel
  package contains kernel specific build products.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1341
This commit is contained in:
Brian Behlendorf 2013-02-17 12:10:17 -08:00
parent 9b2af9a097
commit f3757573a6
26 changed files with 1222 additions and 895 deletions

3
.gitignore vendored
View File

@ -40,10 +40,7 @@ Makefile.in
/libtool /libtool
/zfs_config.h /zfs_config.h
/zfs_config.h.in /zfs_config.h.in
/zfs.spec
/zfs-modules.spec
/zfs.release /zfs.release
/dkms.conf
/stamp-h1 /stamp-h1
/.script-config /.script-config
/zfs-script-config.sh /zfs-script-config.sh

View File

@ -2,7 +2,7 @@ include $(top_srcdir)/config/rpm.am
include $(top_srcdir)/config/deb.am include $(top_srcdir)/config/deb.am
include $(top_srcdir)/config/tgz.am include $(top_srcdir)/config/tgz.am
SUBDIRS = include SUBDIRS = include rpm
if CONFIG_USER if CONFIG_USER
SUBDIRS += dracut udev etc man scripts lib cmd SUBDIRS += dracut udev etc man scripts lib cmd
endif endif
@ -17,10 +17,9 @@ nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS)
endif endif
AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in EXTRA_DIST = autogen.sh copy-builtin
EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
EXTRA_DIST += META DISCLAIMER COPYRIGHT README.markdown OPENSOLARIS.LICENSE EXTRA_DIST += META DISCLAIMER COPYRIGHT README.markdown OPENSOLARIS.LICENSE
EXTRA_DIST += dkms.postinst copy-builtin
distclean-local:: distclean-local::
-$(RM) -R autom4te*.cache -$(RM) -R autom4te*.cache
@ -45,5 +44,5 @@ etags:
tags: ctags etags tags: ctags etags
pkg: @DEFAULT_PACKAGE@ pkg: @DEFAULT_PACKAGE@
pkg-modules: @DEFAULT_PACKAGE@-modules pkg-kmod: @DEFAULT_PACKAGE@-kmod
pkg-utils: @DEFAULT_PACKAGE@-utils pkg-utils: @DEFAULT_PACKAGE@-utils

View File

@ -14,22 +14,20 @@ deb-local:
exit 1; \ exit 1; \
fi) fi)
deb-modules: deb-local rpm-modules deb-kmod: deb-local rpm-kmod
if CONFIG_KERNEL if CONFIG_KERNEL
name=${PACKAGE}-modules; \ name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ version=${VERSION}-${RELEASE}; \
release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \ arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \ pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \
pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \ fakeroot $(ALIEN) --scripts --to-deb $$pkg1; \
pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \ $(RM) $$pkg1
fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2; \
$(RM) $$pkg1 $$pkg2
endif endif
deb-utils: deb-local rpm-utils deb-utils: deb-local rpm-utils
if CONFIG_USER if CONFIG_USER
name=${PACKAGE}; \ name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \ pkg1=$${name}-$${version}.$${arch}.rpm; \
pkg2=$${name}-devel-$${version}.$${arch}.rpm; \ pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
@ -39,4 +37,4 @@ if CONFIG_USER
$(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4 $(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4
endif endif
deb: deb-modules deb-utils deb: deb-kmod deb-utils

View File

@ -1,31 +1,40 @@
srpm-modules: ###############################################################################
if CONFIG_KERNEL # Copyright (C) 2007-2013 Lawrence Livermore National Security, LLC.
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common # Copyright (C) 2007 The Regents of the University of California.
endif # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
###############################################################################
# Build targets for RPM packages.
###############################################################################
srpm-kmod:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \
def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_KMOD}' srpm-common
srpm-dkms:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_DKMS}' srpm-common
srpm-utils: srpm-utils:
if CONFIG_USER $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_UTIL}' srpm-common
endif
srpm: srpm-modules srpm-utils srpm: srpm-kmod srpm-dkms srpm-utils
srpms: srpm-kmod srpm-dkms srpm-utils
rpm-dkms: srpm-modules rpm-kmod: srpm-kmod
if CONFIG_KERNEL $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" dkms-common def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_KMOD}' rpm-common
endif
rpm-modules: srpm-modules rpm-dkms: srpm-dkms
if CONFIG_KERNEL $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_DKMS}' rpm-common
endif
rpm-utils: srpm-utils rpm-utils: srpm-utils
if CONFIG_USER $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL}' rpm-common
endif
rpm: rpm-modules rpm-utils rpm-dkms rpm: rpm-kmod rpm-dkms rpm-utils
rpms: rpm-kmod rpm-dkms rpm-utils
rpm-local: rpm-local:
@(if test "${HAVE_RPMBUILD}" = "no"; then \ @(if test "${HAVE_RPMBUILD}" = "no"; then \
@ -40,32 +49,14 @@ rpm-local:
mkdir -p $(rpmbuild)/RPMS && \ mkdir -p $(rpmbuild)/RPMS && \
mkdir -p $(rpmbuild)/SRPMS && \ mkdir -p $(rpmbuild)/SRPMS && \
mkdir -p $(rpmbuild)/SPECS && \ mkdir -p $(rpmbuild)/SPECS && \
cp $(rpmspec) $(rpmbuild)/SPECS && \ cp ${RPM_SPEC_DIR}/$(rpmspec) $(rpmbuild)/SPECS && \
mkdir -p $(rpmbuild)/SOURCES && \ mkdir -p $(rpmbuild)/SOURCES && \
cp scripts/kmodtool $(rpmbuild)/SOURCES && \
cp $(distdir).tar.gz $(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 srpm-common: dist
rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ @(dist=`$(RPM) --eval %{?dist}`; \
rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
rpmspec=$(pkg).spec; \ rpmspec=$(pkg).spec; \
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) \ $(MAKE) $(AM_MAKEFLAGS) \
@ -75,32 +66,22 @@ srpm-common: dist
$(RPMBUILD) \ $(RPMBUILD) \
--define "_tmppath $$rpmbuild/TMP" \ --define "_tmppath $$rpmbuild/TMP" \
--define "_topdir $$rpmbuild" \ --define "_topdir $$rpmbuild" \
--define "build_src_rpm 1" \ $(def) -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
--define "dist %{nil}" \
--nodeps -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \ cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \
$(RM) -R $$rpmbuild rm -R $$rpmbuild)
rpm-common: rpm-common:
rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ @(dist=`$(RPM) --eval %{?dist}`; \
rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
rpmspec=$(pkg).spec; \ rpmspec=$(pkg).spec; \
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) \ $(MAKE) $(AM_MAKEFLAGS) \
rpmbuild="$$rpmbuild" \ rpmbuild="$$rpmbuild" \
rpmspec="$$rpmspec" \ rpmspec="$$rpmspec" \
rpm-local || exit 1; \ rpm-local || exit 1; \
$(RPMBUILD) \ ${RPMBUILD} \
--define "_tmppath $$rpmbuild/TMP" \ --define "_tmppath $$rpmbuild/TMP" \
--define "_topdir $$rpmbuild" \ --define "_topdir $$rpmbuild" \
--define "dist %{nil}" \ $(def) --rebuild $$rpmpkg || exit 1; \
--define "require_kdir $(LINUX)" \
--define "require_kobj $(LINUX_OBJ)" \
--define "require_kver $(LINUX_VERSION)" \
--define "require_spldir $(SPL)" \
--define "require_splobj $(SPL_OBJ)" \
--define "require_splver $(SPL_VERSION)" \
--define "$(DEBUG_ZFS) 1" \
--define "$(DEBUG_DMU_TX) 1" \
--nodeps --rebuild $$rpmpkg || exit 1; \
cp $$rpmbuild/RPMS/*/* . || exit 1; \ cp $$rpmbuild/RPMS/*/* . || exit 1; \
$(RM) -R $$rpmbuild rm -R $$rpmbuild)

View File

@ -7,22 +7,20 @@ tgz-local:
exit 1; \ exit 1; \
fi) fi)
tgz-modules: tgz-local rpm-modules tgz-kmod: tgz-local rpm-kmod
if CONFIG_KERNEL if CONFIG_KERNEL
name=${PACKAGE}-modules; \ name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ version=${VERSION}-${RELEASE}; \
release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \ arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \ pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \
pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \ fakeroot $(ALIEN) --scripts --to-tgz $$pkg1; \
pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \ $(RM) $$pkg1
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2; \
$(RM) $$pkg1 $$pkg2
endif endif
tgz-utils: tgz-local rpm-utils tgz-utils: tgz-local rpm-utils
if CONFIG_USER if CONFIG_USER
name=${PACKAGE}; \ name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \ pkg1=$${name}-$${version}.$${arch}.rpm; \
pkg2=$${name}-devel-$${version}.$${arch}.rpm; \ pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
@ -31,4 +29,4 @@ if CONFIG_USER
$(RM) $$pkg1 $$pkg2 $$pkg3 $(RM) $$pkg1 $$pkg2 $$pkg3
endif endif
tgz: tgz-modules tgz-utils tgz: tgz-kmod tgz-utils

View File

@ -109,6 +109,11 @@ dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
dnl # are missing it is non-fatal but you will not be able to build dnl # are missing it is non-fatal but you will not be able to build
dnl # RPM packages and will be warned if you try too. dnl # RPM packages and will be warned if you try too.
dnl # dnl #
dnl # By default the generic spec file will be used because it requires
dnl # minimal dependencies. Distribution specific spec files can be
dnl # placed under the 'rpm/<distribution>' directory and enabled using
dnl # the --with-spec=<distribution> configure option.
dnl #
AC_DEFUN([ZFS_AC_RPM], [ AC_DEFUN([ZFS_AC_RPM], [
RPM=rpm RPM=rpm
RPMBUILD=rpmbuild RPMBUILD=rpmbuild
@ -133,6 +138,25 @@ AC_DEFUN([ZFS_AC_RPM], [
AC_MSG_RESULT([$HAVE_RPMBUILD]) AC_MSG_RESULT([$HAVE_RPMBUILD])
]) ])
RPM_DEFINE_COMMON=
RPM_DEFINE_UTIL=
RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
RPM_DEFINE_DKMS=
SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
SRPM_DEFINE_UTIL=
SRPM_DEFINE_KMOD=
SRPM_DEFINE_DKMS=
RPM_SPEC_DIR="rpm/generic"
AC_ARG_WITH([spec],
AS_HELP_STRING([--with-spec=SPEC],
[Spec files 'generic|fedora']),
[RPM_SPEC_DIR="rpm/$withval"])
AC_MSG_CHECKING([whether spec files are available])
AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
AC_SUBST(HAVE_RPM) AC_SUBST(HAVE_RPM)
AC_SUBST(RPM) AC_SUBST(RPM)
AC_SUBST(RPM_VERSION) AC_SUBST(RPM_VERSION)
@ -140,6 +164,16 @@ AC_DEFUN([ZFS_AC_RPM], [
AC_SUBST(HAVE_RPMBUILD) AC_SUBST(HAVE_RPMBUILD)
AC_SUBST(RPMBUILD) AC_SUBST(RPMBUILD)
AC_SUBST(RPMBUILD_VERSION) AC_SUBST(RPMBUILD_VERSION)
AC_SUBST(RPM_SPEC_DIR)
AC_SUBST(RPM_DEFINE_UTIL)
AC_SUBST(RPM_DEFINE_KMOD)
AC_SUBST(RPM_DEFINE_DKMS)
AC_SUBST(RPM_DEFINE_COMMON)
AC_SUBST(SRPM_DEFINE_UTIL)
AC_SUBST(SRPM_DEFINE_KMOD)
AC_SUBST(SRPM_DEFINE_DKMS)
AC_SUBST(SRPM_DEFINE_COMMON)
]) ])
dnl # dnl #

View File

@ -46,6 +46,9 @@ AC_DEFUN([ZFS_AC_META], [
[Define the project release.] [Define the project release.]
) )
AC_SUBST([ZFS_META_RELEASE]) AC_SUBST([ZFS_META_RELEASE])
RELEASE="$ZFS_META_RELEASE"
AC_SUBST([RELEASE])
fi fi
ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([LICENSE]); ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([LICENSE]);

View File

@ -119,11 +119,17 @@ AC_CONFIG_FILES([
scripts/zpios-test/Makefile scripts/zpios-test/Makefile
scripts/zpool-config/Makefile scripts/zpool-config/Makefile
scripts/common.sh scripts/common.sh
zfs.spec rpm/Makefile
zfs-modules.spec rpm/fedora/Makefile
rpm/fedora/zfs.spec
rpm/fedora/zfs-kmod.spec
rpm/fedora/zfs-dkms.spec
rpm/generic/Makefile
rpm/generic/zfs.spec
rpm/generic/zfs-kmod.spec
rpm/generic/zfs-dkms.spec
zfs-script-config.sh zfs-script-config.sh
zfs.release zfs.release
dkms.conf
]) ])
AC_OUTPUT AC_OUTPUT

View File

@ -1,36 +0,0 @@
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"

1
rpm/Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = fedora generic

3
rpm/fedora/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/zfs-dkms.spec
/zfs-kmod.spec
/zfs.spec

1
rpm/fedora/Makefile.am Normal file
View File

@ -0,0 +1 @@
EXTRA_DIST = zfs.spec.in zfs-kmod.spec.in zfs-dkms.spec.in

1
rpm/fedora/zfs-dkms.spec.in Symbolic link
View File

@ -0,0 +1 @@
../generic/zfs-dkms.spec.in

117
rpm/fedora/zfs-kmod.spec.in Normal file
View File

@ -0,0 +1,117 @@
%define module @PACKAGE@
%define repo rpmfusion
%define buildforkernels newest
#define buildforkernels current
#define buildforkernels akmod
%bcond_with debug
%bcond_with debug_dmu_tx
Name: %{module}-kmod
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: Kernel module(s)
Group: System Environment/Kernel
License: @ZFS_META_LICENSE@
URL: http://zfsonlinux.org/
Source0: %{module}-%{version}.tar.gz
Source10: kmodtool
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: i586 i686 x86_64
# Likely compiles but is not supported.
ExcludeArch: ppc ppc64
# The developments headers will conflict with the dkms packages.
Conflicts: %{module}-dkms
BuildRequires: %{_bindir}/kmodtool
%global KmodsBuildRequires kmod-spl-devel
%global KmodsRequires kmod-spl
%{!?kernels:BuildRequires: buildsys-build-rpmfusion-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu} }
%if 0%{?fedora} >= 17
%define prefix /usr
%endif
# Kmodtool does its magic here. A patched version of kmodtool is shipped
# with the source rpm until kmod development packages are supported upstream.
# https://bugzilla.rpmfusion.org/show_bug.cgi?id=2714
%{expand:%(sh %{SOURCE10} --target %{_target_cpu} --repo %{repo} --kmodname %{name} --devel %{?prefix:--prefix "%{?prefix}"} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }
%description
This package contains the ZFS kernel modules.
%prep
# Error out if there was something wrong with kmodtool.
%{?kmodtool_check}
# Print kmodtool output for debugging purposes:
sh %{SOURCE10} --target %{_target_cpu} --repo %{repo} --kmodname %{name} --devel %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null
%if %{with debug}
%define debug --enable-debug
%else
%define debug --disable-debug
%endif
%if %{with debug_dmu_tx}
%define debug_dmu_tx --enable-debug-dmu-tx
%else
%define debug_dmu_tx --disable-debug-dmu-tx
%endif
# Leverage VPATH from configure to avoid making multiple copies.
%define _configure ../%{module}-%{version}/configure
%setup -q -c -T -a 0
for kernel_version in %{?kernel_versions}; do
%{__mkdir} _kmod_build_${kernel_version%%___*}
done
%build
for kernel_version in %{?kernel_versions}; do
pushd _kmod_build_${kernel_version%%___*}
%configure \
--with-config=kernel \
--with-linux="${kernel_version##*___}" \
--with-linux-obj="${kernel_version##*___}" \
--with-spl="/usr/src/spl-%{version}" \
--with-spl-obj="/usr/src/spl-%{version}/${kernel_version%%___*}" \
%{debug} \
%{debug_dmu_tx}
make %{?_smp_mflags}
popd
done
%install
rm -rf ${RPM_BUILD_ROOT}
# Relies on the kernel 'modules_install' make target.
for kernel_version in %{?kernel_versions}; do
pushd _kmod_build_${kernel_version%%___*}
make install \
DESTDIR=${RPM_BUILD_ROOT} \
%{?prefix:INSTALL_MOD_PATH=%{?prefix}} \
INSTALL_MOD_DIR=%{kmodinstdir_postfix}
popd
done
chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/*
%{?akmod_install}
%clean
rm -rf $RPM_BUILD_ROOT
%changelog
* Tue Mar 12 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 0.6.0-1
- Initial kmods2 packaging.

1
rpm/fedora/zfs.spec.in Symbolic link
View File

@ -0,0 +1 @@
../generic/zfs.spec.in

3
rpm/generic/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/zfs-dkms.spec
/zfs-kmod.spec
/zfs.spec

1
rpm/generic/Makefile.am Normal file
View File

@ -0,0 +1 @@
EXTRA_DIST = zfs.spec.in zfs-kmod.spec.in zfs-dkms.spec.in

View File

@ -0,0 +1,67 @@
%define module @PACKAGE@
%define mkconf scripts/dkms.mkconf
Name: %{module}-dkms
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: Kernel module(s) (dkms)
Group: System Environment/Kernel
License: @ZFS_META_LICENSE@
URL: http://zfsonlinux.org/
Source0: %{module}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: dkms >= 2.2.0.2
Provides: %{module}-kmod = %{version}
Conflicts: %{module}-kmod
%description
This package contains the dkms ZFS kernel modules.
%prep
%setup -q -n %{module}-%{version}
%build
%{mkconf} -n %{module} -v %{version} -f dkms.conf
%install
if [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
mkdir -p $RPM_BUILD_ROOT/usr/src/
cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/
%clean
if [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
%files
%defattr(-,root,root)
/usr/src/%{module}-%{version}
%post
for POSTINST in /usr/lib/dkms/common.postinst; do
if [ -f $POSTINST ]; then
$POSTINST %{module} %{version}
exit $?
fi
echo "WARNING: $POSTINST does not exist."
done
echo -e "ERROR: DKMS version is too old and %{module} was not"
echo -e "built with legacy DKMS support."
echo -e "You must either rebuild %{module} with legacy postinst"
echo -e "support or upgrade DKMS to a more current version."
exit 1
%preun
dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade
exit 0
%changelog
* Tue Mar 12 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 0.6.0-1
- Initial dkms packaging.

View File

@ -0,0 +1,130 @@
%define module @PACKAGE@
%bcond_with debug
%bcond_with debug_dmu_tx
Name: %{module}-kmod
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: Kernel module(s)
Group: System Environment/Kernel
License: @ZFS_META_LICENSE@
URL: http://zfsonlinux.org/
Source0: %{module}-%{version}.tar.gz
Source10: kmodtool
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# The developments headers will conflict with the dkms packages.
Conflicts: %{module}-dkms
# Source packages minimally require a kernel-devel dependency.
%{?rhel:BuildRequires: kernel-devel}
%{?fedora:BuildRequires: kernel-devel}
%{?suse_version:BuildRequires: kernel-source}
%if 0%{?rhel}%{?fedora}%{?suse_version}
%global KmodsBuildRequires kmod-spl-devel
%global KmodsRequires kmod-spl
%endif
# Binary packages build against all installed kernels by default.
%if !%{defined kernels} && !%{defined build_src_rpm}
%if 0%{?rhel}%{?fedora}%{?suse_version}
%define kernels %(ls -1 /usr/src/kernels)
%else
%define kernels %(ls -1 /lib/modules)
%endif
%endif
%if 0%{?fedora} >= 17
%define prefix /usr
%endif
# Kmodtool does its magic here. A patched version of kmodtool is shipped
# with the source rpm until kmod development packages are supported upstream.
# https://bugzilla.rpmfusion.org/show_bug.cgi?id=2714
%{expand:%(bash %{SOURCE10} --target %{_target_cpu} --kmodname %{name} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }
%description
This package contains the ZFS kernel modules.
%prep
# Error out if there was something wrong with kmodtool.
%{?kmodtool_check}
# Print kmodtool output for debugging purposes:
bash %{SOURCE10} --target %{_target_cpu} --repo %{repo} --kmodname %{name} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null
%if %{with debug}
%define debug --enable-debug
%else
%define debug --disable-debug
%endif
%if %{with debug_dmu_tx}
%define debug_dmu_tx --enable-debug-dmu-tx
%else
%define debug_dmu_tx --disable-debug-dmu-tx
%endif
# Leverage VPATH from configure to avoid making multiple copies.
%define _configure ../%{module}-%{version}/configure
%setup -q -c -T -a 0
for kernel_version in %{?kernel_versions}; do
%{__mkdir} _kmod_build_${kernel_version%%___*}
done
%build
for kernel_version in %{?kernel_versions}; do
cd _kmod_build_${kernel_version%%___*}
%configure \
--with-config=kernel \
%if 0%{?rhel}%{?fedora}
--with-linux="${kernel_version##*___}" \
--with-linux-obj="${kernel_version##*___}" \
%else
--with-linux=\
%(if [ -e /lib/modules/${kernel_version%%___*}/source ]; then \
echo "/lib/modules/${kernel_version%%___*}/source" \
else \
echo "/lib/modules/${kernel_version%%___*}/build" \
fi) \
--with-linux-obj="/lib/modules/${kernel_version%%___*}/build" \
%endif
--with-spl="/usr/src/spl-%{version}" \
--with-spl-obj="/usr/src/spl-%{version}/${kernel_version%%___*}" \
%{debug} \
%{debug_dmu_tx}
make %{?_smp_mflags}
cd ..
done
%install
rm -rf ${RPM_BUILD_ROOT}
# Relies on the kernel 'modules_install' make target.
for kernel_version in %{?kernel_versions}; do
cd _kmod_build_${kernel_version%%___*}
make install \
DESTDIR=${RPM_BUILD_ROOT} \
%{?prefix:INSTALL_MOD_PATH=%{?prefix}} \
INSTALL_MOD_DIR=%{kmodinstdir_postfix}
cd ..
done
chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/*
%{?akmod_install}
%clean
rm -rf $RPM_BUILD_ROOT
%changelog
* Tue Mar 12 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 0.6.0-1
- Initial kmods2 packaging.

147
rpm/generic/zfs.spec.in Normal file
View File

@ -0,0 +1,147 @@
%global _sbindir /sbin
%global _libdir /%{_lib}
%if 0%{?fedora} >= 17
%global _udevdir %{_prefix}/lib/udev
%global _dracutdir %{_prefix}/lib/dracut
%else
%global _udevdir /lib/udev
%global _dracutdir /lib/dracut
%endif
%bcond_with debug
%bcond_with blkid
%bcond_with selinux
Name: @PACKAGE@
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: Commands to control the kernel modules and libraries
Group: System Environment/Kernel
License: @ZFS_META_LICENSE@
URL: http://zfsonlinux.org/
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: i386 i686 x86_64
# May build but untested on ppc/ppc64
ExcludeArch: ppc ppc64
Requires: %{name}-kmod >= %{version}
Provides: %{name}-kmod-common = %{version}
%if 0%{?rhel}%{?fedora}%{?suse_version}
BuildRequires: zlib-devel
BuildRequires: libuuid-devel
%if %{with blkid}
BuildRequires: libblkid-devel
%endif
%if %{with selinux}
BuildRequires: libselinux-devel
%endif
%endif
%description
This package contains the ZFS command line utilities and libraries.
%package devel
Summary: Development headers
Group: System Environment/Kernel
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
This package contains the header files needed for building additional
applications against the ZFS libraries.
%package test
Summary: Test infrastructure
Group: System Environment/Kernel
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: parted
Requires: lsscsi
Requires: mdadm
Requires: bc
%description test
This package contains test infrastructure and support scripts for
validating the file system.
%package dracut
Summary: Dracut module
Group: System Environment/Kernel
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: dracut
%description dracut
This package contains a dracut module used to construct an initramfs
image which is ZFS aware.
%prep
%if %{with debug}
%define debug --enable-debug
%else
%define debug --disable-debug
%endif
%if %{with blkid}
%define blkid --with-blkid
%else
%define blkid --without-blkid
%endif
%if %{with selinux}
%define selinux --with-selinux
%else
%define selinux --without-selinux
%endif
%setup -q
%build
%configure \
--with-config=user \
--with-udevdir=%{_udevdir} \
--with-dracutdir=%{_dracutdir} \
--disable-static \
%{debug} \
%{blkid} \
%{selinux}
make %{?_smp_mflags}
%install
%{__rm} -rf $RPM_BUILD_ROOT
make install DESTDIR=%{?buildroot}
find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%doc AUTHORS COPYRIGHT DISCLAIMER
%doc OPENSOLARIS.LICENSE README.markdown
%{_sbindir}/*
%{_libdir}/*.so.1*
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*
%{_udevdir}/vdev_id
%{_udevdir}/zvol_id
%{_udevdir}/rules.d/*
%config(noreplace) %{_sysconfdir}/%{name}
# Systemd integration is still required.
%exclude %{_sysconfdir}/init.d/*
%files devel
%{_libdir}/*.so
%{_includedir}/*
%files test
%{_datadir}/%{name}
%files dracut
%doc dracut/README.dracut.markdown
%{_dracutdir}/modules.d/*
%changelog
* Tue Mar 12 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 0.6.0-1
- Refreshed RPM packaging.

View File

@ -1,5 +1,8 @@
SUBDIRS = zpool-config zpios-test zpios-profile SUBDIRS = zpool-config zpios-test zpios-profile
EXTRA_DIST = dkms.mkconf dkms.postinst kmodtool
pkgdatadir = $(datadir)/@PACKAGE@
dist_pkgdata_SCRIPTS = \ dist_pkgdata_SCRIPTS = \
$(top_builddir)/scripts/common.sh \ $(top_builddir)/scripts/common.sh \
$(top_srcdir)/scripts/zconfig.sh \ $(top_srcdir)/scripts/zconfig.sh \

88
scripts/dkms.mkconf Executable file
View File

@ -0,0 +1,88 @@
#!/bin/sh
PROG=$0
pkgcfg=/etc/sysconfig/zfs
while getopts "n:v:c:f:" opt; do
case $opt in
n) pkgname=$OPTARG ;;
v) pkgver=$OPTARG ;;
c) pkgcfg=$OPTARG ;;
f) filename=$OPTARG ;;
esac
done
if [ -z "${pkgname}" -o -z "${pkgver}" -o -z "${filename}" ]; then
echo "Usage: $PROG -n <pkgname> -v <pkgver> -c <pkgcfg> -f <filename>"
exit 1
fi
cat >${filename} <<EOF
PACKAGE_NAME="${pkgname}"
PACKAGE_VERSION="${pkgver}"
PACKAGE_CONFIG="${pkgcfg}"
PRE_BUILD="configure
--prefix=/usr
--with-config=kernel
--with-spl=\${dkms_tree}/spl/\${PACKAGE_VERSION}/build
--with-spl-obj=\${dkms_tree}/spl/\${PACKAGE_VERSION}/\${kernelver}/\${arch}
--with-spl-timeout=300
\$(
[[ -r \${PACKAGE_CONFIG} ]] \\
&& source \${PACKAGE_CONFIG} \\
&& shopt -q -s extglob \\
&& \\
{
if [[ \${ZFS_DKMS_ENABLE_DEBUG,,} == @(y|yes) ]]
then
echo --enable-debug
fi
if [[ \${ZFS_DKMS_ENABLE_DMU_TX,,} == @(y|yes) ]]
then
echo --enable-debug-dmu-tx
fi
}
)
"
POST_INSTALL="scripts/dkms.postinst
-n \${PACKAGE_NAME}
-v \${PACKAGE_VERSION}
-a \${arch}
-k \${kernelver}
-t \${dkms_tree}
"
AUTOINSTALL="yes"
REMAKE_INITRD="no"
MAKE[0]="make"
STRIP[0]="\$(
[[ -r \${PACKAGE_CONFIG} ]] \\
&& source \${PACKAGE_CONFIG} \\
&& shopt -q -s extglob \\
&& [[ \${ZFS_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] \\
&& echo -n no
)"
STRIP[1]="\${STRIP[0]}"
STRIP[2]="\${STRIP[0]}"
STRIP[3]="\${STRIP[0]}"
STRIP[4]="\${STRIP[0]}"
STRIP[5]="\${STRIP[0]}"
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"
EOF

552
scripts/kmodtool Executable file
View File

@ -0,0 +1,552 @@
#!/bin/bash
# kmodtool - Helper script for building kernel module RPMs
# Copyright (c) 2003-2012 Ville Skyttä <ville.skytta@iki.fi>,
# Thorsten Leemhuis <fedora@leemhuis.info>
# Nicolas Chauvet <kwizart@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
shopt -s extglob
myprog="kmodtool-${repo}"
myver="0.12.1"
kmodname=
build_kernels="current"
kernels_known_variants=
kernel_versions=
kernel_versions_to_build_for=
prefix=
filterfile=
target=
error_out()
{
local errorlevel=${1}
shift
echo "Error: $@" >&2
# the next line is not multi-line safe -- not needed *yet*
echo "%global kmodtool_check echo \"kmodtool error: $@\"; exit ${errorlevel};"
exit ${errorlevel}
}
print_rpmtemplate_header()
{
echo
echo '%global kmodinstdir_prefix '${prefix}/lib/modules/
echo '%global kmodinstdir_postfix '/extra/${kmodname}/
echo '%global kernel_versions '${kernel_versions}
echo
}
print_akmodtemplate ()
{
echo
cat <<EOF
%global akmod_install mkdir -p \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/; \\\
rpmbuild --define "_sourcedir %{_sourcedir}" \\\
--define "_srcrpmdir \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/" \\\
-bs --nodeps %{_specdir}/%{name}.spec ; \\\
ln -s \$(ls \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/) \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/${kmodname}-kmod.latest
%package -n akmod-${kmodname}
Summary: Akmod package for ${kmodname} kernel module(s)
Group: System Environment/Kernel
Requires: kmodtool
Requires: akmods
%{?AkmodsBuildRequires:Requires: %{AkmodsBuildRequires}}
# same requires and provides as a kmods package would have
Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
EOF
if [[ ${obsolete_name} ]]; then
echo "Provides: akmod-${obsolete_name} = ${obsolete_version}"
echo "Obsoletes: akmod-${obsolete_name} < ${obsolete_version}"
fi
cat <<EOF
%description -n akmod-${kmodname}
This package provides the akmod package for the ${kmodname} kernel modules.
%posttrans -n akmod-${kmodname}
nohup ${prefix}/sbin/akmods --from-akmod-posttrans --akmod ${kmodname} &> /dev/null &
%files -n akmod-${kmodname}
%defattr(-,root,root,-)
%{_usrsrc}/akmods/*
EOF
}
print_akmodmeta ()
{
cat <<EOF
%package -n kmod-${kmodname}
Summary: Metapackage which tracks in ${kmodname} kernel module for newest kernel${dashvariant}
Group: System Environment/Kernel
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: kmod-${kmodname}-xen = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: kmod-${kmodname}-smp = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: kmod-${kmodname}-PAE = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: akmod-${kmodname} = %{?epoch:%{epoch}:}%{version}-%{release}
EOF
if [[ ${obsolete_name} ]]; then
echo "Provides: kmod-${obsolete_name} = ${obsolete_version}"
echo "Obsoletes: kmod-${obsolete_name} < ${obsolete_version}"
fi
cat <<EOF
%description -n kmod-${kmodname}${dashvariant}
This is a meta-package without payload which sole purpose is to require the
${kmodname} kernel module(s) for the newest kernel${dashvariant},
to make sure you get it together with a new kernel.
%files -n kmod-${kmodname}${dashvariant}
%defattr(644,root,root,755)
EOF
}
print_rpmtemplate_per_kmodpkg ()
{
if [[ "${1}" == "--custom" ]]; then
shift
local customkernel=true
elif [[ "${1}" == "--redhat" ]]; then
# this is needed for akmods
shift
local redhatkernel=true
fi
local kernel_uname_r=${1}
local kernel_variant="${2:+-${2}}"
# first part
cat <<EOF
%package -n kmod-${kmodname}-${kernel_uname_r}
Summary: ${kmodname} kernel module(s) for ${kernel_uname_r}
Group: System Environment/Kernel
Provides: kernel-modules-for-kernel = ${kernel_uname_r}
Provides: kmod-${kmodname}-uname-r = ${kernel_uname_r}
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
Requires(post): ${prefix}/sbin/depmod
Requires(postun): ${prefix}/sbin/depmod
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
%{?KmodsBuildRequires:BuildRequires: %{KmodsBuildRequires}-uname-r = ${kernel_uname_r}}
%{?KmodsBuildRequires:BuildRequires: %{KmodsBuildRequires}}
EOF
if [[ ${obsolete_name} ]]; then
echo "Provides: kmod-${obsolete_name}-${kernel_uname_r} = ${obsolete_version}"
echo "Obsoletes: kmod-${obsolete_name}-${kernel_uname_r} < ${obsolete_version}"
fi
# second part
if [[ ! "${customkernel}" ]]; then
cat <<EOF
Requires: kernel-uname-r = ${kernel_uname_r}
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
%post -n kmod-${kmodname}-${kernel_uname_r}
${prefix}/sbin/depmod -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
%postun -n kmod-${kmodname}-${kernel_uname_r}
${prefix}/sbin/depmod -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
EOF
else
cat <<EOF
%post -n kmod-${kmodname}-${kernel_uname_r}
[[ "$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}/sbin/depmod -a > /dev/null || :
%postun -n kmod-${kmodname}-${kernel_uname_r}
[[ "$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}/sbin/depmod -a > /dev/null || :
EOF
fi
# third part
cat <<EOF
%description -n kmod-${kmodname}-${kernel_uname_r}
This package provides the ${kmodname} kernel modules built for the Linux
kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
%files -n kmod-${kmodname}-${kernel_uname_r}
%defattr(644,root,root,755)
%dir $prefix/lib/modules/${kernel_uname_r}/extra
${prefix}/lib/modules/${kernel_uname_r}/extra/${kmodname}/
EOF
}
print_rpmtemplate_kmoddevelpkg ()
{
cat <<EOF
%package -n kmod-${kmodname}-devel
Summary: ${kmodname} kernel module(s) devel common
Group: System Environment/Kernel
Provides: ${kmodname}-devel-kmod-common = %{?epoch:%{epoch}:}%{version}-%{release}
%description -n kmod-${kmodname}-devel
This package provides the common header files to build kernel modules
which depend on the ${kmodname} kernel module.
%files -n kmod-${kmodname}-devel
%defattr(644,root,root,755)
%{_usrsrc}/${kmodname}-%{version}
EOF
for kernel in ${1}; do
local kernel_uname_r=${kernel}
echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}"
done
echo
echo
}
print_rpmtemplate_per_kmoddevelpkg ()
{
if [[ "${1}" == "--custom" ]]; then
shift
local customkernel=true
elif [[ "${1}" == "--redhat" ]]; then
# this is needed for akmods
shift
local redhatkernel=true
fi
local kernel_uname_r=${1}
local kernel_variant="${2:+-${2}}"
cat <<EOF
%package -n kmod-${kmodname}-devel-${kernel_uname_r}
Summary: ${kmodname} kernel module(s) devel for ${kernel_uname_r}
Group: System Environment/Kernel
Requires: ${kmodname}-devel-kmod-common = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: kmod-${kmodname}-devel-uname-r = ${kernel_uname_r}
EOF
# second part
if [[ ! "${customkernel}" ]]; then
cat <<EOF
Requires: kernel-uname-r = ${kernel_uname_r}
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
EOF
fi
cat <<EOF
%description -n kmod-${kmodname}-devel-${kernel_uname_r}
This package provides objects and symbols required to build kernel modules
which depend on the ${kmodname} kernel modules built for the Linux
kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
%files -n kmod-${kmodname}-devel-${kernel_uname_r}
%defattr(644,root,root,755)
%{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}
EOF
}
print_rpmtemplate_kmodmetapkg ()
{
local kernel_uname_r=${1}
local kernel_variant="${2:+-${2}}"
cat <<EOF
%package -n kmod-${kmodname}${kernel_variant}
Summary: Metapackage which tracks in ${kmodname} kernel module for newest kernel${kernel_variant}
Group: System Environment/Kernel
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: kmod-${kmodname}-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}
EOF
if [[ ${obsolete_name} ]]; then
echo "Provides: kmod-${obsolete_name}${kernel_variant} = ${obsolete_version}"
echo "Obsoletes: kmod-${obsolete_name}${kernel_variant} < ${obsolete_version}"
fi
cat <<EOF
%description -n kmod-${kmodname}${kernel_variant}
This is a meta-package without payload which sole purpose is to require the
${kmodname} kernel module(s) for the newest kernel${kernel_variant}.
to make sure you get it together with a new kernel.
%files -n kmod-${kmodname}${kernel_variant}
%defattr(644,root,root,755)
EOF
}
print_customrpmtemplate ()
{
for kernel in ${1}
do
if [[ -e "/usr/src/kernels/${kernel}" ]] ; then
# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
kernel_versions="${kernel_versions}${kernel}___%{_usrsrc}/kernels/${kernel} "
# parse kernel versions string and print template
local kernel_verrelarch=${kernel%%${kernels_known_variants}}
print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
# create development package
if [[ "${devel}" ]]; then
print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
fi
elif [[ -e ${prefix}/lib/modules/"${kernel}"/build/Makefile ]] ; then
# likely a user-build-kernel with available buildfiles
# fixme: we should check if uname from Makefile is the same as ${kernel}
kernel_versions="${kernel_versions}${kernel}___${prefix}/lib/modules/${kernel}/build/ "
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
# create development package
if [[ "${devel}" ]]; then
print_rpmtemplate_per_kmoddevelpkg --custom "${kernel}"
fi
else
error_out 2 "Don't know how to handle ${kernel} -- ${prefix}/lib/modules/${kernel}/build/Makefile not found"
fi
done
# create common development package
if [[ "${devel}" ]]; then
print_rpmtemplate_kmoddevelpkg "${1}"
fi
# well, it's no header anymore, but who cares ;-)
print_rpmtemplate_header
}
print_rpmtemplate ()
{
# create kernel_versions var
for kernel_version in ${kernel_versions_to_build_for}
do
kernel_versions="${kernel_versions}${kernel_version}___%{_usrsrc}/kernels/${kernel_version} "
done
# and print it and some other required stuff as macro
print_rpmtemplate_header
# now print the packages itselfs
for kernel in ${kernel_versions_to_build_for} ; do
local kernel_verrelarch=${kernel%%${kernels_known_variants}}
# create metapackage
print_rpmtemplate_kmodmetapkg ${kernel} ${kernel##${kernel_verrelarch}}
# create package
print_rpmtemplate_per_kmodpkg ${kernel} ${kernel##${kernel_verrelarch}}
# create development package
if [[ "${devel}" ]]; then
print_rpmtemplate_per_kmoddevelpkg ${kernel} ${kernel##${kernel_verrelarch}}
fi
done
# create common development package
if [[ "${devel}" ]]; then
print_rpmtemplate_kmoddevelpkg "${1}"
fi
}
myprog_help ()
{
echo "Usage: $(basename ${0}) [OPTIONS]"
echo $'\n'"Creates a template to be used during kmod building"
echo $'\n'"Available options:"
# FIXME echo " --datadir <dir> -- look for our shared files in <dir>"
echo " --filterfile <file> -- filter the results with grep --file <file>"
echo " --for-kernels <list> -- created templates only for these kernels"
echo " --kmodname <file> -- name of the kmod (required)"
echo " --devel -- make kmod-devel package"
echo " --noakmod -- no akmod package"
echo " --repo <name> -- use buildsys-build-<name>-kerneldevpkgs"
echo " --target <arch> -- target-arch (required)"
}
while [ "${1}" ] ; do
case "${1}" in
--filterfile)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
elif [[ ! -e "${1}" ]]; then
error_out 2 "Filterfile ${1} not found" >&2
fi
filterfile="${1}"
shift
;;
--kmodname)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
fi
# strip pending -kmod
kmodname="${1%%-kmod}"
shift
;;
--devel)
shift
devel="true"
;;
--prefix)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide a prefix with --prefix" >&2
fi
prefix="${1}"
shift
;;
--repo)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide the name of the repo together with --repo" >&2
fi
repo=${1}
shift
;;
--for-kernels)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
fi
for_kernels="${1}"
shift
;;
--noakmod)
shift
noakmod="true"
;;
--obsolete-name)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide the name of the kmod to obsolte together with --obsolete-name" >&2
fi
obsolete_name="${1}"
shift
;;
--obsolete-version)
shift
if [[ ! "${1}" ]] ; then
error_out 2 "Please provide the version of the kmod to obsolte together with --obsolete-version" >&2
fi
obsolete_version="${1}"
shift
;;
--target)
shift
target="${1}"
shift
;;
--akmod)
shift
build_kernels="akmod"
;;
--newest)
shift
build_kernels="newest"
;;
--current)
shift
build_kernels="current"
;;
--help)
myprog_help
exit 0
;;
--version)
echo "${myprog} ${myver}"
exit 0
;;
*)
echo "Error: Unknown option '${1}'." >&2
usage >&2
exit 2
;;
esac
done
if [[ -e ./kmodtool-kernel-variants ]]; then
kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then
kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
else
kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)"
fi
# general sanity checks
if [[ ! "${target}" ]]; then
error_out 2 "please pass target arch with --target"
elif [[ ! "${kmodname}" ]]; then
error_out 2 "please pass kmodname with --kmodname"
elif [[ ! "${kernels_known_variants}" ]] ; then
error_out 2 "could not determine known variants"
elif ( [[ "${obsolete_name}" ]] && [[ ! "${obsolete_version}" ]] ) || ( [[ ! "${obsolete_name}" ]] && [[ "${obsolete_version}" ]] ) ; then
error_out 2 "you need to provide both --obsolete-name and --obsolete-version"
fi
# go
if [[ "${for_kernels}" ]]; then
# this is easy:
print_customrpmtemplate "${for_kernels}"
elif [[ "${build_kernels}" == "akmod" ]]; then
# do only a akmod package
print_akmodtemplate
print_akmodmeta
else
# seems we are on out own to decide for which kernels to build
# we need more sanity checks in this case
if [[ ! "${repo}" ]]; then
error_out 2 "please provide repo name with --repo"
elif ! $(which buildsys-build-${repo}-kerneldevpkgs &> /dev/null) ; then
error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
fi
# call buildsys-build-${repo}-kerneldevpkgs to get the list of kernels
cmdoptions="--target ${target}"
# filterfile to filter list of kernels?
if [[ "${filterfile}" ]] ; then
cmdoptions="${cmdoptions} --filterfile ${filterfile}"
fi
kernel_versions_to_build_for="$(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
returncode=$?
if (( ${returncode} != 0 )); then
error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: $(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
fi
if [[ "${build_kernels}" == "current" ]] && [[ ! "${noakmod}" ]]; then
print_akmodtemplate
fi
print_rpmtemplate
fi

View File

@ -1,658 +0,0 @@
# The following block is used to allow the source RPM to be rebuilt
# against specific kernels. It is preferable that rpmbuild define the
# require_kver, require_kdir, require_obj constants for us, but if it does not
# not we attempt to determine the correct values based on your distro.
# kdir: Full path to the kernel source headers
# kobj: Full path to the kernel build objects
# kver: Kernel version
# kpkg: Kernel package name
# kdevpkg: Kernel devel package name
# kverpkg: Kernel package version
%if %{defined require_kver}
%define kver %{require_kver}
%endif
%if %{defined require_kdir}
%define kdir %{require_kdir}
%endif
%if %{defined require_kobj}
%define kobj %{require_kobj}
%endif
# Set using 'rpmbuild ... --with kernel ...', defaults to enabled.
%if %{defined _with_kernel}
%define with_kernel 1
%else
%if %{defined _without_kernel}
%define with_kernel 0
%else
%define with_kernel 1
%endif
%endif
# Set using 'rpmbuild ... --with kernel-debug ...', defaults to disabled.
%if %{defined _with_kernel_debug}
%define with_kernel_debug 1
%else
%if %{defined _without_kernel_debug}
%define with_kernel_debug 0
%else
%define with_kernel_debug 0
%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
%else
%if %{defined _without_debug}
%define kdebug --disable-debug
%else
%define kdebug --disable-debug
%endif
%endif
# Set using 'rpmbuild ... --with debug-dmu-tx ...', defaults to disabled.
%if %{defined _with_debug_dmu_tx}
%define kdebug_dmu_tx --enable-debug-dmu-tx
%else
%if %{defined _without_debug_dmu_tx}
%define kdebug_dmu_tx --disable-debug-dmu-tx
%else
%define kdebug_dmu_tx --disable-debug-dmu-tx
%endif
%endif
# SLES:
%if %{defined suse_version}
%if %{undefined kver}
%ifarch ppc64
%define kverextra ppc64
%else
%define kverextra default
%endif
%if %{suse_version} >= 1100
%define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
%define krelease %{klnk}/include/config/kernel.release
%else
%define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
%define krelease %{klnk}/.kernelrelease
%endif
%define kver_kern %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1)
%define kver_dbug %{nil}
%else
%define kver_kern %{kver}
%define kver_dbug %{nil}
%endif
%if %{undefined kverextra}
%define kverextra %(echo %{kver_kern} | cut -f3 -d'-')
%endif
%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
%if %{suse_version} >= 1100
%define koppkg >=
%else
%define koppkg =
%endif
%if %{undefined kdir}
%define kdir_kern %{_usrsrc}/linux-%{kverpkg_kern}
%define kdir_dbug %{nil}
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{nil}
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}-obj/%{_target_cpu}/%{kverextra}
%define kobj_dbug %{nil}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{nil}
%endif
%else
# RHEL 5.x/6.x, CHAOS 5.x:
%if %{defined el5} || %{defined el6} || %{defined ch5}
%if %{undefined kver}
%define klnk %{_usrsrc}/kernels/*/include/config
%define kver_kern %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} -v debug)) | tail -1)
%define kver_dbug %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} debug)) | tail -1)
%else
%define kver_kern %{kver}
%define kver_dbug %{kver}.debug
%endif
%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')
%else
%define kverpkg_kern %{kver_kern}
%define kverpkg_dbug %{kver_dbug}
%endif
%define koppkg =
%if %{undefined kdir}
%if %{defined el6} || %{defined ch5}
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
%else
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}-%{_target_cpu}
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}-%{_target_cpu}
%endif
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{kdir}.debug
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}
%define kobj_dbug %{kdir_dbug}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{kobj}.debug
%endif
%else
# Fedora:
%if %{defined fedora}
%if %{undefined kver}
%define klnk %{_usrsrc}/kernels/*/include/config
%define kver_kern %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} -v debug)) | tail -1)
%define kver_dbug %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} debug)) | tail -1)
%else
%define kver_kern %{kver}
%define kver_dbug %{kver}.debug
%endif
%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 koppkg =
%if %{undefined kdir}
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{kdir}.debug
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}
%define kobj_dbug %{kdir_dbug}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{kobj}.debug
%endif
%else
# Unsupported distro:
%if %{undefined kver}
%define kver_kern %(uname -r)
%define kver_dbug %{nil}
%else
%define kver_kern %{kver}
%define kver_dbug %{nil}
%endif
%define kverpkg_kern %{kver_kern}
%define kverpkg_dbug %{nil}
%define kverpkg_dkms %{nil}
%if %{undefined kdir}
%define kdir_kern /lib/modules/%{kver_kern}/build
%define kdir_dbug %{nil}
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{nil}
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}
%define kobj_dbug %{nil}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{nil}
%endif
%endif
%endif
%endif
# spldir: Full path to the spl source headers
# splobj: Full path to the spl build objects
# splver: Spl version
# splpkg: Spl package name
# spldevpkg: Spl devel package name
# splverpkg: Spl package version
%if %{defined require_splver}
%define splver %{require_splver}
%endif
%if %{defined require_spldir}
%define spldir %{require_spldir}
%endif
%if %{defined require_splobj}
%define splobj %{require_splobj}
%endif
%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
# Distro agnostic:
%define name @PACKAGE@-modules
%define version @VERSION@
# The kernel version should only be appended to a binary RPM. When
# building a source RPM it must be kernel version agnostic. This means
# the source RPM must never specify a required kernel version, but the
# final RPM should be keyed to the kernel version it was built against.
%if %{defined build_src_rpm}
%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}
%endif
%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
%define relext_kern %(echo %{kverpkg_kern} | %{__sed} -e 's/-/_/g')
%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}
%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
%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
Summary: ZFS File System
Group: Utilities/System
Name: %{name}
Version: %{version}
Release: %{rel_kern}
License: @ZFS_META_LICENSE@
URL: git://github.com/zfsonlinux/zfs.git
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
Source: @PACKAGE@-%{version}.tar.gz
%if %{?with_kernel}
%if %{defined req_kern}
Requires: %{req_kern}
%endif
%if %{defined kdevpkg_kern}
BuildRequires: %{kdevpkg_kern}
%endif
%if %{defined splreq_kern}
Requires: %{splreq_kern}
%endif
%if %{defined spldevpkg_kern}
BuildRequires: %{spldevpkg_kern}
%endif
Provides: lustre-backend-fs
%endif
%description
The %{name} package contains kernel modules and support utilities for
the %{name} file system.
%if %{?with_kernel}
%package devel
Summary: ZFS File System Headers and Symbols
Group: Development/Libraries
Release: %{rel_kern}
%if %{defined devreq_kern}
Requires: %{devreq_kern}
%endif
%if %{defined kdevpkg_kern}
BuildRequires: %{kdevpkg_kern}
%endif
%if %{defined spldevreq_kern}
Requires: %{spldevreq_kern}
%endif
%if %{defined spldevpkg_kern}
BuildRequires: %{spldevpkg_kern}
%endif
%description devel
The %{name}-devel package contains the kernel header files and
Module.symvers symbols needed for building additional modules
which use %{name}.
%endif
%if %{?with_kernel_debug}
%package debug
Summary: ZFS File System (Debug)
Group: Utilities/System
Release: %{rel_dbug}
%if %{defined req_dbug}
Requires: %{req_dbug}
%endif
%if %{defined kdevpkg_dbug}
BuildRequires: %{kdevpkg_dbug}
%endif
%if %{defined splreq_dbug}
Requires: %{splreq_dbug}
%endif
%if %{defined spldevpkg_dbug}
BuildRequires: %{spldevpkg_dbug}
%endif
Provides: lustre-backend-fs
%description debug
The %{name}-debug package contains debug kernel modules and support
utilities for the %{name} file system.
%package debug-devel
Summary: ZFS File System Headers and Symbols (Debug)
Group: Development/Libraries
Release: %{rel_dbug}
%if %{defined devreq_dbug}
Requires: %{devreq_dbug}
%endif
%if %{defined kdevpkg_dbug}
BuildRequires: %{kdevpkg_dbug}
%endif
%if %{defined spldevreq_dbug}
Requires: %{spldevreq_dbug}
%endif
%if %{defined spldevpkg_dbug}
BuildRequires: %{spldevpkg_dbug}
%endif
%description debug-devel
The %{name}-debug-devel package contains the debug kernel header files
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}
%build
rm -rf $RPM_BUILD_ROOT
%if %{with_kernel}
%configure --with-linux=%{kdir_kern} --with-linux-obj=%{kobj_kern} \
--with-spl=%{spldir_kern} --with-spl-obj=%{splobj_kern} \
--with-config=kernel %{kdebug} %{kdebug_dmu_tx}
make
make DESTDIR=$RPM_BUILD_ROOT install
%endif
%if %{?with_kernel_debug}
%configure --with-linux=%{kdir_dbug} --with-linux-obj=%{kobj_dbug} \
--with-spl=%{spldir_dbug} --with-spl-obj=%{splobj_dbug} \
--with-config=kernel %{kdebug} %{kdebug_dmu_tx}
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
%if %{?with_kernel}
%files
%defattr(-, root, root)
/lib/modules/%{kver_kern}/*
%files devel
%defattr(-,root,root)
%{_prefix}/src/*/%{kver_kern}
%post
if [ -f /boot/System.map-%{kver_kern} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_kern} %{kver_kern} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun
if [ -f /boot/System.map-%{kver_kern} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_kern} %{kver_kern} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun devel
rmdir %{_prefix}/src/@PACKAGE@-%{version}-@ZFS_META_RELEASE@ 2>/dev/null
exit 0
%endif
%if %{?with_kernel_debug}
%files debug
%defattr(-, root, root)
/lib/modules/%{kver_dbug}/*
%files debug-devel
%defattr(-,root,root)
%{_prefix}/src/*/%{kver_dbug}
%post debug
if [ -f /boot/System.map-%{kver_dbug} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_dbug} %{kver_dbug} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun debug
if [ -f /boot/System.map-%{kver_dbug} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_dbug} %{kver_dbug} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun debug-devel
rmdir %{_prefix}/src/@PACKAGE@-%{version}-@ZFS_META_RELEASE@ 2>/dev/null
exit 0
%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

View File

@ -1,110 +0,0 @@
%define name @PACKAGE@
%define version @VERSION@
%define release @ZFS_META_RELEASE@
%define debug_package %{nil}
%define _sbindir /sbin
%define _libdir /%{_lib}
%define _udevdir /lib/udev
%define _dracutdir %{_datadir}/dracut
Summary: ZFS Library and Utils
Group: Utilities/System
Name: %{name}
Version: %{version}
Release: %{release}%{?dist}
License: @ZFS_META_LICENSE@
URL: git://github.com/zfsonlinux/zfs.git
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
Source: %{name}-%{version}.tar.gz
Requires: zfs-modules spl zlib e2fsprogs
BuildRequires: zlib-devel e2fsprogs-devel
%description
The %{name} package contains the libzfs library and support utilities
for the zfs file system.
%package devel
Summary: ZFS File System User Headers
Group: Development/Libraries
%if %{defined ch5} || %{defined el6} || %{defined fc12}
Requires: zfs zlib libuuid libblkid
BuildRequires: zlib-devel libuuid-devel libblkid-devel
%else
Requires: zfs zlib e2fsprogs
BuildRequires: zlib-devel e2fsprogs-devel
%endif
%description devel
The %{name}-devel package contains the header files needed for building
additional applications against the %{name} libraries.
%package test
Summary: ZFS File System Test Infrastructure
Group: Utilities/System
Requires: zfs parted lsscsi mdadm bc
%description test
The %{name}-test package contains a test infrastructure for zpios which
can be used to simplfy the benchmarking of various hardware and software
configurations. The test infrastructure additionally integrates with
various system profiling tools to facilitate an in depth analysis.
%package dracut
Summary: ZFS Dracut Module
Group: System Environment/Base
Requires: zfs dracut
%description dracut
The %{name}-dracut package allows dracut to construct initramfs images
which are ZFS aware.
%prep
%setup
%build
%configure --with-config=user \
--without-blkid \
--with-udevdir=%{_udevdir} \
--with-dracutdir=%{_dracutdir}
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%{_sbindir}/*
%{_libdir}/*
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*
%{_udevdir}/*
%config %{_sysconfdir}/init.d/*
%config %{_sysconfdir}/zfs/*
%doc AUTHORS COPYING COPYRIGHT DISCLAIMER
%doc OPENSOLARIS.LICENSE README.markdown
%files devel
%defattr(-,root,root)
%{_includedir}/*
%files test
%defattr(-,root,root)
%{_datadir}/@PACKAGE@/*
%files dracut
%defattr(-,root,root)
%{_dracutdir}/*
%post
[ -x /sbin/chkconfig ] && /sbin/chkconfig --add zfs
exit 0
%preun
[ "$1" = 0 ] && [ -x /sbin/chkconfig ] && /sbin/chkconfig --del zfs
exit 0