Blame SOURCES/shim.rpmmacros

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