arrfab / rpms / shim

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