From 0111acb46984e7167fa35d5401373b3811b8de8e Mon Sep 17 00:00:00 2001 From: Turbo Fredriksson Date: Tue, 7 Jul 2015 21:59:06 +0200 Subject: [PATCH] Only build the dracut package if /usr/lib/dracut exists. --- config/zfs-build.m4 | 12 +++++++++++- rpm/generic/zfs.spec.in | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index f93c5b5d4cca..0474bfd10b11 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -140,7 +140,7 @@ AC_DEFUN([ZFS_AC_RPM], [ ]) RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1" --define "$(DEBUG_DMU_TX) 1"' - RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)" --define "_udevdir $(udevdir)" --define "_udevruledir $(udevruledir)" --define "_initconfdir $(DEFAULT_INITCONF_DIR)" $(DEFINE_INITRAMFS)' + RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)" --define "_udevdir $(udevdir)" --define "_udevruledir $(udevruledir)" --define "_initconfdir $(DEFAULT_INITCONF_DIR)" $(DEFINE_INITRAMFS) $(DEFINE_DRACUT)' RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)" --define "require_spldir $(SPL)" --define "require_splobj $(SPL_OBJ)" --define "ksrc $(LINUX)" --define "kobj $(LINUX_OBJ)"' RPM_DEFINE_DKMS= @@ -334,6 +334,16 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ AC_MSG_RESULT([no]) fi AC_SUBST(DEFINE_INITRAMFS) + + AC_MSG_CHECKING([whether dracut is available]) + if test -d /usr/lib/dracut ; then + DEFINE_DRACUT='--define "_dracut 1"' + AC_MSG_RESULT([yes]) + else + DEFINE_DRACUT='' + AC_MSG_RESULT([no]) + fi + AC_SUBST(DEFINE_DRACUT) ]) dnl # diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index 6313f0bfb4b6..7415f87ce4f2 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -19,13 +19,19 @@ %endif %endif +%if 0%{?_dracut} # Set the default dracut directory based on distribution. %if %{undefined _dracutdir} %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7 -%global _dracutdir %{_prefix}/lib/dracut +%global _dracutopt --with-dracutdir=%{_prefix}/lib/dracut %else -%global _dracutdir %{_prefix}/share/dracut +%global _dracutopt --with-dracutdir=%{_prefix}/share/dracut %endif +%else +%global _dracutopt --with-dracutdir=%{_dracutdir} +%endif +%else +%global _dracutopt '' %endif # Set the default _initconfdir when undefined. @@ -184,6 +190,7 @@ Requires: bc This package contains test infrastructure and support scripts for validating the file system. +%if 0%{?_dracut} %package dracut Summary: Dracut module Group: System Environment/Kernel @@ -194,6 +201,7 @@ Requires: dracut %description dracut This package contains a dracut module used to construct an initramfs image which is ZFS aware. +%endif %if 0%{?_initramfs} %package initramfs @@ -232,8 +240,8 @@ image which is ZFS aware. --with-config=user \ --with-udevdir=%{_udevdir} \ --with-udevruledir=%{_udevruledir} \ - --with-dracutdir=%{_dracutdir} \ --disable-static \ + %{_dracutopt} \ %{debug} \ %{blkid} \ %{systemd} @@ -318,9 +326,13 @@ exit 0 %files test %{_datadir}/%{name} +%if 0%{?_dracut} %files dracut %doc contrib/dracut/README.dracut.markdown %{_dracutdir}/modules.d/* +%else +%exclude %{_dracutdir} +%endif %if 0%{?_initramfs} %files initramfs