Blame SOURCES/shim.rpmmacros

20ce0f
%global debug_package %{nil}
20ce0f
%global __brp_mangle_shebangs_exclude_from_file %{expand:%{_builddir}/shim-%{efi_arch}-%{version}-%{release}.%{_target_cpu}-shebangs.txt}
20ce0f
%global vendor_token_str %{expand:%%{nil}%%{?vendor_token_name:-t "%{vendor_token_name}"}}
20ce0f
%global vendor_cert_str %{expand:%%{!?vendor_cert_nickname:-c "Red Hat Test Certificate"}%%{?vendor_cert_nickname:-c "%%{vendor_cert_nickname}"}}
20ce0f
20ce0f
%global bootcsvaa64 %{expand:%{SOURCE10}}
20ce0f
%global bootcsvia32 %{expand:%{SOURCE11}}
20ce0f
%global bootcsvx64 %{expand:%{SOURCE12}}
20ce0f
#%%global bootcsvarm %%{expand:%%{SOURCE13}}
20ce0f
20ce0f
%global shimefiaa64 %{expand:%{SOURCE20}}
20ce0f
%global shimefiia32 %{expand:%{SOURCE21}}
20ce0f
%global shimefix64 %{expand:%{SOURCE22}}
20ce0f
#%%global shimefiarm %%{expand:%%{SOURCE23}
20ce0f
20ce0f
%global shimveraa64 15-6.el8
bda17e
%global shimveria32 15-9.el8
bda17e
%global shimverx64 15-9.el8
20ce0f
#%%global shimverarm 15-1.el8
20ce0f
20ce0f
%global shimdiraa64 %{_datadir}/shim/%{shimveraa64}/aa64
20ce0f
%global shimdiria32 %{_datadir}/shim/%{shimveria32}/ia32
20ce0f
%global shimdirx64 %{_datadir}/shim/%{shimverx64}/x64
20ce0f
#%%global shimdirarm %%{_datadir}/shim/%%{shimverarm}/arm
20ce0f
20ce0f
%global unsignedaa64 shim-unsigned-aarch64
20ce0f
%global unsignedia32 shim-unsigned-ia32
20ce0f
%global unsignedx64 shim-unsigned-x64
20ce0f
#%%global unsignedarm shim-unsigned-arm
20ce0f
20ce0f
%global bootcsv %{expand:%{bootcsv%{efi_arch}}}
20ce0f
%global bootcsvalt %{expand:%{bootcsv%{?efi_alt_arch}}}
20ce0f
%global shimefi %{expand:%{shimefi%{efi_arch}}}
20ce0f
%global shimefialt %{expand:%{shimefi%{?efi_alt_arch}}}
20ce0f
%global shimver %{expand:%{shimver%{efi_arch}}}
20ce0f
%global shimveralt %{expand:%{shimver%{?efi_alt_arch}}}
20ce0f
%global shimdir %{expand:%{shimdir%{efi_arch}}}
20ce0f
%global shimdiralt %{expand:%{shimdir%{?efi_alt_arch}}}
20ce0f
20ce0f
%global unsignednone shim-unsigned-none
20ce0f
%global unsigned %{expand:%%{unsigned%{efi_arch}}}
20ce0f
%global unsignedalt %{expand:%%{unsigned%{efi_alt_arch}}}
20ce0f
20ce0f
%define define_pkg(a:p:)						\
20ce0f
%{expand:%%package -n shim-%{-a*}}					\
20ce0f
Summary: First-stage UEFI bootloader					\
20ce0f
Requires: mokutil >= 1:0.3.0-1						\
20ce0f
Requires: efi-filesystem						\
20ce0f
Provides: shim-signed-%{-a*} = %{version}-%{release}			\
20ce0f
Requires: dbxtool >= 0.6-3						\
20ce0f
%{expand:%%if 0%%{-p*}							\
20ce0f
Provides: shim = %{version}-%{release}					\
20ce0f
Provides: shim-signed = %{version}-%{release}				\
20ce0f
Obsoletes: shim-signed < %{version}-%{release}				\
20ce0f
Obsoletes: shim < %{version}-%{release}					\
20ce0f
%%endif}								\
20ce0f
# Shim uses OpenSSL, but cannot use the system copy as the UEFI ABI	\
20ce0f
# is not compatible with SysV (there's no red zone under UEFI) and	\
20ce0f
# there isn't a POSIX-style C library.					\
20ce0f
# BuildRequires: OpenSSL						\
20ce0f
Provides: bundled(openssl) = 1.0.2j					\
20ce0f
									\
20ce0f
%{expand:%%description -n shim-%{-a*}}					\
20ce0f
Initial UEFI bootloader that handles chaining to a trusted full		\
20ce0f
bootloader under secure boot environments. This package contains the	\
20ce0f
version signed by the UEFI signing service.				\
20ce0f
%{nil}
20ce0f
20ce0f
# -a <efiarch>
20ce0f
# -i <input>
20ce0f
%define hash(a:i:d:)							\
20ce0f
	pesign -i %{-i*} -h -P > shim.hash				\
20ce0f
	read file0 hash0 < shim.hash					\
20ce0f
	read file1 hash1 < %{-d*}/shim%{-a*}.hash			\
20ce0f
	if ! [ "$hash0" = "$hash1" ]; then				\
20ce0f
		echo Invalid signature\! > /dev/stderr			\
20ce0f
		echo $hash0 vs $hash1					\
20ce0f
		exit 1							\
20ce0f
	fi								\
20ce0f
	%{nil}
20ce0f
20ce0f
# -i <input>
20ce0f
# -o <output>
20ce0f
%define sign(i:o:n:a:c:)									\
20ce0f
	%{expand:%%pesign -s -i %{-i*} -o %{-o*} %{-n} %{-n*} %{-a} %{-a*} %{-c} %{-c*}}	\
20ce0f
	%{nil}
20ce0f
20ce0f
# -b <binary prefix>
20ce0f
# -a <efiarch>
20ce0f
# -i <input>
20ce0f
%define distrosign(b:a:d:)						\
20ce0f
	cp -av %{-d*}/%{-b*}%{-a*}.efi %{-b*}%{-a*}-unsigned.efi	\
20ce0f
	%{expand:%%sign -i %{-b*}%{-a*}-unsigned.efi -o %{-b*}%{-a*}-signed.efi -n redhatsecureboot501 -a %{SOURCE2} -c %{SOURCE1} }\
20ce0f
	%{nil}
20ce0f
20ce0f
# -a <efiarch>
20ce0f
# -A <EFIARCH>
20ce0f
# -b <1|0> # signed by this builder?
20ce0f
# -c <1|0> # signed by UEFI CA?
20ce0f
# -i <shimARCH.efi>
20ce0f
%define define_build(a:A:b:c:i:d:)					\
20ce0f
if [ "%{-c*}" = "yes-temporarily-disabled-20180723" ]; then		\
20ce0f
	%{expand:%%hash -i %{-i*} -a %{-a*} -d %{-d*}}			\
20ce0f
fi									\
20ce0f
cp %{-i*} shim%{-a*}.efi						\
20ce0f
if [ "%{-b*}" = "yes" ]; then						\
20ce0f
	%{expand:%%distrosign -b shim -a %{-a*} -d %{-d*}}		\
20ce0f
	mv shim%{-a*}-signed.efi shim%{-a*}-%{efi_vendor}.efi		\
20ce0f
fi									\
20ce0f
if [ "%{-c*}" = "no" ]; then						\
20ce0f
	cp shim%{-a*}-%{efi_vendor}.efi shim%{-a*}.efi			\
20ce0f
fi									\
20ce0f
%{expand:%%distrosign -b mm -a %{-a*} -d %{-d*}}			\
20ce0f
mv mm%{-a*}-signed.efi mm%{-a*}.efi					\
20ce0f
%{expand:%%distrosign -b fb -a %{-a*} -d %{-d*}}			\
20ce0f
mv fb%{-a*}-signed.efi fb%{-a*}.efi					\
20ce0f
rm -vf									\\\
20ce0f
	mm%{-a*}-unsigned.efi						\\\
20ce0f
	fb%{-a*}-unsigned.efi						\\\
20ce0f
	shim%{-a*}-unsigned.efi						\
20ce0f
%{nil}
20ce0f
20ce0f
# -a <efiarch>
20ce0f
# -A <EFIARCH>
20ce0f
# -b <BOOTCSV>
20ce0f
%define do_install(a:A:b:)						\
20ce0f
install -m 0700 shim%{-a*}.efi						\\\
20ce0f
	$RPM_BUILD_ROOT%{efi_esp_dir}/shim%{-a*}.efi			\
20ce0f
install -m 0700 shim%{-a*}-%{efi_vendor}.efi				\\\
20ce0f
	$RPM_BUILD_ROOT%{efi_esp_dir}/shim%{-a*}-%{efi_vendor}.efi	\
20ce0f
install -m 0700 mm%{-a*}.efi						\\\
20ce0f
	$RPM_BUILD_ROOT%{efi_esp_dir}/mm%{-a*}.efi			\
20ce0f
install -m 0700 %{-b*}							\\\
20ce0f
	$RPM_BUILD_ROOT%{efi_esp_dir}/BOOT%{-A*}.CSV			\
20ce0f
install -m 0700 shim%{-a*}.efi						\\\
20ce0f
	$RPM_BUILD_ROOT%{efi_esp_boot}/BOOT%{-A*}.EFI			\
20ce0f
install -m 0700 fb%{-a*}.efi						\\\
20ce0f
	$RPM_BUILD_ROOT%{efi_esp_boot}/fb%{-a*}.efi			\
20ce0f
%nil
20ce0f
20ce0f
# -a <efiarch>
20ce0f
# -A <EFIARCH>
20ce0f
%define define_files(a:A:)						\
20ce0f
%{expand:%%files -n shim-%{-a*}}					\
20ce0f
%{efi_esp_dir}/*%{-a*}*.efi						\
20ce0f
%{efi_esp_dir}/BOOT%{-A*}.CSV						\
20ce0f
%{efi_esp_boot}/*%{-a*}.efi						\
20ce0f
%{efi_esp_boot}/*%{-A*}.EFI						\
20ce0f
%{nil}
20ce0f
20ce0f
%ifarch x86_64
20ce0f
%global is_signed yes
20ce0f
%global is_alt_signed yes
20ce0f
%global provide_legacy_shim 1
20ce0f
%endif
20ce0f
%ifarch aarch64
20ce0f
%global is_signed no
20ce0f
%global is_alt_signed no
20ce0f
%global provide_legacy_shim 1
20ce0f
%endif
20ce0f
%ifnarch x86_64 aarch64
20ce0f
%global is_signed no
20ce0f
%global is_alt_signed no
20ce0f
%global provide_legacy_shim 0
20ce0f
%endif
20ce0f
20ce0f
%if ! 0%{?vendor:1}
20ce0f
%global vendor nopenopenope
20ce0f
%endif
20ce0f
20ce0f
# vim:filetype=rpmmacros