2013-01-17 09:43:06 +00:00
#
# spec file for package shim
#
2014-01-29 10:49:44 +00:00
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
2013-01-17 09:43:06 +00: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 13:54:45 +00:00
# needssslcertforbuild
2013-01-17 09:43:06 +00:00
Name : shim
2013-12-05 02:46:29 +00:00
Version : 0.7
2013-01-17 09:43:06 +00:00
Release : 0
Summary : UEFI shim loader
License : BSD-2-Clause
Group : System/Boot
Url : https://github.com/mjg59/shim
Source : %{name} -%{version} .tar.bz2
2013-08-09 09:33:45 +00:00
# run "extract_signature.sh shim.efi" where shim.efi is the binary
# with the signature from the UEFI signing service.
2014-02-21 02:21:37 +00:00
Source1 : signature-opensuse.asc
2013-01-29 13:42:18 +00:00
Source2 : openSUSE-UEFI-CA-Certificate.crt
2013-02-07 13:54:45 +00:00
Source3 : shim-install
2013-02-27 14:53:25 +00:00
Source4 : SLES-UEFI-CA-Certificate.crt
2013-08-09 09:33:45 +00:00
Source5 : extract_signature.sh
Source6 : attach_signature.sh
Source7 : show_hash.sh
2013-08-28 09:32:58 +00:00
Source8 : show_signatures.sh
Source9 : openSUSE-UEFI-CA-Certificate-4096.crt
2013-09-09 03:29:33 +00:00
Source10 : timestamp.pl
2014-02-13 01:57:08 +00:00
Source11 : strip_signature.sh
2014-02-21 02:21:37 +00:00
Source12 : signature-sles.asc
2013-12-05 02:46:29 +00:00
# PATCH-FIX-UPSTREAM shim-fix-verify-mok.patch glin@suse.com -- Fix the error handling in verify_mok()
Patch1 : shim-fix-verify-mok.patch
# PATCH-FIX-UPSTREAM shim-improve-error-messages.patch glin@suse.com -- Improve the error messages
Patch2 : shim-improve-error-messages.patch
# PATCH-FIX-UPSTREAM shim-correct-user_insecure-usage.patch glin@suse.com -- Correct the usage of the user insecure mode variable
Patch3 : shim-correct-user_insecure-usage.patch
# PATCH-FIX-UPSTREAM shim-fix-dhcpv4-path-generation.patch glin@suse.com -- Fix path generation for DHCPv4 bootloader
Patch4 : shim-fix-dhcpv4-path-generation.patch
# PATCH-FIX-UPSTREAM shim-mokx-support.patch glin@suse.com -- Support MOK blacklist
Patch5 : shim-mokx-support.patch
2013-12-06 07:16:12 +00:00
# PATCH-FIX-UPSTREAM shim-mokmanager-handle-keystroke-error.patch glin@suse.com -- Handle the error status from ReadKeyStroke to avoid the unexpected keys
Patch6 : shim-mokmanager-handle-keystroke-error.patch
2014-02-13 01:57:08 +00:00
# PATCH-FIX-SUSE shim-only-os-name.patch glin@suse.com -- Only include the OS name in version.c
Patch7 : shim-only-os-name.patch
# PATCH-FIX-UPSTREAM shim-get-variable-check.patch glin@suse.com -- Fix the variable checking in get_variable_attr
Patch8 : shim-get-variable-check.patch
# PATCH-FIX-UPSTREAM shim-fallback-improve--entries-creation.patch glin@suse.com -- Improve the boot entry pathes and avoid generating the boot entries that are already there
Patch9 : shim-fallback-improve-entries-creation.patch
2014-02-18 03:46:55 +00:00
# PATCH-FIX-UPSTREAM shim-bnc863205-mokmanager-fix-hash-delete.patch bnc#863205 glin@suse.com -- Fix the hash deletion operation to avoid ruining the whole list
Patch10 : shim-bnc863205-mokmanager-fix-hash-delete.patch
2014-03-06 07:55:56 +00:00
# PATCH-FIX-UPSTREAM shim-fallback-avoid-duplicate-bootorder.patch glin@suse.com -- Fix the duplicate BootOrder entries generated by fallback.efi
Patch11 : shim-fallback-avoid-duplicate-bootorder.patch
# PATCH-FIX-UPSTREAM shim-allow-fallback-use-system-loadimage.patch -- Handle the shim protocol properly to keep only one protocol entity
Patch12 : shim-allow-fallback-use-system-loadimage.patch
2014-03-07 09:40:50 +00:00
# PATCH-FIX-UPSTREAM shim-mokmanager-delete-bs-var-right.patch -- Delete BootService non-volatile variables the right way
Patch13 : shim-mokmanager-delete-bs-var-right.patch
2014-02-28 10:04:44 +00: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
2013-07-23 04:44:22 +00:00
BuildRequires : gnu-efi >= 3.0t
2013-01-17 09:43:06 +00:00
BuildRequires : mozilla-nss-tools
BuildRequires : openssl >= 0.9.8
BuildRequires : pesign
2013-02-07 13:54:45 +00:00
BuildRequires : pesign-obs-integration
2013-04-03 06:25:09 +00:00
Requires : perl-Bootloader
2013-01-17 09:43:06 +00:00
BuildRoot : %{_tmppath} /%{name} -%{version} -build
2013-02-07 13:54:45 +00:00
Recommends: grub2-efi
2013-01-17 09:43:06 +00:00
ExclusiveArch : x86_64
%description
shim is a trivial EFI application that, when run, attempts to open and
execute another application.
Authors:
--------
Matthew Garrett <mjg59@srcf.ucam.org>
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
2013-07-23 04:44:22 +00:00
%patch4 -p1
2013-01-17 09:43:06 +00:00
%patch5 -p1
2013-12-06 07:16:12 +00:00
%patch6 -p1
2014-02-13 01:57:08 +00:00
%patch7 -p1
%patch8 -p1
%patch9 -p1
2014-02-18 03:46:55 +00:00
%patch10 -p1
2014-03-06 07:55:56 +00:00
%patch11 -p1
%patch12 -p1
2014-03-07 09:40:50 +00:00
%patch13 -p1
2014-02-28 10:04:44 +00:00
%patch100 -p1
2013-01-17 09:43:06 +00:00
%build
2013-08-29 08:43:23 +00:00
# first, build MokManager and fallback as they don't depend on a
# specific certificate
2013-12-05 02:46:29 +00:00
make EFI_PATH=/usr/lib64 MokManager.efi fallback.efi 2>/dev/null
2013-08-29 08:43:23 +00: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 14:53:25 +00: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 08:43:23 +00:00
if test " $ p r j i s s u e r " = " $ o p e n s u s e s u b j e c t " ; then
suffixes=(opensuse)
elif test " $ p r j i s s u e r " = " $ s l e s s u b j e c t " ; then
suffixes=(sles)
elif test " $ p r j s u b j e c t " = " $ p r j i s s u e r " ; then
suffixes=(devel opensuse sles)
2013-02-27 14:53:25 +00:00
fi
2013-08-29 08:43:23 +00:00
fi
for suffix in " $ { s u f f i x e s [ @ ] } " ; do
if test " $ s u f f i x " = " o p e n s u s e " ; then
cert=%{SOURCE2}
cert2=%{SOURCE9}
2014-02-21 02:21:37 +00:00
verify='openSUSE Secure Boot CA1'
signature=%{SOURCE1}
2013-08-29 08:43:23 +00:00
elif test " $ s u f f i x " = " s l e s " ; then
cert=%{SOURCE4}
cert2=''
2014-02-21 02:21:37 +00:00
verify='SUSE Linux Enterprise Secure Boot CA1'
signature=%{SOURCE12}
2013-08-29 08:43:23 +00:00
elif test " $ s u f f i x " = " d e v e l " ; then
cert=%{_sourcedir} /_projectcert.crt
cert2=''
2014-02-21 02:21:37 +00:00
verify=`openssl x509 -in " $ c e r t " -noout -email`
signature=''
2013-08-29 08:43:23 +00:00
test -e " $ c e r t " || continue
else
echo " i n v a l i d s u f f i x "
false
2013-02-27 14:53:25 +00:00
fi
2013-08-29 08:43:23 +00:00
openssl x509 -in $cert -outform DER -out shim-$suffix.der
2014-02-20 10:26:49 +00:00
rm -f shim_cert.h shim.cer shim.crt
2013-08-29 08:43:23 +00:00
if [ -z " $ c e r t 2 " ]; 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 14:53:25 +00:00
fi
2013-08-29 08:43:23 +00:00
# make sure cast warnings don't trigger post build check
2013-12-05 02:46:29 +00:00
make EFI_PATH=/usr/lib64 VENDOR_CERT_FILE=shim-$suffix.der shim.efi 2>/dev/null
2014-02-21 02:21:37 +00:00
#
# assert correct certificate embedded
grep -q " $ v e r i f y " shim.efi
2013-08-29 08:43:23 +00:00
# make VENDOR_CERT_FILE=cert.der VENDOR_DBX_FILE=dbx
2014-02-13 01:57:08 +00:00
chmod 755 %{SOURCE10}
2013-08-29 08:43:23 +00:00
# alternative: verify signature
#sbverify --cert MicCorThiParMarRoo_2010-10-05.pem shim-signed.efi
2014-02-21 02:21:37 +00:00
if test -n " $ s i g n a t u r e " ; then
head -1 " $ s i g n a t u r e " > hash1
cp shim.efi shim.efi.bak
# pe header contains timestamp and checksum. we need to
# restore that
%{SOURCE10} --set-from-file " $ s i g n a t u r e " shim.efi
pesign -h -P -i shim.efi > hash2
cat hash1 hash2
if ! cmp -s hash1 hash2; then
echo " E R R O R : $ s u f f i x b i n a r y c h a n g e d , n e e d t o r e q u e s t n e w s i g n a t u r e ! "
# don't fail in devel projects
prj=" % { _ p r o j e c t } "
if [ " $ { p r j % % % : * } " = " o p e n S U S E " -o " $ { p r j % % % : * } " = " S U S E " ]; then
false
fi
mv shim.efi.bak shim-$suffix.efi
rm shim.efi
else
# attach signature
pesign -m %{SOURCE1} -i shim.efi -o shim-$suffix.efi
rm -f shim.efi
fi
2013-08-29 08:43:23 +00:00
fi
rm -f shim.cer shim.crt
2013-09-09 03:29:33 +00:00
# make sure cert.o gets rebuilt
rm -f cert.o
2013-08-29 08:43:23 +00:00
done
2013-02-27 14:53:25 +00:00
2013-08-29 08:43:23 +00:00
ln -s shim-${suffixes[0]}.efi shim.efi
2013-01-17 09:43:06 +00:00
%install
2013-07-23 04:44:22 +00:00
export BRP_PESIGN_FILES='%{_libdir}/efi/shim*.efi %{_libdir}/efi/MokManager.efi %{_libdir}/efi/fallback.efi'
2013-01-17 09:43:06 +00:00
install -d %{buildroot} /%{_libdir} /efi
2013-08-29 08:43:23 +00:00
cp -a shim*.efi %{buildroot} /%{_libdir} /efi
2013-02-27 14:53:25 +00:00
install -m 444 shim-*.der %{buildroot} /%{_libdir} /efi
2013-07-23 04:44:22 +00:00
install -m 644 MokManager.efi %{buildroot} /%{_libdir} /efi/MokManager.efi
install -m 644 fallback.efi %{buildroot} /%{_libdir} /efi/fallback.efi
2013-02-07 13:54:45 +00:00
install -d %{buildroot} /%{_sbindir}
install -m 755 %{SOURCE3} %{buildroot} /%{_sbindir} /
2013-07-23 04:44:22 +00:00
# install SUSE certificate
install -d %{buildroot} /%{_sysconfdir} /uefi/certs/
2013-08-29 08:43:23 +00: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 09:43:06 +00:00
%clean
%{?buildroot:%__rm -rf " %{buildroot} " }
2013-04-03 06:25:09 +00:00
%post
/sbin/update-bootloader --refresh || true
2013-01-17 09:43:06 +00:00
%files
%defattr (-,root,root)
%doc COPYRIGHT
%dir %{_libdir} /efi
2013-02-07 16:09:29 +00:00
%{_libdir} /efi/shim.efi
2013-02-27 14:53:25 +00:00
%{_libdir} /efi/shim-*.efi
%{_libdir} /efi/shim-*.der
2013-01-17 09:43:06 +00:00
%{_libdir} /efi/MokManager.efi
2013-07-23 04:44:22 +00:00
%{_libdir} /efi/fallback.efi
2013-02-07 13:54:45 +00:00
%{_sbindir} /shim-install
2013-07-23 04:44:22 +00:00
%dir %{_sysconfdir} /uefi/
%dir %{_sysconfdir} /uefi/certs/
%{_sysconfdir} /uefi/certs/*.crt
2013-01-17 09:43:06 +00:00
%changelog