File macros.kgraft of Package kgraft

# Defines %flavors_to_build and %kernel_source() as a side effect.
%kgraft_module_package(n:x) \
%{expand:%( \
	subpkg=/usr/lib/rpm/kgraft-module-subpackage \
	echo "%%define _suse_kgraft_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_kgraft_module_subpackage -n %{-n*}%{!-n:kgraft-patch} -r %{release} $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 "%package -n %{-n*}%{!-n:kgraft-patch}-kmp-_dummy_" \
	echo "Version: %version" \
	echo "Summary: %summary" \
	echo "Group: %group" \
	echo "%description -n %{-n*}%{!-n:kgraft-patch}-kmp-_dummy_" \
)}
openSUSE Build Service is sponsored by