2013-01-17 10:43:06 +01:00
#
# spec file for package shim
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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
2013-01-17 10:43:06 +01:00
Name : shim
2013-07-23 06:44:22 +02:00
Version : 0.4
2013-01-17 10:43:06 +01: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 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.
Source1 : microsoft.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-01-17 10:43:06 +01:00
# PATCH-FIX-SUSE shim-suse-build.patch glin@suse.com -- Adjust Makefile for the build service
Patch0 : shim-suse-build.patch
2013-07-23 06:44:22 +02:00
# PATCH-FIX-UPSTREAM shim-fix-pointer-casting.patch glin@suse.com -- Fix a casting issue and the size of an empty vendor_cert or dbx_cert.
Patch1 : shim-fix-pointer-casting.patch
# PATCH-FIX-UPSTREAM shim-merge-lf-loader-code.patch glin@suse.com -- Merge the Linux Foundation loader UI code
Patch2 : shim-merge-lf-loader-code.patch
# PATCH-FIX-UPSTREAM shim-fix-simple-file-selector.patch glin@suse.com -- Fix the buffer allocation in the simple file selector
Patch3 : shim-fix-simple-file-selector.patch
2013-01-30 11:19:49 +01:00
# PATCH-FIX-UPSTREAM shim-mokmanager-support-crypt-hash-method.patch glin@suse.com -- Support the password hashes from /etc/shadow
2013-07-23 06:44:22 +02:00
Patch4 : shim-mokmanager-support-crypt-hash-method.patch
2013-02-22 11:31:48 +01:00
# PATCH-FIX-UPSTREAM shim-bnc804631-fix-broken-bootpath.patch bnc#804631 glin@suse.com -- Fix the broken bootpath generated in generate_path()
2013-07-23 06:44:22 +02:00
Patch5 : shim-bnc804631-fix-broken-bootpath.patch
2013-03-05 11:12:49 +01:00
# PATCH-FIX-UPSTREAM shim-bnc798043-no-doulbe-separators.patch bnc#798043 glin@suse.com -- Remove all double-separators from the bootpath
2013-07-23 06:44:22 +02:00
Patch6 : shim-bnc798043-no-doulbe-separators.patch
2013-03-08 09:06:19 +01:00
# PATCH-FIX-UPSTREAM shim-bnc807760-change-pxe-2nd-loader-name.patch bnc#807760 glin@suse.com -- Change the PXE 2nd stage loader to match the filename we are using
2013-07-23 06:44:22 +02:00
Patch7 : shim-bnc807760-change-pxe-2nd-loader-name.patch
2013-03-08 09:06:19 +01:00
# PATCH-FIX-UPSTREAM shim-bnc808106-correct-certcount.patch bnc#808106 glin@suse.com -- Correct the certifcate count of the signature list
2013-07-23 06:44:22 +02:00
Patch8 : shim-bnc808106-correct-certcount.patch
2013-05-08 08:52:29 +02:00
# PATCH-FIX-UPSTREAM shim-mokmanager-ui-revamp.patch glin@suse.com -- Revamp the MokManager UI
2013-07-23 06:44:22 +02:00
Patch9 : shim-mokmanager-ui-revamp.patch
BuildRequires : gnu-efi >= 3.0t
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
2013-04-03 08:25:09 +02:00
Requires : perl-Bootloader
2013-01-17 10:43:06 +01:00
BuildRoot : %{_tmppath} /%{name} -%{version} -build
2013-02-07 14:54:45 +01:00
Recommends: grub2-efi
2013-01-17 10:43:06 +01: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
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
2013-07-23 06:44:22 +02:00
%patch4 -p1
2013-01-17 10:43:06 +01:00
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
2013-01-30 11:19:49 +01:00
%patch9 -p1
2013-01-17 10:43:06 +01:00
%build
chmod +x " m a k e - c e r t s "
2013-02-27 15:53:25 +01:00
2013-08-29 10:43:23 +02:00
# first, build MokManager and fallback as they don't depend on a
# specific certificate
make MokManager.efi fallback.efi 2>/dev/null
# 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 " $ 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 15:53:25 +01:00
fi
2013-08-29 10:43:23 +02: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}
elif test " $ s u f f i x " = " s l e s " ; then
cert=%{SOURCE4}
cert2=''
elif test " $ s u f f i x " = " d e v e l " ; then
cert=%{_sourcedir} /_projectcert.crt
cert2=''
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 15:53:25 +01:00
fi
2013-08-29 10:43:23 +02:00
openssl x509 -in $cert -outform DER -out shim-$suffix.der
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
rm -f shim.cer
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
make VENDOR_CERT_FILE=shim-$suffix.der shim.efi 2>/dev/null
# make VENDOR_CERT_FILE=cert.der VENDOR_DBX_FILE=dbx
chmod 755 %{SOURCE6} %{SOURCE7}
# alternative: verify signature
#sbverify --cert MicCorThiParMarRoo_2010-10-05.pem shim-signed.efi
head -1 %{SOURCE1} > hash1
%{SOURCE7} shim.efi > hash2
cat hash1 hash2
if ! cmp -s hash1 hash2; then
echo " E R R O R : 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 " ]; then
false
fi
mv shim.efi shim-$suffix.efi
else
%{SOURCE6} %{SOURCE1} shim.efi
mv shim-signed.efi shim-$suffix.efi
rm -f shim.efi
fi
rm -f shim.cer shim.crt
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
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
%clean
%{?buildroot:%__rm -rf " %{buildroot} " }
2013-04-03 08:25:09 +02:00
%post
/sbin/update-bootloader --refresh || true
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
%changelog