[packages/tpm_emulator] - switch to macro driven module build for multiple kernel versions - rel 8
baggins
baggins at pld-linux.org
Sun Oct 27 18:32:40 CET 2013
commit d2539c8b4fd115251f7c3ad88e2f84f19202a7b5
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Oct 27 18:31:56 2013 +0100
- switch to macro driven module build for multiple kernel versions
- rel 8
tpm_emulator.spec | 108 +++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 74 insertions(+), 34 deletions(-)
---
diff --git a/tpm_emulator.spec b/tpm_emulator.spec
index 876cbc0..64c65dc 100644
--- a/tpm_emulator.spec
+++ b/tpm_emulator.spec
@@ -5,20 +5,47 @@
%bcond_without userspace # don't build userspace packages
%bcond_with verbose # verbose kernel module build
#
+%if %{without kernel}
+%undefine with_dist_kernel
+%endif
+
+# The goal here is to have main, userspace, package built once with
+# simple release number, and only rebuild kernel packages with kernel
+# version as part of release number, without the need to bump release
+# with every kernel change.
+%if 0%{?_pld_builder:1} && %{with kernel} && %{with userspace}
+%{error:kernel and userspace cannot be built at the same time on PLD builders}
+exit 1
+%endif
+
%if "%{_alt_kernel}" != "%{nil}"
+%if 0%{?build_kernels:1}
+%{error:alt_kernel and build_kernels are mutually exclusive}
+exit 1
+%endif
%undefine with_userspace
+%global _build_kernels %{alt_kernel}
+%else
+%global _build_kernels %{?build_kernels:,%{?build_kernels}}
%endif
-%if %{without kernel}
-%undefine with_dist_kernel
+
+%if %{without userspace}
+# nothing to be placed to debuginfo package
+%define _enable_debug_packages 0
%endif
+%define _duplicate_files_terminate_build 0
+
+%define kpkg %(echo %{_build_kernels} | tr , '\\n' | while read n ; do echo %%undefine alt_kernel ; [ -z "$n" ] || echo %%define alt_kernel $n ; echo %%kernel_pkg ; done)
+%define bkpkg %(echo %{_build_kernels} | tr , '\\n' | while read n ; do echo %%undefine alt_kernel ; [ -z "$n" ] || echo %%define alt_kernel $n ; echo %%build_kernel_pkg ; done)
+
%define pname tpm_emulator
-%define rel 7
+%define rel 8
Summary: Software-based TPM and MTM Emulator
Summary(pl.UTF-8): Programowy emulator TPM i MTM
Name: %{pname}%{_alt_kernel}
Version: 0.7.4
-Release: %{rel}
+Release: %{rel}%{?with_kernel:@%{_kernel_ver_str}}
License: GPL v2+
Group: Applications/System
Source0: http://downloads.sourceforge.net/tpm-emulator.berlios/%{pname}-%{version}.tar.gz
@@ -27,9 +54,8 @@ Patch0: %{pname}-libdir.patch
URL: http://tpm-emulator.berlios.de/
BuildRequires: cmake >= 2.4
BuildRequires: gmp-devel
-%if %{with dist_kernel}
-BuildRequires: kernel%{_alt_kernel}-module-build
-%endif
+BuildRequires: rpmbuild(macros) >= 1.678
+%{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
Requires: %{name}-libs = %{version}-%{rel}
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -74,22 +100,44 @@ Static TDDL library.
%description static -l pl.UTF-8
Statyczna biblioteka TDDL.
-%package -n kernel%{_alt_kernel}-char-tpmd
-Summary: Kernel module that provides /dev/tpm device
-Summary(pl.UTF-8): Moduł jądra udostępniający urządzenie /dev/tpm
-Group: Base/Kernel
-%if %{with dist_kernel}
-%requires_releq_kernel
-Requires(postun): %releq_kernel
-%endif
-
-%description -n kernel%{_alt_kernel}-char-tpmd
-Kernel module that provides /dev/tpm device for backward compatibility
-and forwards the received commands to tpmd.
-
-%description -n kernel%{_alt_kernel}-char-tpmd -l pl.UTF-8
-Moduł jądra udostępniający dla kompatybilności urządzenie /dev/tpm i
-przekazujący odebrane polecenia do tpmd.
+%define kernel_pkg()\
+%package -n kernel%{_alt_kernel}-char-tpmd\
+Summary: Kernel module that provides /dev/tpm device\
+Summary(pl.UTF-8): Moduł jądra udostępniający urządzenie /dev/tpm\
+Group: Base/Kernel\
+%if %{with dist_kernel}\
+%requires_releq_kernel\
+Requires(postun): %releq_kernel\
+%endif\
+\
+%description -n kernel%{_alt_kernel}-char-tpmd\
+Kernel module that provides /dev/tpm device for backward compatibility\
+and forwards the received commands to tpmd.\
+\
+%description -n kernel%{_alt_kernel}-char-tpmd -l pl.UTF-8\
+Moduł jądra udostępniający dla kompatybilności urządzenie /dev/tpm i\
+przekazujący odebrane polecenia do tpmd.\
+\
+%if %{with kernel}\
+%files -n kernel%{_alt_kernel}-char-tpmd\
+%defattr(644,root,root,755)\
+/lib/modules/%{_kernel_ver}/misc/tpmd_dev.ko*\
+/lib/udev/rules.d/80-tpmd_dev.rules\
+%endif\
+\
+%post -n kernel%{_alt_kernel}-char-tpmd\
+%depmod %{_kernel_ver}\
+\
+%postun -n kernel%{_alt_kernel}-char-tpmd\
+%depmod %{_kernel_ver}\
+%{nil}
+
+%define build_kernel_pkg()\
+%build_kernel_modules -m tpmd_dev -C tpmd_dev/linux\
+%install_kernel_modules -D installed -m tpmd_dev/linux/tpmd_dev -d misc\
+%{nil}
+
+%{?with_kernel:%{expand:%kpkg}}
%prep
%setup -q -n %{pname}-%{version}
@@ -108,8 +156,8 @@ cd build
cd ..
%if %{with kernel}
ln -sf ../../build/config.h tpmd_dev/linux/config.h
-%build_kernel_modules -m tpmd_dev -C tpmd_dev/linux
%{__make} -C tpmd_dev/linux tpmd_dev.rules
+%{expand:%bkpkg}
%endif
%install
@@ -122,9 +170,8 @@ rm -rf $RPM_BUILD_ROOT
%if %{with kernel}
install -d $RPM_BUILD_ROOT/lib/udev/rules.d
-cd tpmd_dev/linux
-cp -p tpmd_dev.rules $RPM_BUILD_ROOT/lib/udev/rules.d/80-tpmd_dev.rules
-%install_kernel_modules -m tpmd_dev -d misc
+cp -p tpmd_dev/linux/tpmd_dev.rules $RPM_BUILD_ROOT/lib/udev/rules.d/80-tpmd_dev.rules
+cp -a installed/* $RPM_BUILD_ROOT
%endif
%clean
@@ -153,10 +200,3 @@ rm -rf $RPM_BUILD_ROOT
%defattr(644,root,root,755)
%{_libdir}/libtddl.a
%endif
-
-%if %{with kernel}
-%files -n kernel%{_alt_kernel}-char-tpmd
-%defattr(644,root,root,755)
-/lib/modules/%{_kernel_ver}/misc/tpmd_dev.ko*
-/lib/udev/rules.d/80-tpmd_dev.rules
-%endif
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/tpm_emulator.git/commitdiff/d2539c8b4fd115251f7c3ad88e2f84f19202a7b5
More information about the pld-cvs-commit
mailing list