File fwupdate.spec of Package fwupdate.12922

# spec file for package fwupdate
# Copyright (c) 2019 SUSE LINUX 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
# needssslcertforbuild

%ifarch %{x86} x86_64
# as soon as the kernel support SMBIOS calls over ACPI-WMI,
# this is no longer needed
%bcond_without libsmbios
%bcond_with libsmbios

Name:           fwupdate
Version:        12
Release:        0
Summary:        Tools to manage UEFI firmware updates
License:        GPL-2.0-or-later
Group:          System/Base
Patch0:         %{name}-suse-build.patch
Patch1:         %{name}-bsc1152928-update-aarch64-linker-script.patch
BuildRequires:  efivar-devel >= 34
BuildRequires:  elfutils
BuildRequires:  fdupes
BuildRequires:  gettext
BuildRequires:  gnu-efi >= 3.0.2
%if %{with libsmbios}
BuildRequires:  libsmbios-devel
BuildRequires:  pesign-obs-integration
BuildRequires:  pkg-config
BuildRequires:  popt-devel
BuildRequires:  systemd-rpm-macros
Requires:       %{name}-efi
Requires:       efibootmgr
Requires:       libfwup1 = %{version}-%{release}
%ifarch x86_64
Requires:       shim >= 11
ExclusiveArch:  x86_64 %{ix86} aarch64

%if 0%{?is_opensuse}
%global efidir opensuse
%global efidir sles

%undefine _unique_debug_names
%if 0%{?suse_version} > 1500
%define sysefibasedir  %{_datadir}/efi
%define sysefidir      %{sysefibasedir}/%{_target_cpu}
%define sysefidir      %{_libdir}/efi

fwupdate provides a simple command line interface to the UEFI firmware updates.

%package -n libfwup1
Summary:        Library to manage UEFI firmware updates
Group:          System/Libraries

%description -n libfwup1
Library to allow for the simple manipulation of UEFI firmware updates.

%package devel
Summary:        Development headers for libfwup
Group:          Development/Libraries/Other
Requires:       efivar-devel >= 34
Requires:       fwupdate = %{version}-%{release}
Requires:       libfwup1 = %{version}-%{release}

%description devel
development headers required to use libfwup.

%package efi
Summary:        UEFI binaries used by libfwup
Group:          System/Base
%ifarch x86_64
Requires:       shim

%description efi
UEFI binaries used by libfwup to update the firmware.

%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1

make PJONES="$RPM_OPT_FLAGS" libdir=%{_libdir} bindir=%{_bindir} \
     EFIDIR=%{efidir} GNUEFIDIR=%{_libdir} TARGETDIR=%{sysefidir} \

export BRP_PESIGN_FILES='%{_libdir}/efi/fwup*.efi'
%make_install libdir=%{_libdir} bindir=%{_bindir} mandir=%{_mandir} \
              localedir=%{_datadir}/locale/ includedir=%{_includedir} \
	      libexecdir=%{_libexecdir} datadir=%{_datadir} EFIDIR=%{efidir} \

echo 0%{?_build_create_debug}
%if 0%{?_build_create_debug} == 0
rm -rf %{buildroot}/usr/src/debug/%{name}*
rm -f  %{buildroot}/usr/lib/debug/%{sysefidir}/fwup*.efi.debug

%fdupes %{buildroot}%{_mandir}/*

# create rcsymlink
mkdir -p %{buildroot}%{_sbindir}
ln -sv %{_sbindir}/service %{buildroot}%{_sbindir}/rcfwupdate-cleanup

%service_add_pre fwupdate-cleanup.service

%service_add_post fwupdate-cleanup.service

%service_del_preun fwupdate-cleanup.service

%service_del_postun fwupdate-cleanup.service

%post -n libfwup1 -p /sbin/ldconfig

%postun -n libfwup1 -p /sbin/ldconfig

%posttrans -n %{name}-efi
# Create the directory for the firwmare update capsule
mkdir -p /boot/efi/EFI/%{efidir}/fw
# Install the UEFI firmware update program
cp %{sysefidir}/fwup*.efi /boot/efi/EFI/%{efidir}

%postun -n %{name}-efi
if [ "$1" = 0 ] ; then
	# Remove all the capsules
	rm -rf /boot/efi/EFI/%{efidir}/fw
	# Remove the UEFI firmware update program
	rm -f /boot/efi/EFI/%{efidir}/fwup*.efi

%license COPYING
%doc %{_mandir}/man1/*
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%ghost %attr(0755,root,root) %dir %{_rundir}/fwupdate/
%attr(0755,root,root) %dir %{_libexecdir}/fwupdate/

%files devel
%doc %{_mandir}/man3/*

%files -n libfwup1

%files efi
%dir %{?sysefibasedir}
%dir %{sysefidir}

openSUSE Build Service is sponsored by