[packages/spl] - switch to macro driven module build for multiple kernel versions - rel 6

baggins baggins at pld-linux.org
Tue Oct 29 12:27:29 CET 2013


commit 248e4e5fa0036b6696b4be71dfa91e3414b5e1fc
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Tue Oct 29 12:26:57 2013 +0100

    - switch to macro driven module build for multiple kernel versions
    - rel 6

 spl.spec | 164 +++++++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 108 insertions(+), 56 deletions(-)
---
diff --git a/spl.spec b/spl.spec
index 25ec42c..20b804f 100644
--- a/spl.spec
+++ b/spl.spec
@@ -9,8 +9,24 @@
 %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 userspace}
@@ -18,22 +34,26 @@
 %define		_enable_debug_packages	0
 %endif
 
-%define	pname	spl
-%define	rel	5
+%define		_duplicate_files_terminate_build	0
+
+%define		kbrs	%(echo %{_build_kernels} | tr , '\\n' | while read n ; do echo %%undefine alt_kernel ; [ -z "$n" ] || echo %%define alt_kernel $n ; echo "BuildRequires:kernel%%{_alt_kernel}-module-build >= 3:2.6.20.2" ; done)
+%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	spl
+%define		rel	6
 Summary:	Solaris Porting Layer
 Summary(pl.UTF-8):	Solaris Porting Layer - warstwa do portowania kodu z Solarisa
-Name:		%{pname}%{_alt_kernel}
+Name:		%{pname}%{?_pld_builder:%{?with_kernel:-kernel}}%{_alt_kernel}
 Version:	0.6.2
-Release:	%{rel}
+Release:	%{rel}%{?_pld_builder:%{?with_kernel:@%{_kernel_ver_str}}}
 License:	GPL v2+
 Group:		Applications/System
 Source0:	http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/%{pname}-%{version}.tar.gz
 # Source0-md5:	f00535bf89a7fde0e08f44a14a1f1e03
 URL:		http://zfsonlinux.org/
-%if %{with kernel}
-%{?with_dist_kernel:BuildRequires:	kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
-BuildRequires:	rpmbuild(macros) >= 1.379
-%endif
+BuildRequires:	rpmbuild(macros) >= 1.678
+%{?with_dist_kernel:%{expand:%kbrs}}
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -42,56 +62,101 @@ Solaris Porting Layer.
 %description -l pl.UTF-8
 Solaris Porting Layer - warstwa do portowania kodu z Solarisa.
 
-%package -n kernel%{_alt_kernel}-spl
-Summary:	Solaris Porting Layer - Linux kernel modules
-Summary(pl.UTF-8):	Solaris Porting Layer - moduły jądra Linuksa
-Release:	%{rel}@%{_kernel_ver_str}
-Group:		Base/Kernel
-Requires(post,postun):	/sbin/depmod
-%if %{with dist_kernel}
-%requires_releq_kernel
-Requires(postun):	%releq_kernel
-%endif
-
-%description -n kernel%{_alt_kernel}-spl
-Solaris Porting Layer - Linux kernel modules.
-
-%description -n kernel%{_alt_kernel}-spl -l pl.UTF-8
-Solaris Porting Layer - moduły jądra Linuksa.
-
-%package -n kernel%{_alt_kernel}-spl-devel
-Summary:	Solaris Porting Layer - Linux kernel headers
-Summary(pl.UTF-8):	Solaris Porting Layer - pliki nagłówkowe jądra Linuksa
-Release:	%{rel}@%{_kernel_ver_str}
-Group:		Development/Building
-%{?with_dist_kernel:Requires:	kernel%{_alt_kernel}-headers}
-
-%description -n kernel%{_alt_kernel}-spl-devel
-Solaris Porting Layer - Linux kernel headers configured for PLD
-kernel%{_alt_kernel}, version %{_kernel_ver}.
-
-%description -n kernel%{_alt_kernel}-spl-devel -l pl.UTF-8
-Solaris Porting Layer - pliki nagłówkowe jądra Linuksa skonfigurowane
-dla jądra PLD z pakietu kernel%{_alt_kernel} w wersji %{_kernel_ver}.
+%define	kernel_pkg()\
+%package -n kernel%{_alt_kernel}-spl\
+Summary:	Solaris Porting Layer - Linux kernel modules\
+Summary(pl.UTF-8):	Solaris Porting Layer - moduły jądra Linuksa\
+Release:	%{rel}@%{_kernel_ver_str}\
+Group:		Base/Kernel\
+Requires(post,postun):	/sbin/depmod\
+%if %{with dist_kernel}\
+%requires_releq_kernel\
+Requires(postun):	%releq_kernel\
+%endif\
+\
+%description -n kernel%{_alt_kernel}-spl\
+Solaris Porting Layer - Linux kernel modules.\
+\
+%description -n kernel%{_alt_kernel}-spl -l pl.UTF-8\
+Solaris Porting Layer - moduły jądra Linuksa.\
+\
+%package -n kernel%{_alt_kernel}-spl-devel\
+Summary:	Solaris Porting Layer - Linux kernel headers\
+Summary(pl.UTF-8):	Solaris Porting Layer - pliki nagłówkowe jądra Linuksa\
+Release:	%{rel}@%{_kernel_ver_str}\
+Group:		Development/Building\
+%{?with_dist_kernel:Requires:	kernel%{_alt_kernel}-headers}\
+\
+%description -n kernel%{_alt_kernel}-spl-devel\
+Solaris Porting Layer - Linux kernel headers configured for PLD\
+kernel%{_alt_kernel}, version %{_kernel_ver}.\
+\
+%description -n kernel%{_alt_kernel}-spl-devel -l pl.UTF-8\
+Solaris Porting Layer - pliki nagłówkowe jądra Linuksa skonfigurowane\
+dla jądra PLD z pakietu kernel%{_alt_kernel} w wersji %{_kernel_ver}.\
+\
+%files -n kernel%{_alt_kernel}-spl\
+%defattr(644,root,root,755)\
+%dir /lib/modules/%{_kernel_ver}/misc/spl\
+/lib/modules/%{_kernel_ver}/misc/spl/spl.ko*\
+%dir /lib/modules/%{_kernel_ver}/misc/splat\
+/lib/modules/%{_kernel_ver}/misc/splat/splat.ko*\
+\
+%files -n kernel%{_alt_kernel}-spl-devel\
+%defattr(644,root,root,755)\
+%dir /usr/src/spl-%{version}\
+/usr/src/spl-%{version}/spl*.in\
+/usr/src/spl-%{version}/include\
+/usr/src/spl-%{version}/%{_kernel_ver}\
+\
+%post	-n kernel%{_alt_kernel}-spl\
+%depmod %{_kernel_ver}\
+\
+%postun	-n kernel%{_alt_kernel}-spl\
+%depmod %{_kernel_ver}\
+%{nil}
+
+%define build_kernel_pkg()\
+%configure \\\
+	--disable-silent-rules \\\
+	--with-config="kernel" \\\
+	--with-linux=%{_kernelsrcdir}\
+\
+%{__make} clean\
+%{__make} %{?with_verbose:V=1}\
+p=`pwd`\
+%{__make} install DESTDIR=$p/installed INSTALL_MOD_DIR=misc\
+%{nil}
+
+%{?with_kernel:%{expand:%kpkg}}
 
 %prep
 %setup -q -n %{pname}-%{version}
 
 %build
+%{?with_kernel:%{expand:%bkpkg}}
+
+%if %{with userspace}
 %configure \
 	--disable-silent-rules \
-	--with-config="%{?with_kernel:%{?with_userspace:all}}%{!?with_kernel:user}%{!?with_userspace:kernel}" \
-	--with-linux=%{_kernelsrcdir}
+	--with-config="user"
 
 %{__make} \
 	%{?with_verbose:V=1}
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with kernel}
+install -d $RPM_BUILD_ROOT
+cp -a installed/* $RPM_BUILD_ROOT
+%endif
+
+%if %{with userspace}
 %{__make} install \
-	DESTDIR=$RPM_BUILD_ROOT \
-	INSTALL_MOD_DIR=misc
+	DESTDIR=$RPM_BUILD_ROOT
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -103,16 +168,3 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_sbindir}/splat
 %{_mandir}/man1/splat.1*
 %endif
-
-%if %{with kernel}
-%files -n kernel%{_alt_kernel}-spl
-%defattr(644,root,root,755)
-%dir /lib/modules/%{_kernel_ver}/misc/spl
-/lib/modules/%{_kernel_ver}/misc/spl/spl.ko*
-%dir /lib/modules/%{_kernel_ver}/misc/splat
-/lib/modules/%{_kernel_ver}/misc/splat/splat.ko*
-
-%files -n kernel%{_alt_kernel}-spl-devel
-%defattr(644,root,root,755)
-/usr/src/spl-%{version}
-%endif
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/spl.git/commitdiff/248e4e5fa0036b6696b4be71dfa91e3414b5e1fc



More information about the pld-cvs-commit mailing list