2013-01-17 10:43:06 +01:00
|
|
|
#
|
|
|
|
# spec file for package shim
|
|
|
|
#
|
2017-02-16 03:17:33 +01:00
|
|
|
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
2013-01-17 10:43:06 +01:00
|
|
|
#
|
|
|
|
# All modifications and additions to the file contributed by third parties
|
|
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
|
|
# upon. The license for this file, and modifications and additions to the
|
|
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
|
|
# license for the pristine package is not an Open Source License, in which
|
|
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
|
|
# published by the Open Source Initiative.
|
|
|
|
|
|
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
|
|
#
|
2013-02-07 14:54:45 +01:00
|
|
|
# needssslcertforbuild
|
|
|
|
|
2016-12-05 09:35:58 +01:00
|
|
|
|
2015-07-20 12:27:18 +02:00
|
|
|
%undefine _build_create_debug
|
|
|
|
|
2013-01-17 10:43:06 +01:00
|
|
|
Name: shim
|
2017-06-22 06:42:26 +02:00
|
|
|
Version: 12
|
2013-01-17 10:43:06 +01:00
|
|
|
Release: 0
|
|
|
|
Summary: UEFI shim loader
|
|
|
|
License: BSD-2-Clause
|
|
|
|
Group: System/Boot
|
2017-06-22 06:42:26 +02:00
|
|
|
Url: https://github.com/rhboot/shim
|
|
|
|
Source: https://github.com/rhboot/shim/releases/download/%{version}/%{name}-%{version}.tar.bz2
|
2013-08-09 11:33:45 +02:00
|
|
|
# run "extract_signature.sh shim.efi" where shim.efi is the binary
|
|
|
|
# with the signature from the UEFI signing service.
|
2016-12-05 09:35:58 +01:00
|
|
|
# Note: For signature requesting, check SIGNATURE_UPDATE.txt
|
2014-04-29 09:15:01 +02:00
|
|
|
Source1: signature-opensuse.asc
|
2013-01-29 14:42:18 +01:00
|
|
|
Source2: openSUSE-UEFI-CA-Certificate.crt
|
2013-02-07 14:54:45 +01:00
|
|
|
Source3: shim-install
|
2013-02-27 15:53:25 +01:00
|
|
|
Source4: SLES-UEFI-CA-Certificate.crt
|
2013-08-09 11:33:45 +02:00
|
|
|
Source5: extract_signature.sh
|
|
|
|
Source6: attach_signature.sh
|
|
|
|
Source7: show_hash.sh
|
2013-08-28 11:32:58 +02:00
|
|
|
Source8: show_signatures.sh
|
|
|
|
Source9: openSUSE-UEFI-CA-Certificate-4096.crt
|
2013-09-09 05:29:33 +02:00
|
|
|
Source10: timestamp.pl
|
2014-04-29 09:15:01 +02:00
|
|
|
Source11: strip_signature.sh
|
|
|
|
Source12: signature-sles.asc
|
2016-12-05 09:35:58 +01:00
|
|
|
Source99: SIGNATURE_UPDATE.txt
|
2014-04-29 09:15:01 +02:00
|
|
|
# PATCH-FIX-SUSE shim-only-os-name.patch glin@suse.com -- Only include the OS name in version.c
|
2015-07-08 10:54:24 +02:00
|
|
|
Patch1: shim-only-os-name.patch
|
2017-08-22 08:17:06 +02:00
|
|
|
# PATCH-FIX-SUSE shim-only-os-name.patch glin@suse.com -- Use the Arch-independent names
|
|
|
|
Patch2: shim-arch-independent-names.patch
|
2015-07-20 12:27:18 +02:00
|
|
|
# PATCH-FIX-OPENSUSE shim-change-debug-file-path.patch glin@suse.com -- Change the default debug file path
|
|
|
|
Patch50: shim-change-debug-file-path.patch
|
2014-04-29 09:15:01 +02:00
|
|
|
# PATCH-FIX-OPENSUSE shim-opensuse-cert-prompt.patch glin@suse.com -- Show the prompt to ask whether the user trusts openSUSE certificate or not
|
|
|
|
Patch100: shim-opensuse-cert-prompt.patch
|
2016-08-04 08:19:49 +02:00
|
|
|
BuildRequires: gnu-efi >= 3.0.3
|
2013-01-17 10:43:06 +01:00
|
|
|
BuildRequires: mozilla-nss-tools
|
|
|
|
BuildRequires: openssl >= 0.9.8
|
|
|
|
BuildRequires: pesign
|
2013-02-07 14:54:45 +01:00
|
|
|
BuildRequires: pesign-obs-integration
|
2017-02-16 03:17:33 +01:00
|
|
|
%if 0%{?suse_version} > 1320
|
|
|
|
BuildRequires: update-bootloader-rpm-macros
|
|
|
|
%endif
|
|
|
|
%if 0%{?update_bootloader_requires:1}
|
|
|
|
%update_bootloader_requires
|
|
|
|
%else
|
2013-04-03 08:25:09 +02:00
|
|
|
Requires: perl-Bootloader
|
2017-02-16 03:17:33 +01:00
|
|
|
%endif
|
2013-01-17 10:43:06 +01:00
|
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
2014-08-04 11:46:50 +02:00
|
|
|
# For shim-install script
|
|
|
|
Requires: grub2-efi
|
2017-08-22 08:17:06 +02:00
|
|
|
# Disable AArch64 until we have the signature
|
|
|
|
ExclusiveArch: x86_64
|
2013-01-17 10:43:06 +01:00
|
|
|
|
|
|
|
%description
|
|
|
|
shim is a trivial EFI application that, when run, attempts to open and
|
|
|
|
execute another application.
|
|
|
|
|
2015-07-20 12:27:18 +02:00
|
|
|
%package -n shim-debuginfo
|
|
|
|
Summary: UEFI shim loader - debug symbols
|
|
|
|
Group: System/Boot
|
|
|
|
|
|
|
|
%description -n shim-debuginfo
|
|
|
|
The debug symbols of UEFI shim loader
|
|
|
|
|
|
|
|
%package -n shim-debugsource
|
|
|
|
Summary: UEFI shim loader - debug source
|
|
|
|
Group: System/Boot
|
2013-01-17 10:43:06 +01:00
|
|
|
|
2015-07-20 12:27:18 +02:00
|
|
|
%description -n shim-debugsource
|
|
|
|
The source code of UEFI shim loader
|
2013-01-17 10:43:06 +01:00
|
|
|
|
|
|
|
Authors:
|
|
|
|
--------
|
|
|
|
Matthew Garrett <mjg59@srcf.ucam.org>
|
|
|
|
|
|
|
|
%prep
|
|
|
|
%setup -q
|
|
|
|
%patch1 -p1
|
2017-08-22 08:17:06 +02:00
|
|
|
%patch2 -p1
|
2015-07-20 12:27:18 +02:00
|
|
|
%patch50 -p1
|
2017-08-22 08:17:06 +02:00
|
|
|
%if 0%{?is_opensuse} == 1
|
2014-04-29 09:15:01 +02:00
|
|
|
%patch100 -p1
|
2017-08-22 08:17:06 +02:00
|
|
|
%endif
|
2013-01-17 10:43:06 +01:00
|
|
|
%build
|
2013-08-29 10:43:23 +02:00
|
|
|
# first, build MokManager and fallback as they don't depend on a
|
|
|
|
# specific certificate
|
2017-08-22 08:17:06 +02:00
|
|
|
make EFI_PATH=/usr/lib64 RELEASE=0 MokManager.efi fallback.efi 2>/dev/null
|
2013-08-29 10:43:23 +02:00
|
|
|
|
|
|
|
# now build variants of shim that embed different certificates
|
|
|
|
default=''
|
|
|
|
suffixes=(opensuse sles)
|
|
|
|
# check whether the project cert is a known one. If it is we build
|
|
|
|
# just one shim that embeds this specific cert. If it's a devel
|
|
|
|
# project we build all variants to simplify testing.
|
2013-02-27 15:53:25 +01:00
|
|
|
if test -e %{_sourcedir}/_projectcert.crt ; then
|
|
|
|
prjsubject=$(openssl x509 -in %{_sourcedir}/_projectcert.crt -noout -subject_hash)
|
|
|
|
prjissuer=$(openssl x509 -in %{_sourcedir}/_projectcert.crt -noout -issuer_hash)
|
|
|
|
opensusesubject=$(openssl x509 -in %{SOURCE2} -noout -subject_hash)
|
|
|
|
slessubject=$(openssl x509 -in %{SOURCE4} -noout -subject_hash)
|
2013-08-29 10:43:23 +02:00
|
|
|
if test "$prjissuer" = "$opensusesubject" ; then
|
|
|
|
suffixes=(opensuse)
|
|
|
|
elif test "$prjissuer" = "$slessubject" ; then
|
|
|
|
suffixes=(sles)
|
|
|
|
elif test "$prjsubject" = "$prjissuer" ; then
|
|
|
|
suffixes=(devel opensuse sles)
|
2013-02-27 15:53:25 +01:00
|
|
|
fi
|
2013-08-29 10:43:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
for suffix in "${suffixes[@]}"; do
|
|
|
|
if test "$suffix" = "opensuse"; then
|
|
|
|
cert=%{SOURCE2}
|
|
|
|
cert2=%{SOURCE9}
|
2014-04-29 09:15:01 +02:00
|
|
|
verify='openSUSE Secure Boot CA1'
|
|
|
|
signature=%{SOURCE1}
|
2013-08-29 10:43:23 +02:00
|
|
|
elif test "$suffix" = "sles"; then
|
|
|
|
cert=%{SOURCE4}
|
|
|
|
cert2=''
|
2014-04-29 09:15:01 +02:00
|
|
|
verify='SUSE Linux Enterprise Secure Boot CA1'
|
|
|
|
signature=%{SOURCE12}
|
2013-08-29 10:43:23 +02:00
|
|
|
elif test "$suffix" = "devel"; then
|
|
|
|
cert=%{_sourcedir}/_projectcert.crt
|
|
|
|
cert2=''
|
2014-04-29 09:15:01 +02:00
|
|
|
verify=`openssl x509 -in "$cert" -noout -email`
|
|
|
|
signature=''
|
2013-08-29 10:43:23 +02:00
|
|
|
test -e "$cert" || continue
|
|
|
|
else
|
|
|
|
echo "invalid suffix"
|
|
|
|
false
|
2013-02-27 15:53:25 +01:00
|
|
|
fi
|
2013-08-29 10:43:23 +02:00
|
|
|
|
|
|
|
openssl x509 -in $cert -outform DER -out shim-$suffix.der
|
2014-04-29 09:15:01 +02:00
|
|
|
rm -f shim_cert.h shim.cer shim.crt
|
2013-08-29 10:43:23 +02:00
|
|
|
if [ -z "$cert2" ]; then
|
|
|
|
# create empty local cert file, we don't need a local key pair as we
|
|
|
|
# sign the mokmanager with our vendor key
|
|
|
|
touch shim.crt
|
|
|
|
touch shim.cer
|
|
|
|
else
|
|
|
|
cp $cert2 shim.crt
|
2013-02-27 15:53:25 +01:00
|
|
|
fi
|
2013-08-29 10:43:23 +02:00
|
|
|
# make sure cast warnings don't trigger post build check
|
2017-08-22 08:17:06 +02:00
|
|
|
make EFI_PATH=/usr/lib64 RELEASE=0 VENDOR_CERT_FILE=shim-$suffix.der ENABLE_HTTPBOOT=1 shim.efi
|
2014-04-29 09:15:01 +02:00
|
|
|
#
|
|
|
|
# assert correct certificate embedded
|
|
|
|
grep -q "$verify" shim.efi
|
2013-08-29 10:43:23 +02:00
|
|
|
# make VENDOR_CERT_FILE=cert.der VENDOR_DBX_FILE=dbx
|
2014-04-29 09:15:01 +02:00
|
|
|
chmod 755 %{SOURCE10}
|
2013-08-29 10:43:23 +02:00
|
|
|
# alternative: verify signature
|
|
|
|
#sbverify --cert MicCorThiParMarRoo_2010-10-05.pem shim-signed.efi
|
2014-04-29 09:15:01 +02:00
|
|
|
if test -n "$signature"; then
|
|
|
|
head -1 "$signature" > hash1
|
|
|
|
cp shim.efi shim.efi.bak
|
|
|
|
# pe header contains timestamp and checksum. we need to
|
|
|
|
# restore that
|
|
|
|
%{SOURCE10} --set-from-file "$signature" shim.efi
|
|
|
|
pesign -h -P -i shim.efi > hash2
|
|
|
|
cat hash1 hash2
|
|
|
|
if ! cmp -s hash1 hash2; then
|
|
|
|
echo "ERROR: $suffix binary changed, need to request new signature!"
|
2014-09-03 15:40:07 +02:00
|
|
|
%if %{defined shim_enforce_ms_signature}
|
|
|
|
false
|
|
|
|
%endif
|
2014-04-29 09:15:01 +02:00
|
|
|
mv shim.efi.bak shim-$suffix.efi
|
|
|
|
rm shim.efi
|
|
|
|
else
|
|
|
|
# attach signature
|
|
|
|
pesign -m "$signature" -i shim.efi -o shim-$suffix.efi
|
|
|
|
rm -f shim.efi
|
|
|
|
fi
|
2014-08-12 11:40:50 +02:00
|
|
|
else
|
|
|
|
mv shim.efi shim-$suffix.efi
|
2013-08-29 10:43:23 +02:00
|
|
|
fi
|
2015-07-20 12:27:18 +02:00
|
|
|
mv shim.efi.debug shim-$suffix.debug
|
2013-08-29 10:43:23 +02:00
|
|
|
rm -f shim.cer shim.crt
|
2013-09-09 05:29:33 +02:00
|
|
|
# make sure cert.o gets rebuilt
|
|
|
|
rm -f cert.o
|
2013-08-29 10:43:23 +02:00
|
|
|
done
|
2013-02-27 15:53:25 +01:00
|
|
|
|
2013-08-29 10:43:23 +02:00
|
|
|
ln -s shim-${suffixes[0]}.efi shim.efi
|
2015-07-20 12:27:18 +02:00
|
|
|
mv shim-${suffixes[0]}.debug shim.debug
|
|
|
|
|
|
|
|
# Collect the source for debugsource
|
2017-07-22 15:51:59 +02:00
|
|
|
mkdir ../source
|
|
|
|
find . \( -name "*.c" -o -name "*.h" \) -type f -exec cp --parents -a {} ../source/ \;
|
|
|
|
mv ../source .
|
2013-01-17 10:43:06 +01:00
|
|
|
|
|
|
|
%install
|
2013-07-23 06:44:22 +02:00
|
|
|
export BRP_PESIGN_FILES='%{_libdir}/efi/shim*.efi %{_libdir}/efi/MokManager.efi %{_libdir}/efi/fallback.efi'
|
2013-01-17 10:43:06 +01:00
|
|
|
install -d %{buildroot}/%{_libdir}/efi
|
2013-08-29 10:43:23 +02:00
|
|
|
cp -a shim*.efi %{buildroot}/%{_libdir}/efi
|
2013-02-27 15:53:25 +01:00
|
|
|
install -m 444 shim-*.der %{buildroot}/%{_libdir}/efi
|
2013-07-23 06:44:22 +02:00
|
|
|
install -m 644 MokManager.efi %{buildroot}/%{_libdir}/efi/MokManager.efi
|
|
|
|
install -m 644 fallback.efi %{buildroot}/%{_libdir}/efi/fallback.efi
|
2013-02-07 14:54:45 +01:00
|
|
|
install -d %{buildroot}/%{_sbindir}
|
|
|
|
install -m 755 %{SOURCE3} %{buildroot}/%{_sbindir}/
|
2013-07-23 06:44:22 +02:00
|
|
|
# install SUSE certificate
|
|
|
|
install -d %{buildroot}/%{_sysconfdir}/uefi/certs/
|
2013-08-29 10:43:23 +02:00
|
|
|
for file in shim-*.der; do
|
|
|
|
fpr=$(openssl x509 -sha1 -fingerprint -inform DER -noout -in $file | cut -c 18- | cut -d ":" -f 1,2,3,4 | sed 's/://g')
|
|
|
|
install -m 644 $file %{buildroot}/%{_sysconfdir}/uefi/certs/$fpr.crt
|
|
|
|
done
|
2013-01-17 10:43:06 +01:00
|
|
|
|
2015-07-20 12:27:18 +02:00
|
|
|
# install the debug symbols
|
|
|
|
install -d %{buildroot}/usr/lib/debug/%{_libdir}/efi
|
|
|
|
install -m 644 shim.debug %{buildroot}/usr/lib/debug/%{_libdir}/efi
|
|
|
|
install -m 644 MokManager.efi.debug %{buildroot}/usr/lib/debug/%{_libdir}/efi/MokManager.debug
|
|
|
|
install -m 644 fallback.efi.debug %{buildroot}/usr/lib/debug/%{_libdir}/efi/fallback.debug
|
|
|
|
|
|
|
|
# install the debug source
|
|
|
|
install -d %{buildroot}/usr/src/debug/%{name}-%{version}
|
|
|
|
cp -r source/* %{buildroot}/usr/src/debug/%{name}-%{version}
|
|
|
|
|
2013-01-17 10:43:06 +01:00
|
|
|
%clean
|
|
|
|
%{?buildroot:%__rm -rf "%{buildroot}"}
|
|
|
|
|
2013-04-03 08:25:09 +02:00
|
|
|
%post
|
2017-02-16 03:17:33 +01:00
|
|
|
%if 0%{?update_bootloader_check_type_reinit_post:1}
|
|
|
|
%update_bootloader_check_type_reinit_post grub2-efi
|
|
|
|
%else
|
2014-05-14 12:01:52 +02:00
|
|
|
/sbin/update-bootloader --reinit || true
|
2017-02-16 03:17:33 +01:00
|
|
|
%endif
|
|
|
|
|
|
|
|
%posttrans
|
|
|
|
%{?update_bootloader_posttrans}
|
2013-04-03 08:25:09 +02:00
|
|
|
|
2013-01-17 10:43:06 +01:00
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
|
|
|
%doc COPYRIGHT
|
|
|
|
%dir %{_libdir}/efi
|
2013-02-07 17:09:29 +01:00
|
|
|
%{_libdir}/efi/shim.efi
|
2013-02-27 15:53:25 +01:00
|
|
|
%{_libdir}/efi/shim-*.efi
|
|
|
|
%{_libdir}/efi/shim-*.der
|
2013-01-17 10:43:06 +01:00
|
|
|
%{_libdir}/efi/MokManager.efi
|
2013-07-23 06:44:22 +02:00
|
|
|
%{_libdir}/efi/fallback.efi
|
2013-02-07 14:54:45 +01:00
|
|
|
%{_sbindir}/shim-install
|
2013-07-23 06:44:22 +02:00
|
|
|
%dir %{_sysconfdir}/uefi/
|
|
|
|
%dir %{_sysconfdir}/uefi/certs/
|
|
|
|
%{_sysconfdir}/uefi/certs/*.crt
|
2013-01-17 10:43:06 +01:00
|
|
|
|
2015-07-20 12:27:18 +02:00
|
|
|
%files -n shim-debuginfo
|
|
|
|
%defattr(-,root,root,-)
|
|
|
|
/usr/lib/debug/%{_libdir}/efi/shim.debug
|
|
|
|
/usr/lib/debug/%{_libdir}/efi/MokManager.debug
|
|
|
|
/usr/lib/debug/%{_libdir}/efi/fallback.debug
|
|
|
|
|
|
|
|
%files -n shim-debugsource
|
|
|
|
%defattr(-,root,root,-)
|
|
|
|
%dir /usr/src/debug/%{name}-%{version}
|
|
|
|
/usr/src/debug/%{name}-%{version}/*
|
|
|
|
|
2013-01-17 10:43:06 +01:00
|
|
|
%changelog
|