From 31b2e0b070d99681d189951557d2344dc2b63dbf Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 25 Jun 2009 15:31:53 -0700 Subject: [PATCH] Packaging Fixes - Kernel modules should be built using the LINUX_OBJ Makefiles and not the LINUX Makefiles to ensure the proper install paths are used. - Install modules in to addon/spl/ - Ensure no additional kernel module build products are packaged. - Simplified spl.spec.in which supports RHEL, CHAOS, SLES, FEDORA. --- module/Makefile.in | 8 +-- spl.spec.in | 120 ++++++++++++++++++++++++++------------------- 2 files changed, 74 insertions(+), 54 deletions(-) diff --git a/module/Makefile.in b/module/Makefile.in index b93a1d769..4368f7142 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -4,11 +4,13 @@ subdir-m += splat INSTALL=/usr/bin/install modules clean: - $(MAKE) -C @LINUX@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ + $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ modules_install: - $(MAKE) -C @LINUX@ SUBDIRS=`pwd` \ - INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=addon $@ + $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` \ + INSTALL_MOD_PATH=$(DESTDIR) \ + INSTALL_MOD_DIR=addon/spl $@ + find ${DESTDIR}/lib/modules/ -name 'modules.*' | xargs ${RM} distdir: list='$(subdir-m)'; for subdir in $$list; do \ diff --git a/spl.spec.in b/spl.spec.in index e67408dd7..ac4b9e78d 100644 --- a/spl.spec.in +++ b/spl.spec.in @@ -1,71 +1,89 @@ # The following block is used to allow the source RPM to be rebuilt -# against arbitrary kernels. It ensure the release name is correct -# and the proper build/install requires are set. +# 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. -# When require_kdir is defined we do one of two things: -# require_kver: Ideally defined to match the kernel. -# !require_kver: A best guess is made. -%if 0%{?require_kdir:1} -%if 0%{?require_kver:1} -%define kver %{require_kver} -%define kdir %{require_kdir} +%{?require_kver: %define kver %{require_kver}} +%{?require_kdir: %define kdir %{require_kdir}} +%{?require_kobj: %define kobj %{require_kobj}} + +# 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 + +# SLES*: +%if %{defined sles_version} + %if %{undefined kver} + %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{_target_cpu} + %define kver %(%{__cat} %{klnk}/.kernelrelease) + %endif + %define kpkg kernel-%{_target_cpu} + %define kdevpkg kernel-source kernel-syms + %define kverpkg %(echo %{kver} | cut -d'-' -f1-2) + %{!?kdir: %define kdir %{_usrsrc}/linux-%{kverpkg}} + %{!?kobj: %define kobj %{kdir}-obj/%{_target_cpu}/%{_target_cpu}} + +# CHAOS4: %else -%{!?require_kobj: %define require_kobj %{require_kdir}} -%define kdir %{require_kdir} -%define kuts %{require_kobj}/include/linux/utsrelease.h \ - %{require_kobj}/include/linux/version.h -%define kver %((grep UTS_RELEASE %{kuts}) | cut -f2 -d'"' | tail -1) +%if %{defined ch4} + %if %{undefined kver} + %define klnk %{_usrsrc}/kernels/*/include/config + %define kver %((%{__cat} %{klnk}/kernel.release) | tail -1) + %endif + %define kpkg chaos-kernel + %define kdevpkg chaos-kernel-devel + %define kverpkg %{kver} + %{!?kdir: %define kdir %{_usrsrc}/kernels/%{kver}} + %{!?kobj: %define kobj %{kdir}} + +# RHEL*/Fedora: +%else +%if %{defined fedora} || %{defined rhel} + %if %{undefined kver} + %define klnk %{_usrsrc}/kernels/*/include/config + %define kver %((%{__cat} %{klnk}/kernel.release) | tail -1) + %endif + %define kpkg kernel + %define kdevpkg kernel-devel + %define kverpkg %(echo %{kver} | cut -d'.' -f1-7) + %{!?kdir: %define kdir %{_usrsrc}/kernels/%{kver}} + %{!?kobj: %define kobj %{kdir}} + +%else + +# Unsupported distro: +%{!?kver: %define kver unknown} +%define kpkg kernel +%define kdevpkg kernel-devel +%define kverpkg %{kver} +%{!?kdir: %define kdir %{_usrsrc}/kernels/%{kver}} +%{!?kobj: %define kobj %{kdir}} + %endif - -# When require_kdir is not defined we do one of two things: -# require_kver: Locate the requested kernel in default dirs. -# !require_kver: Locate the newest kernel in default dirs. -%else -%if 0%{?require_kver:1} -%define kver %{require_kver} -%define kdef %{_prefix}/src/kernels/%{kver} %{_prefix}/src/linux-%{kver} -%define kdir %((echo X; ls -1d %kdef 2>/dev/null)|sed -e 's/linux-//'|tail -1) -%else -%define kdef %{_prefix}/src/kernels/* %{_prefix}/src/linux-* -%define kdir %((echo X; ls -1d %kdef 2>/dev/null)|sed -e 's/linux-//'|tail -1) -%define kver %(basename %{kdir}) %endif %endif -# Kernel objects may not be located with the source. Assume -# that they are but allow this to be overrided if required. -%if 0%{?require_kobj:1} -%define kobj %{require_kobj} -%else -%define kobj %{kdir} -%endif - -# Each distro has its own kernel package naming convention. -%if 0%{?ch4} -%define kstr chaos-kernel -%define kdev chaos-kernel-devel -%else -%define kstr kernel -%define kdev kernel-devel -%endif - +# Distro agnostic: %define debug_package %{nil} -# The kernel version should only be appended to a binary RPM. -# When building a source RPM it must be kernel version agnostic. %define name @PACKAGE@ %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. %if %{?build_src_rpm:1}0 %define release @SPL_META_RELEASE@ %else -%define release @SPL_META_RELEASE@_%(echo %{kver} | sed -e 's/-/_/g') +%define release @SPL_META_RELEASE@_%(echo %{kverpkg} | %{__sed} -e 's/-/_/g') %endif %if 0%{?require_kver:1} -%define buildrequires %{kdev}=%{kver} +%define buildrequires %{kdevpkg}=%{kverpkg} %else -%define buildrequires %{kdev} +%define buildrequires %{kdevpkg} %endif Summary: Solaris Porting Layer @@ -77,7 +95,7 @@ License: GPL URL: git://eris.llnl.gov/spl.git BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) Source: %{name}-%{version}.tar.gz -Requires: %{kstr} = %{kver} +Requires: %{kpkg} = %{kverpkg} BuildRequires: %{buildrequires} %description @@ -89,7 +107,7 @@ kstat, mutex, rwlock, taskq, thread, time, and vnode APIs. %package devel Summary: Solaris Porting Layer Headers and Symbols Group: Development/Libraries -Requires: %{kstr} = %{kver} +Requires: %{kpkg} = %{kverpkg} BuildRequires: %{buildrequires} %description devel