3c208a5480
Allow a source rpm to be rebuilt with debugging enabled. This avoids the need to have to manually modify the spec file. By default debugging is still largely disabled. To enable specific debugging features use the following options with rpmbuild. '--with debug' - Enables ASSERTs '--with debug-log' - Enables the internal debug log '--with debug-kmem' - Enables basic memory accounting '--with debug-kmem-tracking' - Enables detailed memory tracking # For example: $ rpmbuild --rebuild --with debug spl-modules-0.6.0-rc6.src.rpm Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
292 lines
7.9 KiB
RPMSpec
292 lines
7.9 KiB
RPMSpec
# 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 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-log ...', defaults to enabled.
|
|
%if %{defined _with_debug_log}
|
|
%define kdebug_log --enable-debug-log
|
|
%else
|
|
%if %{defined _without_debug_log}
|
|
%define kdebug_log --disable-debug-log
|
|
%else
|
|
%define kdebug_log --enable-debug-log
|
|
%endif
|
|
%endif
|
|
|
|
# Set using 'rpmbuild ... --with debug-kmem ...', defaults to enabled.
|
|
%if %{defined _with_debug_kmem}
|
|
%define kdebug_kmem --enable-debug-kmem
|
|
%else
|
|
%if %{defined _without_debug_kmem}
|
|
%define kdebug_kmem --disable-debug-kmem
|
|
%else
|
|
%define kdebug_kmem --enable-debug-kmem
|
|
%endif
|
|
%endif
|
|
|
|
# Set using 'rpmbuild ... --with debug-tracking ...', defaults to disabled.
|
|
%if %{defined _with_debug_kmem_tracking}
|
|
%define kdebug_kmem_tracking --enable-debug-kmem-tracking
|
|
%else
|
|
%if %{defined _without_debug_kmem_tracking}
|
|
%define kdebug_kmem_tracking --disable-debug-kmem-tracking
|
|
%else
|
|
%define kdebug_kmem_tracking --disable-debug-kmem-tracking
|
|
%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 %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1)
|
|
%endif
|
|
|
|
%if %{undefined kverextra}
|
|
%define kverextra %(echo %{kver} | cut -f3 -d'-')
|
|
%endif
|
|
|
|
%define kpkg kernel-%{kverextra}
|
|
%define kdevpkg kernel-source
|
|
%define kverpkg %(echo %{kver} | %{__sed} -e 's/-%{kverextra}//g')
|
|
|
|
# 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 %{_usrsrc}/linux-%{kverpkg}
|
|
%endif
|
|
%if %{undefined kobj}
|
|
%define kobj %{kdir}-obj/%{_target_cpu}/%{kverextra}
|
|
%endif
|
|
%else
|
|
|
|
# CHAOS 4.x:
|
|
%if %{defined ch4}
|
|
%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 chaos-kernel
|
|
%define kdevpkg chaos-kernel-devel
|
|
%define kverpkg %{kver}
|
|
%define koppkg =
|
|
%if %{undefined kdir}
|
|
%define kdir %{_usrsrc}/kernels/%{kver}
|
|
%endif
|
|
%if %{undefined kobj}
|
|
%define kobj %{kdir}
|
|
%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 %((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')
|
|
%else
|
|
%define kverpkg %{kver}
|
|
%endif
|
|
%define koppkg =
|
|
%if %{undefined kdir}
|
|
%if %{defined el6} || %{defined ch5}
|
|
%define kdir %{_usrsrc}/kernels/%{kver}
|
|
%else
|
|
%define kdir %{_usrsrc}/kernels/%{kver}-%{_target_cpu}
|
|
%endif
|
|
%endif
|
|
%if %{undefined kobj}
|
|
%define kobj %{kdir}
|
|
%endif
|
|
%else
|
|
|
|
# Fedora:
|
|
%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)
|
|
%endif
|
|
%define kpkg kernel
|
|
%define kdevpkg kernel-devel
|
|
%define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g')
|
|
%define koppkg =
|
|
%if %{undefined kdir}
|
|
%define kdir %{_usrsrc}/kernels/%{kver}
|
|
%endif
|
|
%if %{undefined kobj}
|
|
%define kobj %{kdir}
|
|
%endif
|
|
%else
|
|
|
|
# Unsupported distro:
|
|
%if %{undefined kver}
|
|
%define kver %(uname -r)
|
|
%endif
|
|
%define kverpkg %{kver}
|
|
%if %{undefined kdir}
|
|
%define kdir /lib/modules/%{kver}/build
|
|
%endif
|
|
%if %{undefined kobj}
|
|
%define kobj %{kdir}
|
|
%endif
|
|
|
|
%endif
|
|
%endif
|
|
%endif
|
|
%endif
|
|
|
|
# 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}
|
|
%endif
|
|
%else
|
|
%define relext %(echo %{kverpkg} | %{__sed} -e 's/-/_/g')
|
|
%define release @SPL_META_RELEASE@_%{relext}
|
|
%if %{defined kpkg}
|
|
%define krequires %{kpkg} %{koppkg} %{kverpkg}
|
|
%endif
|
|
%if %{defined kdevpkg}
|
|
%define devel_requires %{kdevpkg} %{koppkg} %{kverpkg}
|
|
%endif
|
|
%endif
|
|
|
|
Summary: Solaris Porting Layer Modules
|
|
Group: Utilities/System
|
|
Name: %{name}
|
|
Version: %{version}
|
|
Release: %{release}
|
|
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}
|
|
%endif
|
|
%if %{defined kdevpkg}
|
|
BuildRequires: %{kdevpkg}
|
|
%endif
|
|
|
|
%description
|
|
The %{name} 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 devel
|
|
Summary: Solaris Porting Layer Headers and Symbols
|
|
Group: Development/Libraries
|
|
%if %{defined devel_requires}
|
|
Requires: %{devel_requires}
|
|
%endif
|
|
%if %{defined kdevpkg}
|
|
BuildRequires: %{kdevpkg}
|
|
%endif
|
|
|
|
%description devel
|
|
The %{name}-devel package contains the header files and Module{s}.symvers
|
|
symbols needed for building additional modules which use %{name}.
|
|
|
|
%prep
|
|
%setup -n @PACKAGE@-%{version}
|
|
%build
|
|
%configure --with-linux=%{kdir} --with-linux-obj=%{kobj} --with-config=kernel \
|
|
%{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
|
|
make
|
|
|
|
%install
|
|
rm -rf $RPM_BUILD_ROOT
|
|
make DESTDIR=$RPM_BUILD_ROOT install
|
|
|
|
%clean
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
%files
|
|
%defattr(-, root, root)
|
|
/lib/modules/*
|
|
|
|
%files devel
|
|
%defattr(-,root,root)
|
|
%{_prefix}/src/*
|
|
|
|
%post
|
|
if [ -f /boot/System.map-%{kver} ]; then
|
|
/sbin/depmod -ae -F /boot/System.map-%{kver} %{kver} || 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
|
|
else
|
|
/sbin/depmod -a || exit 0
|
|
fi
|