Support debug and debug-devel sub packages
This commit adds support for building debug and debug-devel sub packages of the spl-modules main package. This is to allow building packages which are built against a debug kernel. By default, only packages are built against a regular non-debug kernel. This can be toggled by passing the '--with kernel-debug' parameter to rpmbuild. Examples: # To build packages against only the non-debug kernel $ rpmbuild --rebuild --with kernel --without kernel-debug $SRPM # To build packages against only the debug kernel $ rpmbuild --rebuild --without kernel --with kernel-debug $SRPM # To build packages against debug and non-debug kernel $ rpmbuild --rebuild --with kernel --with kernel-debug $SRPM Note: Only the RHEL 5/6, CHAOS 5, and Fedora distributions are supported for building the debug and debug-devel packages. Signed-off-by: Prakash Surya <surya1@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #115
This commit is contained in:
parent
44e406d712
commit
92c2f755ee
|
@ -22,6 +22,28 @@
|
|||
%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 debug ...', defaults to disabled.
|
||||
%if %{defined _with_debug}
|
||||
%define kdebug --enable-debug
|
||||
|
@ -83,16 +105,25 @@
|
|||
%define krelease %{klnk}/.kernelrelease
|
||||
%endif
|
||||
|
||||
%define kver %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1)
|
||||
%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} | cut -f3 -d'-')
|
||||
%define kverextra %(echo %{kver_kern} | cut -f3 -d'-')
|
||||
%endif
|
||||
|
||||
%define kpkg kernel-%{kverextra}
|
||||
%define kdevpkg kernel-source
|
||||
%define kverpkg %(echo %{kver} | %{__sed} -e 's/-%{kverextra}//g')
|
||||
%define kpkg_kern kernel-%{kverextra}
|
||||
%define kpkg_dbug %{nil}
|
||||
|
||||
%define kdevpkg_kern kernel-source
|
||||
%define kdevpkg_dbug %{nil}
|
||||
|
||||
%define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/-%{kverextra}//g')
|
||||
%define kverpkg_dbug %{nil}
|
||||
|
||||
# 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
|
||||
|
@ -103,10 +134,19 @@
|
|||
%endif
|
||||
|
||||
%if %{undefined kdir}
|
||||
%define kdir %{_usrsrc}/linux-%{kverpkg}
|
||||
%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 %{kdir}-obj/%{_target_cpu}/%{kverextra}
|
||||
%define kobj_kern %{kdir_kern}-obj/%{_target_cpu}/%{kverextra}
|
||||
%define kobj_dbug %{nil}
|
||||
%else
|
||||
%define kobj_kern %{kobj}
|
||||
%define kobj_dbug %{nil}
|
||||
%endif
|
||||
%else
|
||||
|
||||
|
@ -114,18 +154,39 @@
|
|||
%if %{defined ch4}
|
||||
%if %{undefined kver}
|
||||
%define klnk %{_usrsrc}/kernels/*/include/config
|
||||
%define kver %((echo X; %{__cat} %{klnk}/kernel.release
|
||||
%define kver_kern %((echo X; %{__cat} %{klnk}/kernel.release
|
||||
2>/dev/null) | tail -1)
|
||||
%define kver_dbug %{nil}
|
||||
%else
|
||||
%define kver_kern %{kver}
|
||||
%define kver_dbug %{nil}
|
||||
%endif
|
||||
%define kpkg chaos-kernel
|
||||
%define kdevpkg chaos-kernel-devel
|
||||
%define kverpkg %{kver}
|
||||
|
||||
%define kpkg_kern chaos-kernel
|
||||
%define kpkg_dbug %{nil}
|
||||
|
||||
%define kdevpkg_kern chaos-kernel-devel
|
||||
%define kdevpkg_dbug %{nil}
|
||||
|
||||
%define kverpkg_kern %{kver_kern}
|
||||
%define kverpkg_dbug %{nil}
|
||||
|
||||
%define koppkg =
|
||||
|
||||
%if %{undefined kdir}
|
||||
%define kdir %{_usrsrc}/kernels/%{kver}
|
||||
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
|
||||
%define kdir_dbug %{nil}
|
||||
%else
|
||||
%define kdir_kern %{kdir}
|
||||
%define kdir_dbug %{nil}
|
||||
%endif
|
||||
|
||||
%if %{undefined kobj}
|
||||
%define kobj %{kdir}
|
||||
%define kobj_kern %{kdir_kern}
|
||||
%define kobj_dbug %{nil}
|
||||
%else
|
||||
%define kobj_kern %{kobj}
|
||||
%define kobj_dbug %{nil}
|
||||
%endif
|
||||
%else
|
||||
|
||||
|
@ -133,26 +194,50 @@
|
|||
%if %{defined el5} || %{defined el6} || %{defined ch5}
|
||||
%if %{undefined kver}
|
||||
%define klnk %{_usrsrc}/kernels/*/include/config
|
||||
%define kver %((echo X; %{__cat} %{klnk}/kernel.release
|
||||
2>/dev/null) | tail -1)
|
||||
%endif
|
||||
%define kpkg kernel
|
||||
%define kdevpkg kernel-devel
|
||||
%if %{defined el6} || %{defined ch5}
|
||||
%define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g')
|
||||
%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 kverpkg %{kver}
|
||||
%define kver_kern %{kver}
|
||||
%define kver_dbug %{kver}.debug
|
||||
%endif
|
||||
|
||||
%define kpkg_kern kernel
|
||||
%define kpkg_dbug kernel-debug
|
||||
|
||||
%define kdevpkg_kern kernel-devel
|
||||
%define kdevpkg_dbug kernel-debug-devel
|
||||
|
||||
%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 %{_usrsrc}/kernels/%{kver}
|
||||
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
|
||||
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
|
||||
%else
|
||||
%define kdir %{_usrsrc}/kernels/%{kver}-%{_target_cpu}
|
||||
%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 %{kdir}
|
||||
%define kobj_kern %{kdir_kern}
|
||||
%define kobj_dbug %{kdir_dbug}
|
||||
%else
|
||||
%define kobj_kern %{kobj}
|
||||
%define kobj_dbug %{kobj}.debug
|
||||
%endif
|
||||
%else
|
||||
|
||||
|
@ -160,31 +245,69 @@
|
|||
%if %{defined fedora}
|
||||
%if %{undefined kver}
|
||||
%define klnk %{_usrsrc}/kernels/*/include/config
|
||||
%define kver %((echo X; %{__cat} %{klnk}/kernel.release
|
||||
2>/dev/null) | tail -1)
|
||||
%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 kernel
|
||||
%define kdevpkg kernel-devel
|
||||
%define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g')
|
||||
|
||||
%define kpkg_kern kernel
|
||||
%define kpkg_dbug kernel-debug
|
||||
|
||||
%define kdevpkg_kern kernel-devel
|
||||
%define kdevpkg_dbug kernel-debug-devel
|
||||
|
||||
%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 %{_usrsrc}/kernels/%{kver}
|
||||
%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 %{kdir}
|
||||
%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 %(uname -r)
|
||||
%define kver_kern %(uname -r)
|
||||
%define kver_dbug %{nil}
|
||||
%else
|
||||
%define kver_kern %{kver}
|
||||
%define kver_dbug %{nil}
|
||||
%endif
|
||||
%define kverpkg %{kver}
|
||||
|
||||
%define kverpkg_kern %{kver_kern}
|
||||
%define kverpkg_dbug %{nil}
|
||||
|
||||
%if %{undefined kdir}
|
||||
%define kdir /lib/modules/%{kver}/build
|
||||
%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 %{kdir}
|
||||
%define kobj_kern %{kdir_kern}
|
||||
%define kobj_dbug %{nil}
|
||||
%else
|
||||
%define kobj_kern %{kobj}
|
||||
%define kobj_dbug %{nil}
|
||||
%endif
|
||||
|
||||
%endif
|
||||
|
@ -195,43 +318,65 @@
|
|||
# Distro agnostic:
|
||||
%define name @PACKAGE@-modules
|
||||
%define version @VERSION@
|
||||
%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. 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 release @SPL_META_RELEASE@
|
||||
%define requires %{kpkg}
|
||||
%if %{defined kdevpkg}
|
||||
%define devel_requires %{kdevpkg}
|
||||
%define rel_kern @SPL_META_RELEASE@
|
||||
%define rel_dbug @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 kdevpkg_kern}
|
||||
%define devreq_kern %{kdevpkg_kern}
|
||||
%endif
|
||||
%if %{defined kdevpkg_dbug}
|
||||
%define devreq_dbug %{kdevpkg_dbug}
|
||||
%endif
|
||||
%else
|
||||
%define relext %(echo %{kverpkg} | %{__sed} -e 's/-/_/g')
|
||||
%define release @SPL_META_RELEASE@_%{relext}
|
||||
%if %{defined kpkg}
|
||||
%define krequires %{kpkg} %{koppkg} %{kverpkg}
|
||||
%define relext_kern %(echo %{kverpkg_kern} | %{__sed} -e 's/-/_/g')
|
||||
%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}
|
||||
%if %{defined kpkg_kern}
|
||||
%define req_kern %{kpkg_kern} %{koppkg} %{kverpkg_kern}
|
||||
%endif
|
||||
%if %{defined kdevpkg}
|
||||
%define devel_requires %{kdevpkg} %{koppkg} %{kverpkg}
|
||||
%if %{defined kpkg_dbug}
|
||||
%define req_dbug %{kpkg_dbug} %{koppkg} %{kverpkg_dbug}
|
||||
%endif
|
||||
%if %{defined kdevpkg_kern}
|
||||
%define devreq_kern %{kdevpkg_kern} %{koppkg} %{kverpkg_kern}
|
||||
%endif
|
||||
%if %{defined kdevpkg_dbug}
|
||||
%define devreq_dbug %{kdevpkg_dbug} %{koppkg} %{kverpkg_dbug}
|
||||
%endif
|
||||
%endif
|
||||
|
||||
|
||||
Summary: Solaris Porting Layer Modules
|
||||
Group: Utilities/System
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Release: %{rel_kern}
|
||||
License: @LICENSE@
|
||||
URL: git://github.com/zfsonlinux/spl.git
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
|
||||
Source: @PACKAGE@-%{version}.tar.gz
|
||||
%if %{defined krequires}
|
||||
Requires: %{krequires}
|
||||
|
||||
%if %{?with_kernel}
|
||||
|
||||
%if %{defined req_kern}
|
||||
Requires: %{req_kern}
|
||||
%endif
|
||||
%if %{defined kdevpkg}
|
||||
BuildRequires: %{kdevpkg}
|
||||
%if %{defined kdevpkg_kern}
|
||||
BuildRequires: %{kdevpkg_kern}
|
||||
%endif
|
||||
|
||||
%endif
|
||||
|
||||
%description
|
||||
|
@ -240,52 +385,135 @@ primatives in the linux kernel. These include, but are not limited to:
|
|||
atomic, condvar, debug, error, memory, kobject, kstat, mutex, rwlock,
|
||||
taskq, thread, time, and vnode APIs.
|
||||
|
||||
%if %{?with_kernel}
|
||||
|
||||
%package devel
|
||||
Summary: Solaris Porting Layer Headers and Symbols
|
||||
Group: Development/Libraries
|
||||
%if %{defined devel_requires}
|
||||
Requires: %{devel_requires}
|
||||
Release: %{rel_kern}
|
||||
%if %{defined devreq_kern}
|
||||
Requires: %{devreq_kern}
|
||||
%endif
|
||||
%if %{defined kdevpkg}
|
||||
BuildRequires: %{kdevpkg}
|
||||
%if %{defined kdevpkg_kern}
|
||||
BuildRequires: %{kdevpkg_kern}
|
||||
%endif
|
||||
|
||||
%description devel
|
||||
The %{name}-devel package contains the header files and Module{s}.symvers
|
||||
symbols needed for building additional modules which use %{name}.
|
||||
|
||||
%endif
|
||||
%if %{?with_kernel_debug}
|
||||
|
||||
%package debug
|
||||
Summary: Solaris Porting Layer Debug Modules
|
||||
Group: Utilities/System
|
||||
Release: %{rel_dbug}
|
||||
%if %{defined req_dbug}
|
||||
Requires: %{req_dbug}
|
||||
%endif
|
||||
%if %{defined kdevpkg_dbug}
|
||||
BuildRequires: %{kdevpkg_dbug}
|
||||
%endif
|
||||
|
||||
%description debug
|
||||
The %{name}-debug package contains kernel modules for emulating Solaris
|
||||
style primatives in the linux kernel. These include, but are not limited
|
||||
to: atomic, condvar, debug, error, memory, kobject, kstat, mutex,
|
||||
rwlock, taskq, thread, time, and vnode APIs.
|
||||
|
||||
%package debug-devel
|
||||
Summary: Solaris Porting Layer Debug Headers and Symbols
|
||||
Group: Development/Libraries
|
||||
Release: %{rel_dbug}
|
||||
%if %{defined devreq_dbug}
|
||||
Requires: %{devreq_dbug}
|
||||
%endif
|
||||
%if %{defined kdevpkg_dbug}
|
||||
BuildRequires: %{kdevpkg_dbug}
|
||||
%endif
|
||||
|
||||
%description debug-devel
|
||||
The %{name}-debug-devel package contains the header files and
|
||||
Module{s}.symvers symbols needed for building additional modules which
|
||||
use %{name}-debug.
|
||||
|
||||
%endif
|
||||
|
||||
%prep
|
||||
%setup -n @PACKAGE@-%{version}
|
||||
%build
|
||||
%configure --with-linux=%{kdir} --with-linux-obj=%{kobj} --with-config=kernel \
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%if %{?with_kernel}
|
||||
|
||||
%configure --with-config=kernel \
|
||||
--with-linux=%{kdir_kern} --with-linux-obj=%{kobj_kern} \
|
||||
%{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
|
||||
%endif
|
||||
%if %{?with_kernel_debug}
|
||||
|
||||
%configure --with-config=kernel \
|
||||
--with-linux=%{kdir_dbug} --with-linux-obj=%{kobj_dbug} \
|
||||
%{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
|
||||
make
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
|
||||
%endif
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%if %{?with_kernel}
|
||||
|
||||
%files
|
||||
%defattr(-, root, root)
|
||||
/lib/modules/*
|
||||
/lib/modules/%{kver_kern}/*
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
%{_prefix}/src/*
|
||||
%{_prefix}/src/*/%{kver_kern}/*
|
||||
|
||||
%post
|
||||
if [ -f /boot/System.map-%{kver} ]; then
|
||||
/sbin/depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
|
||||
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} ]; then
|
||||
/sbin/depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
|
||||
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
|
||||
|
||||
%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
|
||||
|
||||
%endif
|
||||
|
|
Loading…
Reference in New Issue