8c628c9
%global debug_package %{nil}
d0eddb1
8c628c9
%global efidir %(eval echo $(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/'))
8c628c9
79c5475
# this is literally to make vim's \c not put a brace at the end.
79c5475
%global _dist %{expand:%{?_module_build:%%{?dist}}}
79c5475
%global dist %{expand:%%{_dist}}
79c5475
8c628c9
Name:		shim-signed
8c628c9
Version:	13
79c5475
Release:	0.7%{dist}
8c628c9
Summary:	First-stage UEFI bootloader
8c628c9
License:	BSD
8c628c9
URL:		http://github.com/rhboot/shim/
8c628c9
8c628c9
# Shim is only required on platforms implementing the UEFI secure boot
8c628c9
# protocol. The only one of those we currently wish to support is 64-bit x86.
8c628c9
# Adding further platforms will require adding appropriate relocation code.
8c628c9
ExclusiveArch:	x86_64 aarch64
9c5743a
9c5743a
# keep these two lists of sources synched up arch-wise.  That is 0 and 10
9c5743a
# match, 1 and 11 match, ...
9c5743a
Source0:	BOOTX64.CSV
9c5743a
Source1:	BOOTAA64.CSV
9c5743a
Source2:	BOOTIA32.CSV
9c5743a
8c628c9
Source10:	shimaa64.efi
8c628c9
Source11:	shimia32.efi
8c628c9
Source12:	shimx64.efi
8c628c9
Source13:	shimx64-signed.efi
9c5743a
0a2d265
%global shimverx64 13-3.fc27
0a2d265
%global shimveria32 13-3.fc27
0a2d265
%global shimveraa64 13-3.fc27
9c5743a
9c5743a
%ifarch x86_64
8c628c9
BuildRequires: shim-unsigned-x64 = %{shimverx64}
8c628c9
BuildRequires: shim-unsigned-ia32 = %{shimveria32}
8c628c9
BuildRequires: shim-unsigned = 0.8-1.fc22
8c628c9
%global shimdirx64 %{_datadir}/shim/%{shimverx64}/x64
8c628c9
%global shimdiria32 %{_datadir}/shim/%{shimveria32}/ia32
d0eddb1
%endif
8c628c9
%ifarch aarch64
8c628c9
BuildRequires: shim-unsigned-aarch64 = %{shimveraa64}
8c628c9
%global shimdiraa64 %{_datadir}/shim/%{shimveraa64}/aa64
d0eddb1
%endif
8c628c9
BuildRequires:	pesign >= 0.112-20.fc27
e5d6859
d0eddb1
%description
d0eddb1
Initial UEFI bootloader that handles chaining to a trusted full bootloader
d0eddb1
under secure boot environments. This package contains the version signed by
d0eddb1
the UEFI signing service.
d0eddb1
ea8f9b5
%define define_pkg(a:p:)						\
8c628c9
%{expand:%%package -n shim-%{-a*}}					\
8c628c9
Summary: First-stage UEFI bootloader					\
8c628c9
Requires: mokutil >= 1:0.2.0-1						\
8c628c9
Provides: shim-signed-%{-a*} = %{version}-%{release}			\
8c628c9
Requires: dbxtool >= 0.6-3						\
3cf3e97
%{expand:%%if 0%%{-p*}							\
3cf3e97
Provides: shim = %{version}-%{release}					\
3cf3e97
Provides: shim-signed = %{version}-%{release}				\
3cf3e97
Obsoletes: shim-signed < %{version}-%{release}				\
3cf3e97
Obsoletes: shim < %{version}-%{release}					\
3cf3e97
%%endif}								\
8c628c9
# Shim uses OpenSSL, but cannot use the system copy as the UEFI ABI	\
8c628c9
# is not compatible with SysV (there's no red zone under UEFI) and	\
8c628c9
# there isn't a POSIX-style C library.					\
8c628c9
# BuildRequires: OpenSSL						\
8c628c9
Provides: bundled(openssl) = 1.0.2j					\
8c628c9
									\
8c628c9
%{expand:%%description -n shim-%{-a*}}					\
8c628c9
Initial UEFI bootloader that handles chaining to a trusted full		\
8c628c9
bootloader under secure boot environments. This package contains the	\
8c628c9
version signed by the UEFI signing service.				\
8c628c9
%{nil}
8c628c9
8c628c9
%ifarch x86_64
3cf3e97
%define_pkg -a x64 -p 1
8c628c9
%define_pkg -a ia32
8c628c9
%endif
8c628c9
%ifarch aarch64
3cf3e97
%define_pkg -a aa64 -p 1
8c628c9
%endif
2fc46bb
d0eddb1
%prep
d0eddb1
cd %{_builddir}
059ec45
rm -rf shim-signed-%{version}
d0eddb1
mkdir shim-signed-%{version}
d0eddb1
d0eddb1
%build
f0edb52
%define vendor_token_str %{expand:%%{nil}%%{?vendor_token_name:-t "%{vendor_token_name}"}}
f0edb52
%define vendor_cert_str %{expand:%%{!?vendor_cert_nickname:-c "Red Hat Test Certificate"}%%{?vendor_cert_nickname:-c "%%{vendor_cert_nickname}"}}
f0edb52
8c628c9
# -a <efiarch>
8c628c9
# -i <input>
8c628c9
%define hash(a:i:d:)							\
8c628c9
	pesign -i %{-i*} -h -P > shim.hash				\
8c628c9
	read file0 hash0 < shim.hash					\
8c628c9
	read file1 hash1 < %{-d*}/shim%{-a*}.hash			\
8c628c9
	if ! [ "$hash0" = "$hash1" ]; then				\
8c628c9
		echo Invalid signature\! > /dev/stderr			\
8c628c9
		echo $hash0 vs $hash1					\
8c628c9
		exit 1							\
8c628c9
	fi								\
8c628c9
	%{nil}
8c628c9
8c628c9
# -i <input>
8c628c9
# -o <output>
8c628c9
%define sign(i:o:)							\
8c628c9
	%{expand:%%pesign -s -i %{-i*} -o %{-o*}}			\
8c628c9
	%{nil}
8c628c9
8c628c9
# -b <binary prefix>
8c628c9
# -a <efiarch>
8c628c9
# -i <input>
8c628c9
%define distrosign(b:a:d:)						\
8c628c9
	cp -av %{-d*}/%{-b*}%{-a*}.efi %{-b*}%{-a*}-unsigned.efi	\
8c628c9
	%{expand:%%sign -i %{-b*}%{-a*}-unsigned.efi -o %{-b*}%{-a*}-signed.efi}\
8c628c9
	%{nil}
8c628c9
8c628c9
# -a <efiarch>
8c628c9
# -A <EFIARCH>
8c628c9
# -b <yes|no> # signed by this builder?
8c628c9
# -c <yes|no> # signed by UEFI CA?
8c628c9
# -i <shimARCH.efi>
8c628c9
%define define_build(a:A:b:c:i:d:)					\
8c628c9
if [ "%{-c*}" = "yes" ]; then						\
8c628c9
	%{expand:%%hash -i %{-i*} -a %{-a*} -d %{-d*}}			\
8c628c9
fi									\
8c628c9
cp %{-i*} shim%{-a*}.efi						\
8c628c9
if [ "%{-b*}" = "yes" ]; then						\
8c628c9
	%{expand:%%distrosign -b shim -a %{-a*} -d %{-d*}}		\
8c628c9
	mv shim%{-a*}-signed.efi shim%{-a*}-%{efidir}.efi		\
8c628c9
fi									\
8c628c9
if [ "%{-c*}" = "yes" ]; then						\
8c628c9
	cp shim%{-a*}-%{efidir}.efi shim%{-a*}.efi			\
8c628c9
fi									\
8c628c9
%{expand:%%distrosign -b mm -a %{-a*} -d %{-d*}}			\
8c628c9
mv mm%{-a*}-signed.efi mm%{-a*}.efi					\
8c628c9
%{expand:%%distrosign -b fb -a %{-a*} -d %{-d*}}			\
8c628c9
mv fb%{-a*}-signed.efi fb%{-a*}.efi					\
8c628c9
rm -vf									\\\
8c628c9
	mm%{-a*}-unsigned.efi						\\\
8c628c9
	fb%{-a*}-unsigned.efi						\\\
8c628c9
	shim%{-a*}-unsigned.efi						\
8c628c9
%{nil}
99c7543
8c628c9
cd shim-signed-%{version}
8c628c9
%ifarch aarch64
8c628c9
%define_build -a aa64 -A AA64 -i %{SOURCE10} -b yes -c no -d %{shimdiraa64}
e5d6859
%endif
8c628c9
%ifarch x86_64
8c628c9
%define_build -a ia32 -A IA32 -i %{SOURCE11} -b yes -c yes -d %{shimdiria32}
8c628c9
%define_build -a x64 -A X64 -i %{SOURCE12} -b yes -c yes -d %{shimdirx64}
e5d6859
%endif
e5d6859
d0eddb1
%install
8c628c9
# -a <efiarch>
8c628c9
# -A <EFIARCH>
8c628c9
# -b <BOOTCSV>
8c628c9
%define do_install(a:A:b:)						\
8c628c9
install -m 0644 shim%{-a*}.efi						\\\
8c628c9
	$RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim%{-a*}.efi		\
8c628c9
install -m 0644 shim%{-a*}-%{efidir}.efi				\\\
8c628c9
	$RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim%{-a*}-%{efidir}.efi	\
8c628c9
install -m 0644 mm%{-a*}.efi						\\\
8c628c9
	$RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/mm%{-a*}.efi		\
8c628c9
install -m 0644 %{-b*}							\\\
8c628c9
	$RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/BOOT%{-A*}.CSV		\
8c628c9
install -m 0644 shim%{-a*}.efi						\\\
8c628c9
	$RPM_BUILD_ROOT/boot/efi/EFI/BOOT/BOOT%{-A*}.EFI		\
8c628c9
install -m 0644 fb%{-a*}.efi						\\\
8c628c9
	$RPM_BUILD_ROOT/boot/efi/EFI/BOOT/fb%{-a*}.efi			\
8c628c9
%nil
8c628c9
d0eddb1
rm -rf $RPM_BUILD_ROOT
d0eddb1
cd shim-signed-%{version}
d0eddb1
install -D -d -m 0755 $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/
8c628c9
install -D -d -m 0755 $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/
8c628c9
9c5743a
%ifarch x86_64
8c628c9
%do_install -a x64 -A X64 -b %{SOURCE0}
8c628c9
%do_install -a ia32 -A IA32 -b %{SOURCE2}
8c628c9
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/BOOT.CSV
126c580
install -m 0644 $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/mmx64.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/MokManager.efi
697d29a
install -m 0644 %{SOURCE13} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim.efi
8c628c9
install -m 0644 %{SOURCE13} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shimx64.efi
8c628c9
install -m 0644 %{SOURCE13} $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/BOOTX64.EFI
126c580
install -m 0644 $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/fbx64.efi $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/fallback.efi
8c628c9
%endif
8c628c9
%ifarch aarch64
8c628c9
%do_install -a aa64 -A AA64 -b %{SOURCE1}
79c5475
install -m 0644 %{SOURCE10} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim.efi
9c5743a
%endif
879a89e
8c628c9
# -a <efiarch>
8c628c9
# -A <EFIARCH>
8c628c9
%define define_files(a:A:)						\
8c628c9
%{expand:%%files -n shim-%{-a*}}					\
8c628c9
/boot/efi/EFI/%{efidir}/*%{-a*}*.efi					\
8c628c9
/boot/efi/EFI/%{efidir}/BOOT%{-A*}.CSV					\
8c628c9
/boot/efi/EFI/BOOT/*%{-a*}.efi						\
8c628c9
/boot/efi/EFI/BOOT/*%{-A*}.EFI						\
8c628c9
%{nil}
d0eddb1
8c628c9
%ifarch x86_64
8c628c9
%define_files -a x64 -A X64
8c628c9
/boot/efi/EFI/%{efidir}/BOOT.CSV
8c628c9
/boot/efi/EFI/%{efidir}/MokManager.efi
697d29a
/boot/efi/EFI/%{efidir}/shim.efi
8c628c9
/boot/efi/EFI/BOOT/fallback.efi
8c628c9
8c628c9
%define_files -a ia32 -A IA32
8c628c9
%endif
8c628c9
%ifarch aarch64
8c628c9
%define_files -a aa64 -A AA64
79c5475
/boot/efi/EFI/%{efidir}/shim.efi
8c628c9
%endif
d0eddb1
d0eddb1
%changelog
79c5475
* Wed Oct 04 2017 Peter Jones <pjones@redhat.com> - 13-0.7
79c5475
- Make /boot/efi/EFI/fedora/shim.efi still exist on aarch64 as well.
79c5475
  Resolves: rhbz#1497854
79c5475
0a2d265
* Tue Sep 19 2017 Peter Jones <pjones@redhat.com> - 13-0.6
0a2d265
- Fix binary format issue on Aarch64
0a2d265
  Resolves: rhbz#1489604
0a2d265
0a2d265
* Tue Sep 05 2017 Peter Jones <pjones@redhat.com> - 13-0.5
697d29a
- Make /boot/efi/EFI/fedora/shim.efi still exist on x86_64, since some
697d29a
  machines have boot entries that point to it.
697d29a
3cf3e97
* Tue Aug 29 2017 Peter Jones <pjones@redhat.com> - 13-0.4
3cf3e97
- Make our provides not get silently ignore by rpmbuild...
3cf3e97
6dd6378
* Fri Aug 25 2017 Peter Jones <pjones@redhat.com> - 13-0.3
126c580
- x64: use the new fbx64.efi and mm64.efi as fallback.efi and MokManager.efi
6dd6378
- Provide: "shim" in x64 and aa64 builds
6dd6378
6dd6378
* Thu Aug 24 2017 Peter Jones <pjones@redhat.com> - 13-0.2
6dd6378
- Obsolete old shim builds.
6dd6378
8c628c9
* Tue Aug 22 2017 Peter Jones <pjones@redhat.com> - 13-0.1
8c628c9
- Initial (partially unsigned) build for multi-arch support on x64/ia32.
8c628c9
Petr Šabata f6c116f
* Thu Mar 23 2017 Petr Ĺ abata <contyk@redhat.com> - 0.8-9
Petr Šabata f6c116f
- Re-enable dist tag for module builds
Petr Šabata f6c116f
50f797b
* Tue Feb 17 2015 Peter Jones <pjones@redhat.com> - 0.8-8
8c628c9
- Don't dual-sign shim-%%{efidir}.efi either.
99c7543
  Resolves: rhbz#1184765
99c7543
99c7543
* Tue Feb 17 2015 Peter Jones <pjones@redhat.com> - 0.8-8
50f797b
- Require dbxtool
50f797b
454252f
* Wed Dec 17 2014 Peter Jones <pjones@redhat.com> - 0.8-7
454252f
- Wrong -signed changes got built for aarch64 last time, for dumb reasons.
454252f
  Related: rhbz#1170289
454252f
5265a4b
* Fri Dec 05 2014 Peter Jones <pjones@redhat.com> - 0.8-6
5265a4b
- Rebuild once more so we can use a different -unsigned version on different
5265a4b
  arches (because we can't tag a newer build into aarch64 without an x86
5265a4b
  update to match.)
5265a4b
  Related: rhbz#1170289
5265a4b
f804fa2
* Wed Dec 03 2014 Peter Jones <pjones@redhat.com> - 0.8-5
f804fa2
- Rebuild for aarch64 path fixes
f804fa2
  Related: rhbz#1170289
f804fa2
63d4aee
* Thu Oct 30 2014 Peter Jones <pjones@redhat.com> - 0.8-2
63d4aee
- Remove the dist tag so people don't complain about what it says.
63d4aee
e5d6859
* Fri Oct 24 2014 Peter Jones <pjones@redhat.com> - 0.8-1
e5d6859
- Update to shim 0.8
e5d6859
  rhbz#1148230
e5d6859
  rhbz#1148231
e5d6859
  rhbz#1148232
e5d6859
- Handle building on aarch64 as well
e5d6859
35699de
* Fri Jul 18 2014 Peter Jones <pjones@redhat.com> - 0.7-2
35699de
- Don't do multi-signing; too many machines screw up verification.
35699de
  Resolves: rhbz#1049749
35699de
e2e3364
* Wed Nov 13 2013 Peter Jones <pjones@redhat.com> - 0.7-1
e2e3364
- Update to shim 0.7
e2e3364
  Resolves: rhbz#1023767
e2e3364
c8da388
* Thu Oct 24 2013 Peter Jones <pjones@redhat.com> - 0.5-1
c8da388
- Update to shim 0.5
c8da388
879a89e
* Thu Jun 20 2013 Peter Jones <pjones@redhat.com> - 0.4-1
879a89e
- Provide a fallback for uninitialized Boot#### and BootOrder
879a89e
  Resolves: rhbz#963359
879a89e
- Move all signing from shim-unsigned to here
879a89e
- properly compare our generated hash from shim-unsigned with the hash of
879a89e
  the signed binary (as opposed to doing it manually)
879a89e
711efbc
* Fri May 31 2013 Peter Jones <pjones@redhat.com> - 0.2-4.4
711efbc
- Re-sign to get alignments that match the new specification.
711efbc
  Resolves: rhbz#963361
711efbc
67e85d9
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-4.3
67e85d9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
67e85d9
7bcdf0b
* Wed Jan 02 2013 Peter Jones <pjones@redhat.com> - 0.2-3.3
7bcdf0b
- Add obsoletes and provides for earlier shim-signed packages, to cover
7bcdf0b
  the package update cases where previous versions were installed.
7bcdf0b
  Related: rhbz#888026
7bcdf0b
60fd090
* Mon Dec 17 2012 Peter Jones <pjones@redhat.com> - 0.2-3.2
60fd090
- Make the shim-unsigned dep be on the subpackage.
60fd090
2fc46bb
* Sun Dec 16 2012 Peter Jones <pjones@redhat.com> - 0.2-3.1
2fc46bb
- Rebuild to provide "shim" package directly instead of just as a Provides:
2fc46bb
f0edb52
* Sat Dec 15 2012 Peter Jones <pjones@redhat.com> - 0.2-3
f0edb52
- Also provide shim-fedora.efi, signed only by the fedora signer.
f0edb52
- Fix the fedora signature on the result to actually be correct.
f0edb52
- Update for shim-unsigned 0.2-3
f0edb52
d0eddb1
* Mon Dec 03 2012 Peter Jones <pjones@redhat.com> - 0.2-2
d0eddb1
- Initial build