Blame SOURCES/macros.kmp

67e50c
# Use these macros to differentiate between RH and other KMP implementation(s).
67e50c
redhat_kernel_module_package	1
67e50c
kernel_module_package_release	1
67e50c
936cd0
redhat_kmp_has_post_hooks	1
936cd0
936cd0
%__brp_kmod_set_exec_bit  /usr/lib/rpm/redhat/brp-kmod-set-exec-bit
936cd0
%__brp_kmod_restore_perms /usr/lib/rpm/redhat/brp-kmod-restore-perms
936cd0
936cd0
%__kmod_brps_added 0
67e50c
67e50c
#kernel_module_package [ -n name ] [ -v version ] [ -r release ] [ -s script ]
67e50c
#                      [ -f filelist] [ -x ] [ -p preamble ] flavor flavor ...
67e50c
67e50c
%kernel_module_package_buildreqs	%global kmodtool_generate_buildreqs 1 \
936cd0
					kernel-devel kernel-abi-stablelists redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel kmod
67e50c
67e50c
%kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \
936cd0
	## An ugly hack: we want kmods to be processed by find-debuginfo,
936cd0
	## but it processes only files with executable permission set.
936cd0
	## It is important now since, as of now, if debuginfo package
936cd0
	## is enabled (and it is enabled), there's an RPM build error
936cd0
	## as a result of lack of ether absence or emptiness of
936cd0
	## debugsourcefiles.list (which is likely a bug in RPM, but it looks
936cd0
	## like that there's no obvious fix and apparently no one have
936cd0
	## any issues with this).
936cd0
	## In order to minimise intrusiveness, usually (in Red Hat-built kmod
936cd0
	## RPMs) *.ko files just have executable permission being set as a part
936cd0
	## of %build section. There are two caveats with kmp, however:
936cd0
	##  * We have no control over %build section itself (and it wasn't
936cd0
	##    required previously)
936cd0
	##  * Changing the criteria used in find-debuginfo.sh/brp-strip
936cd0
	##    for selecting files that have to undergo debug section separation
936cd0
	##    may introduce regression.
936cd0
	## As a result, we insert additional hooks in __spec_install_post
936cd0
	## (__brp_kmod_set_exec_bit in the beginning and
936cd0
	## __brp_kmod_restore_perms in the end) that (temporarily) set
936cd0
	## executable permission for *.ko files so find-debuginfo.sh will pick
936cd0
	## them up.
936cd0
	## Unfortunately, __spec_install_post's body is copied here since
936cd0
	## we want that __debug_package macro expansion has been performed
936cd0
	## lazily and  it looks like RPM has no ability to provide a body
936cd0
	## of a macro verbatim.
936cd0
	if [ 0 = "%{__kmod_brps_added}" ]; then \
936cd0
		echo "%%global __spec_install_post \\\\" \
936cd0
		echo "	%%{?__brp_kmod_set_exec_bit} \\\\" \
936cd0
		echo "	%%%%{?__debug_package:%%%%{__debug_install_post}} \\\\" \
936cd0
		echo "	%%{__arch_install_post} \\\\" \
936cd0
		echo "	%%{__os_install_post} \\\\" \
936cd0
		echo "	%%{?__brp_kmod_pre_sign_process} \\\\" \
936cd0
		echo "	%%{?__brp_kmod_sign} \\\\" \
936cd0
		echo "	%%{?__brp_kmod_post_sign_process} \\\\" \
936cd0
		echo "	%%{?__brp_kmod_compress} \\\\" \
936cd0
		echo "	%%{?__brp_kmod_post_compress_process} \\\\" \
936cd0
		echo "	%%{?__brp_kmod_restore_perms} \\\\" \
936cd0
		echo "%%{nil}" \
936cd0
	fi \
936cd0
	%global __kmod_brps_added 1 \
936cd0
	%global kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \
936cd0
	%global kmod_version %{-v*}%{!-v:%{version}} \
936cd0
	%global kmod_release %{-r*}%{!-r:%{release}} \
936cd0
	%global latest_kernel %({ rpm -q --qf '%%{VERSION}-%%{RELEASE}.%%{ARCH}\\\\n' `rpm -qa | egrep "^kernel(-rt|-aarch64)?-devel" | /usr/lib/rpm/redhat/rpmsort -r | head -n 1`; echo '%%%%{nil}'; } | head -n 1) \
67e50c
	%{!?kernel_version:%{expand:%%global kernel_version %{latest_kernel}}} \
67e50c
	%global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \
67e50c
	flavors="default" \
67e50c
	if [ -z "%*" ]; then \
67e50c
		flavors_to_build=$flavors \
67e50c
	elif [ -z "%{-x}" ]; then \
67e50c
		flavors_to_build="%*" \
67e50c
	else \
67e50c
		flavors_to_build=" $flavors "\
67e50c
		for i in %* \
67e50c
		do \
67e50c
			flavors_to_build=${flavors_to_build//$i /}
67e50c
		done \
67e50c
	fi \
67e50c
	echo "%%global flavors_to_build ${flavors_to_build:-%%nil}" \
936cd0
	echo "%%global kernel_source() \\\$([ default = \"%%%%{1}\" ] && echo \"/usr/src/kernels//%%%%kverrel\" || %{kmodtool} kernel_source \"%%%%{kverrel}\" \"%%%%{1}\" 2>/dev/null || { ls -Ud \"/usr/src/kernels///%%%%{kverrel}\"[.+]\"%%%%{1}\" | sort -V | tail -n 1; } || echo \"/usr/src/kernels////%%%%kverrel.%%%%1\")" \
936cd0
	echo "%%global kernel_module_package_moddir() extra" \
67e50c
	if [ ! -z "%{-f*}" ] \
67e50c
	then \
67e50c
		filelist="%{-f*}" \
67e50c
	fi \
67e50c
	if [ ! -z "%{-p*}" ] \
67e50c
	then \
67e50c
		preamble="%{-p*}" \
67e50c
	fi \
67e50c
	nobuildreqs="yes" \
67e50c
	if [ "x%{kmodtool_generate_buildreqs}" != "x1" ] \
67e50c
	then \
67e50c
		nobuildreqs="no" \
67e50c
	fi \
936cd0
	override_filelist="$filelist" override_preamble="$preamble" nobuildreqs="$nobuildreqs" kmod_version=%kmod_version kmod_release=%kmod_release %{kmodtool} rpmtemplate %{-n*}%{!-n:%name} %{kverrel} $flavors_to_build 2>/dev/null \
67e50c
)}