2011-10-05 07:01:45 +02:00
|
|
|
# A few cross-distro definitions:
|
|
|
|
%kernel_module_package_release 1
|
2019-07-28 13:42:10 +02:00
|
|
|
%kernel_module_package_buildreqs modutils kernel-syms kmod-compat
|
2011-10-05 07:01:45 +02:00
|
|
|
|
2018-06-20 08:03:05 +02:00
|
|
|
%cpu_arch %(case %_target_cpu in \
|
|
|
|
# from rpm --eval '%ix86' \
|
|
|
|
(i?86 | pentium3 | pentium4 | athlon | geode) \
|
|
|
|
echo "i386" \
|
|
|
|
;; \
|
|
|
|
(aarch64) \
|
|
|
|
echo "arm64" \
|
|
|
|
;; \
|
|
|
|
(*)\
|
|
|
|
echo "%_target_cpu" \
|
|
|
|
;; \
|
|
|
|
esac)
|
|
|
|
|
|
|
|
%linux_arch %(case %cpu_arch in \
|
2018-07-29 10:27:56 +02:00
|
|
|
(x86_64 | i386) \
|
|
|
|
echo "x86" \
|
|
|
|
;; \
|
2018-06-20 08:03:05 +02:00
|
|
|
(ppc*) \
|
|
|
|
echo "powerpc" \
|
|
|
|
;; \
|
|
|
|
(s390x) \
|
|
|
|
echo "s390" \
|
|
|
|
;; \
|
|
|
|
(arm64) \
|
|
|
|
echo "arm64" \
|
|
|
|
;; \
|
|
|
|
(armv*) \
|
|
|
|
echo "arm" \
|
|
|
|
;; \
|
2019-09-11 08:08:09 +02:00
|
|
|
(riscv*) \
|
|
|
|
echo "riscv" \
|
|
|
|
;;
|
2018-06-20 08:03:05 +02:00
|
|
|
(*) \
|
|
|
|
echo "%cpu_arch" \
|
|
|
|
;; \
|
|
|
|
esac)
|
|
|
|
|
|
|
|
%linux_make_arch ARCH=%linux_arch
|
|
|
|
|
2011-10-05 07:01:45 +02:00
|
|
|
# Defines %flavors_to_build and %kernel_source() as a side effect.
|
2013-05-01 08:12:39 +02:00
|
|
|
%_kernel_module_package(n:v:r:t:f:Xp:bc:) \
|
2013-09-04 08:05:35 +02:00
|
|
|
%{expand:%( \
|
2011-10-05 07:01:45 +02:00
|
|
|
subpkg=%{-t*}%{!-t:/usr/lib/rpm/kernel-module-subpackage} \
|
2013-05-01 08:12:39 +02:00
|
|
|
echo "%%define _suse_kernel_module_subpackage(n:v:r:f:p:bc) %%{expand:%%(cd %_sourcedir; cat $subpkg; echo %%%%nil)}" \
|
2011-10-05 07:01:45 +02:00
|
|
|
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 \
|
2018-06-20 08:03:05 +02:00
|
|
|
krel=$(make -si -C /usr/src/linux-obj/%_target_cpu/$flavor/ %linux_make_arch kernelrelease 2>/dev/null) \
|
2011-10-05 07:01:45 +02:00
|
|
|
kver=${krel%%-*} \
|
|
|
|
flavors_to_build="$flavors_to_build $flavor" \
|
2018-01-31 19:59:10 +01:00
|
|
|
echo "%%_suse_kernel_module_subpackage -n %{-n*}%{!-n:%name} -v %{-v*}%{!-v:%version} -r %{-r*}%{!-r:%release} %{-f} %{-p} %{-b} %{-c:-c} $flavor $kver" \
|
2011-10-05 07:01:45 +02:00
|
|
|
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_" \
|
2013-05-01 08:12:39 +02:00
|
|
|
%{-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
|
2013-09-04 08:05:35 +02:00
|
|
|
: 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 \
|
2013-05-01 08:12:39 +02:00
|
|
|
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" } \
|
2011-10-05 07:01:45 +02:00
|
|
|
)}
|
|
|
|
|
|
|
|
# kernel_module_package: simply pass on all options and arguments.
|
2013-05-01 08:12:39 +02:00
|
|
|
%kernel_module_package(n:v:r:t:f:xp:bc:) \
|
2020-09-23 10:07:46 +02:00
|
|
|
%{expand:%%_kernel_module_package %{-x:-X} %{-n} %{-v} %{-r} %{-t} %{-f} %{-p} %{-b} %{-c} %*}
|
2011-10-05 07:01:45 +02:00
|
|
|
|
|
|
|
# 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.)
|
2013-05-01 08:12:39 +02:00
|
|
|
%suse_kernel_module_package(n:v:r:s:f:xp:bc:) \
|
2020-09-23 10:07:46 +02:00
|
|
|
%{expand:%%_kernel_module_package %{-x: }%{!-x:-X} %{-n} %{-v} %{-r} %{-s:-t %{-s*}} %{-f} %{-p} %{-b} %{-c} %*}
|