LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File macros.kernel-source of Package kernel-source (Project Kernel:HEAD)

# A few cross-distro definitions:
%kernel_module_package_release 1
%kernel_module_package_buildreqs modutils kernel-syms

# Defines %flavors_to_build and %kernel_source() as a side effect.
%_kernel_module_package(n:v:r:t:f:Xp:bc:) \
%{expand:%( \
	subpkg=%{-t*}%{!-t:/usr/lib/rpm/kernel-module-subpackage} \
	echo "%%define _suse_kernel_module_subpackage(n:v:r:f:p:bc) %%{expand:%%(cd %_sourcedir; cat $subpkg; echo %%%%nil)}" \
	flavors_to_build= \
	flavors="%*" \
	for flavor in $(ls /usr/src/linux-obj/%_target_cpu 2>/dev/null); do \
	    case " $flavors " in \
	    (*" $flavor "*) \
		[ -n "%{-X}" ] && continue ;; \
	    (*) \
		[ -z "%{-X}" -a -n "$flavors" ] && continue ;; \
	    esac \
	    krel=$(make -s -C /usr/src/linux-obj/%_target_cpu/$flavor kernelrelease) \
	    kver=${krel%%-*} \
	    flavors_to_build="$flavors_to_build $flavor" \
	    echo "%%_suse_kernel_module_subpackage -n %{-n*}%{!-n:%name} -v %{-v*}%{!-v:%version} -r %{-r*}%{!-r:%release} %{-p} %{-b} %{-c:-c} $flavor $kver" \
	done \
	echo "%%global flavors_to_build${flavors_to_build:-%%nil}" \
	echo "%%{expand:%%(test -z '%flavors_to_build' && echo %%%%internal_kmp_error)}" \
	echo "%%global kernel_source() /usr/src/linux-obj/%_target_cpu/%%%%{1}" \
	echo "%%global kernel_module_package_moddir() updates" \
	\
	echo "%package -n %{-n*}%{!-n:%name}-kmp-_dummy_" \
	echo "Version: %version" \
	echo "Summary: %summary" \
	echo "Group: %group" \
	echo "%description -n %{-n*}%{!-n:%name}-kmp-_dummy_" \
	%{-c:
		for fmt in DER PEM; do h=$(openssl x509 -inform $fmt -fingerprint -noout -in %{-c*}); if test -n "$h"; then break; fi; done \
		cert=/etc/uefi/certs/$(echo "$h" | sed -rn 's/^SHA1 Fingerprint=//; T; s/://g; s/(.{8}).*/\\1/p').crt
		: The -n expanstion in kernel-cert-subpackage only works if
		: -n is actually passed to the macro. Fix this here, so that
		: we do not have to modify the modsign-repackage script
		sed "s|@CERTS@|$cert|g; s|%%{-n.}|%{-n*}%{!-n:%name}|g" /usr/lib/rpm/kernel-cert-subpackage \
		echo "%%global __spec_build_pre %%__spec_build_pre mkdir -p %%buildroot/etc/uefi/certs; openssl x509 -in %{-c*} -inform $fmt -out %%buildroot/$cert -outform DER" } \
	)}

# kernel_module_package: simply pass on all options and arguments.
%kernel_module_package(n:v:r:t:f:xp:bc:) \
	%{expand:%%_kernel_module_package %{-x:-X} %{-n} %{-v} %{-r} %{-t} %{-f} %{-p} %*}

# suse_kernel_module_package: invert the meaning of the -x flag. (You are not
# supposed to understand why a simple %{-x:}%{!-x:-x} won't work.)
%suse_kernel_module_package(n:v:r:s:f:xp:bc:) \
	%{expand:%%_kernel_module_package %{-x: }%{!-x:-X} %{-n} %{-v} %{-r} %{-s:-t %{-s*}} %{-f} %{-p} %*}