# Do the necessary checks in order to enable livepatching support. # Enable livepatching support for SLE15-SP4 onwards. It requires # compiler support introduced there. # Currently only supported on x86_64 and ppc64le. # Expand to the necessary livepatching compilation flags if the macro # livepatching is defined in the spec file. %cflags_livepatching %{lua: if rpm.expand("%livepatchable") == "1" then \ if rpm.expand("%_arch") == "x86_64" then print("-fpatchable-function-entry=16,14 -fdump-ipa-clones") end \ if rpm.expand("%_arch") == "ppc64le" then print("-fpatchable-function-entry=14,13 -fdump-ipa-clones -msplit-patch-nops") end \ end } %tar_lp_basename %{name}-livepatch-%{version}-%{release} %tar_lp_package_name %{tar_lp_basename}.%{_arch}.tar.xz %clones_dest_dir %{tar_lp_basename}/%{_arch} # Ipa-clones are files generated by gcc which logs changes made across # functions, and we need to know such changes to build livepatches # correctly. These files are intended to be used by the livepatch # developers and may be retrieved by using `osc getbinaries`. %pack_ipa_dumps \ %if 0%{?livepatchable} && ("%{_arch}" == "x86_64" || "%{_arch}" == "ppc64le") \ mkdir -p ipa-clones/%{clones_dest_dir} \ find . -name "*.ipa-clones" ! -empty -exec cp -t ipa-clones/%{clones_dest_dir} --parents {} + \ tar -cJf %{tar_lp_package_name} -C ipa-clones --owner root --group root --sort name %{tar_lp_basename} \ cp %{tar_lp_package_name} %{_topdir}/OTHER \ %endif # Macro to make sure we always get the most recent version of a certain # library. %requires_ge_with_release() %{expand:%(t=$(echo '%*' | LC_ALL=C xargs -r rpm -q --qf 'Requires: %%{name} >= %%{epoch}:%%{version}-%%{release}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not"); test -n "$t" || echo "%%{error: %%%%{requires_ge_with_release %*} does not resolve}"; echo "$t")}