0e6d36
# Use these macros to differentiate between RH and other KMP implementation(s).
0e6d36
redhat_kernel_module_package	1
0e6d36
kernel_module_package_release	1
0e6d36
c8cbd2
%__find_provides        /usr/lib/rpm/redhat/find-provides
c8cbd2
%__find_requires        /usr/lib/rpm/redhat/find-requires
c8cbd2
0e6d36
#kernel_module_package [ -n name ] [ -v version ] [ -r release ] [ -s script ]
0e6d36
#                      [ -f filelist] [ -x ] [ -p preamble ] flavor flavor ...
0e6d36
0e6d36
%kernel_module_package_buildreqs	%global kmodtool_generate_buildreqs 1 \
0e6d36
					kernel-devel
0e6d36
0e6d36
%kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \
0e6d36
	%define kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \
0e6d36
	%define kmp_version %{-v*}%{!-v:%{version}} \
0e6d36
	%define kmp_release %{-r*}%{!-r:%{release}} \
0e6d36
	%define latest_kernel %(rpm -q --qf '%{VERSION}-%{RELEASE}\\\\n' `rpm -q kernel-devel | /usr/lib/rpm/redhat/rpmsort -r | head -n 1` | head -n 1) \
0e6d36
	%{!?kernel_version:%{expand:%%global kernel_version %{latest_kernel}}} \
0e6d36
	%global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \
0e6d36
	flavors="default" \
0e6d36
	if [ "i686" == "%{_target_cpu}" ] || [ "x86_64" == "%{_target_cpu}" ] \
0e6d36
	then \
0e6d36
		xenver=$(rpm -q kernel-xen-devel-%{kverrel}|head -n 1)\
0e6d36
		kdver=$(rpm -q kernel-kdump-devel-%{kverrel}|head -n 1)\
0e6d36
		if [ "kernel-xen-devel-%{kverrel}" == "$xenver" ] \
0e6d36
		then \
0e6d36
			flavors="$flavors xen" \
0e6d36
		fi \
0e6d36
		if [ "kernel-kdump-devel-%{kverrel}" == "$kdver" ] \
0e6d36
		then \
0e6d36
			flavors="$flavors kdump" \
0e6d36
		fi \
0e6d36
	fi \
0e6d36
	if [ -z "%*" ]; then \
0e6d36
		flavors_to_build=$flavors \
0e6d36
	elif [ -z "%{-x}" ]; then \
0e6d36
		flavors_to_build="%*" \
0e6d36
	else \
0e6d36
		flavors_to_build=" $flavors "\
0e6d36
		echo "[$flavors_to_build]" >/tmp/tmp.txt
0e6d36
		for i in %* \
0e6d36
		do \
0e6d36
			flavors_to_build=${flavors_to_build//$i /}
0e6d36
		done \
0e6d36
	fi \
0e6d36
	echo "%%global flavors_to_build ${flavors_to_build:-%%nil}" \
d95e9b
	echo "%%global kernel_source() /usr/src/kernels/%kverrel.\\\$([ %%%%{1} = default ] || echo "%%%%{1}.")%_target_cpu" \
0e6d36
	if [ ! -z "%{-f*}" ] \
0e6d36
	then \
0e6d36
		filelist="%{-f*}" \
0e6d36
	fi \
0e6d36
	if [ ! -z "%{-p*}" ] \
0e6d36
	then \
0e6d36
		preamble="%{-p*}" \
0e6d36
	fi \
bc1c35
	nobuildreqs="yes" \
bc1c35
	if [ "x%{kmodtool_generate_buildreqs}" != "x1" ] \
0e6d36
	then \
bc1c35
		nobuildreqs="no" \
0e6d36
	fi \
a91c84
	kmp_override_filelist="$filelist" kmp_override_preamble="$preamble" kmp_nobuildreqs="$nobuildreqs" %{kmodtool} rpmtemplate_kmp %{-n*}%{!-n:%name} %{kverrel} $flavors_to_build 2>/dev/null \
0e6d36
)}