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

baggins baggins at pld-linux.org
Tue Oct 29 00:10:06 CET 2013


commit 0406611bedf313f157d9791a6ac7f8485e5a5f69
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Tue Oct 29 00:09:32 2013 +0100

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

 nvidiabl.spec | 154 ++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 86 insertions(+), 68 deletions(-)
---
diff --git a/nvidiabl.spec b/nvidiabl.spec
index 405b65c..47070b1 100644
--- a/nvidiabl.spec
+++ b/nvidiabl.spec
@@ -1,28 +1,43 @@
 #
 # Conditional build:
 %bcond_without	dist_kernel	# allow non-distribution kernel
-%bcond_without	kernel		# don't build kernel modules
 %bcond_with	verbose		# verbose build (V=1)
 %bcond_with	dkms	# build dkms package
 
+%if "%{_alt_kernel}" != "%{nil}"
+%if 0%{?build_kernels:1}
+%{error:alt_kernel and build_kernels are mutually exclusive}
+exit 1
+%endif
+%global		_build_kernels		%{alt_kernel}
+%else
+%global		_build_kernels		%{?build_kernels:,%{?build_kernels}}
+%endif
+
 # nothing to be placed to debuginfo package
 %define		_enable_debug_packages	0
 
-%define		rel	28
-%define		modname	nvidiabl
+%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		rel	29
+%define		pname	nvidiabl
 Summary:	Linux driver for nVidia display back-lights
-Name:		%{modname}%{_alt_kernel}
+Name:		%{pname}%{_alt_kernel}
 Version:	0.81
-Release:	%{rel}
+Release:	%{rel}%{?_pld_builder:@%{_kernel_ver_str}}
 License:	GPL v2+
 URL:		https://github.com/guillaumezin/nvidiabl
-Source0:	https://github.com/guillaumezin/nvidiabl/archive/v%{version}.tar.gz?/%{modname}-%{version}.tgz
+Source0:	https://github.com/guillaumezin/nvidiabl/archive/v%{version}.tar.gz?/%{pname}-%{version}.tgz
 # Source0-md5:	f72d90c0fe34b36a0ff3b6d7034e99c4
 Source1:	modprobe.conf
 Patch0:		nvidiabl-dkmsconf.patch
 Group:		Base/Kernel
-%{?with_dist_kernel:BuildRequires:	kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
-BuildRequires:	rpmbuild(macros) >= 1.379
+BuildRequires:	rpmbuild(macros) >= 1.678
+%{?with_dist_kernel:%{expand:%kbrs}}
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -34,7 +49,7 @@ adjust the display backlight.
 On Apple machines this driver allows more fine-grained brightness
 adjustment than the (mbp_nvidia_bl) driver and is generally preferred.
 
-%package -n dkms-%{modname}
+%package -n dkms-%{pname}
 Summary:	DKMS-ready driver for nVidia display back-lights
 License:	GPL v2+
 Group:		Base/Kernel
@@ -44,7 +59,7 @@ Requires(post):	dkms
 BuildArch:	noarch
 %endif
 
-%description -n dkms-%{modname}
+%description -n dkms-%{pname}
 This package contains a DKMS-ready driver for nvidia laptop display
 back-lights.
 
@@ -57,82 +72,85 @@ On Apple machines this driver allows more fine-grained brightness
 adjustment than the mbp-nvidia-bl-dkms (mbp_nvidia_bl) driver and is
 generally preferred.
 
-
-%package -n kernel%{_alt_kernel}-video-nvidiabl
-Summary:	Linux driver for nVidia display back-lights
-Summary(pl.UTF-8):	Sterownik dla Linuksa do nvidiabl
-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}-video-nvidiabl
-This driver drives the smartdimmer register found on modern mobile
-nVidia graphics adapters such as NV40, NV41, NV43, NV44, NV46, NV47,
-NV49, NV4B, C51, G84, G86, G92, G94, G96, GT200 architectures to
-adjust the display backlight.
-
-On Apple machines this driver allows more fine-grained brightness
-adjustment than the (mbp_nvidia_bl) driver and is generally preferred.
-
-%description -n kernel%{_alt_kernel}-video-nvidiabl -l pl.UTF-8
-Sterownik dla Linuksa do nvidiabl.
-
-Ten pakiet zawiera moduł jądra Linuksa.
+%define	kernel_pkg()\
+%package -n kernel%{_alt_kernel}-video-nvidiabl\
+Summary:	Linux driver for nVidia display back-lights\
+Summary(pl.UTF-8):	Sterownik dla Linuksa do nvidiabl\
+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}-video-nvidiabl\
+This driver drives the smartdimmer register found on modern mobile\
+nVidia graphics adapters such as NV40, NV41, NV43, NV44, NV46, NV47,\
+NV49, NV4B, C51, G84, G86, G92, G94, G96, GT200 architectures to\
+adjust the display backlight.\
+\
+On Apple machines this driver allows more fine-grained brightness\
+adjustment than the (mbp_nvidia_bl) driver and is generally preferred.\
+\
+%description -n kernel%{_alt_kernel}-video-nvidiabl -l pl.UTF-8\
+Sterownik dla Linuksa do nvidiabl.\
+\
+Ten pakiet zawiera moduł jądra Linuksa.\
+\
+%files -n kernel%{_alt_kernel}-video-nvidiabl\
+%defattr(644,root,root,755)\
+/lib/modules/%{_kernel_ver}/misc/*.ko*\
+%config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{pname}.conf\
+\
+%post	-n kernel%{_alt_kernel}-video-nvidiabl\
+%depmod %{_kernel_ver}\
+\
+%postun	-n kernel%{_alt_kernel}-video-nvidiabl\
+%depmod %{_kernel_ver}\
+%{nil}
+
+%define build_kernel_pkg()\
+%build_kernel_modules -m nvidiabl\
+%install_kernel_modules -D installed -m nvidiabl -d misc\
+%{nil}
+
+%{expand:%kpkg}
 
 %prep
-%setup -qn %{modname}-%{version}
+%setup -qn %{pname}-%{version}
 %patch0 -p1
 
 %build
-%if %{with kernel}
-%build_kernel_modules -m nvidiabl
-%endif
+%{expand:%bkpkg}
 
 %install
 rm -rf $RPM_BUILD_ROOT
-%if %{with kernel}
-%install_kernel_modules -m nvidiabl -d misc
 install -d $RPM_BUILD_ROOT/etc/modprobe.d
-cp -p %{SOURCE1} $RPM_BUILD_ROOT/etc/modprobe.d/%{modname}.conf
-%endif
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT/etc/modprobe.d/%{pname}.conf
+cp -a installed/* $RPM_BUILD_ROOT
 
 %if %{with dkms}
-install -d $RPM_BUILD_ROOT%{_usrsrc}/%{modname}-%{version}-%{rel}
-cp -p Makefile *.[ch] $RPM_BUILD_ROOT%{_usrsrc}/%{modname}-%{version}-%{rel}
-sed -e 's|@MODNAME@|%{modname}|g' -e 's|@MODVERSION@|%{version}-%{rel}|g' \
-	dkms.conf > $RPM_BUILD_ROOT%{_usrsrc}/%{modname}-%{version}-%{rel}/dkms.conf
+install -d $RPM_BUILD_ROOT%{_usrsrc}/%{pname}-%{version}-%{rel}
+cp -p Makefile *.[ch] $RPM_BUILD_ROOT%{_usrsrc}/%{pname}-%{version}-%{rel}
+sed -e 's|@pname@|%{pname}|g' -e 's|@MODVERSION@|%{version}-%{rel}|g' \
+	dkms.conf > $RPM_BUILD_ROOT%{_usrsrc}/%{pname}-%{version}-%{rel}/dkms.conf
 %endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post -n dkms-%{modname}
-%{_sbindir}/dkms add -m %{modname} -v %{version}-%{rel} --rpm_safe_upgrade && \
-%{_sbindir}/dkms build -m %{modname} -v %{version}-%{rel} --rpm_safe_upgrade && \
-%{_sbindir}/dkms install -m %{modname} -v %{version}-%{rel} --rpm_safe_upgrade || :
-
-%preun -n dkms-%{modname}
-%{_sbindir}/dkms remove -m %{modname} -v %{version}-%{rel} --rpm_safe_upgrade --all || :
-
-%post	-n kernel%{_alt_kernel}-video-nvidiabl
-%depmod %{_kernel_ver}
+%post -n dkms-%{pname}
+%{_sbindir}/dkms add -m %{pname} -v %{version}-%{rel} --rpm_safe_upgrade && \
+%{_sbindir}/dkms build -m %{pname} -v %{version}-%{rel} --rpm_safe_upgrade && \
+%{_sbindir}/dkms install -m %{pname} -v %{version}-%{rel} --rpm_safe_upgrade || :
 
-%postun	-n kernel%{_alt_kernel}-video-nvidiabl
-%depmod %{_kernel_ver}
+%preun -n dkms-%{pname}
+%{_sbindir}/dkms remove -m %{pname} -v %{version}-%{rel} --rpm_safe_upgrade --all || :
 
 %if %{with dkms}
-%files -n dkms-%{modname}
-%defattr(644,root,root,755)
-%{_usrsrc}/%{modname}-%{version}-%{rel}
-%endif
-
-%if %{with kernel}
-%files -n kernel%{_alt_kernel}-video-nvidiabl
+%files -n dkms-%{pname}
 %defattr(644,root,root,755)
-/lib/modules/%{_kernel_ver}/misc/*.ko*
-%config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{modname}.conf
+%{_usrsrc}/%{pname}-%{version}-%{rel}
 %endif
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/nvidiabl.git/commitdiff/0406611bedf313f157d9791a6ac7f8485e5a5f69



More information about the pld-cvs-commit mailing list